-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathVideoTagGenerator.py
More file actions
53 lines (47 loc) · 2.21 KB
/
Copy pathVideoTagGenerator.py
File metadata and controls
53 lines (47 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import os
import linecache
def distinct_tag():
# with is like your try .. finally block in this case
with open('templates//First_part.html', 'r') as file:
# read a list of lines into data
first_data = file.readlines()
file.close()
# with is like your try .. finally block in this case
with open('templates//End_part.html', 'r') as file:
# read a list of lines into data
end_data = file.readlines()
file.close()
return first_data, end_data
def make_tag(username, first_part, end_part):
#first part
first_part.append('\t<div class="top-brands-login">\n')
first_part.append('\t\t<div class="container">\n')
first_part.append('\t\t\t<h3>فیلم های رنگی شده </h3>\n')
#middle part
str_list = []
videoDirectory = os.listdir('static//UserColorizedVideos//' + username)
if videoDirectory:
count=0
str_list.append('\t\t\t<div class="horizontal-scroll-wrapper squares">\n')
for f in videoDirectory:
count+=1
str_list.append('\t\t\t\t<div>\n')
str_list.append('\t\t\t\t\t<video id="video{}" controls width="200px" height="150px">\n'.format(count))
str_list.append('\t\t\t\t\t\t<source id="vid{}" src="../static/ColorizedVideo.mp4" type="video/mp4">\n'.format(count))
str_list.append('\t\t\t\t\t\t<script>\n')
str_list.append('\t\t\t\t\t\t\tusername = document.getElementById("u1").innerHTML;\n')
str_list.append('\t\t\t\t\t\t\tdocument.getElementById("vid{}").src = "../static/UserColorizedVideos/" + username + "/{}";\n'.format(count, f))
str_list.append('\t\t\t\t\t\t</script>\n')
str_list.append('\t\t\t\t\t\tYour browser does not support HTML5 video.\n')
str_list.append('\t\t\t\t\t</video>\n')
str_list.append('\t\t\t\t</div>\n')
str_list.append('\t\t\t</div>\n')
#end part
firstEnd_part = []
firstEnd_part.append('\t\t</div>\n')
firstEnd_part.append('\t</div>\n')
end_part = firstEnd_part + end_part
# and write everything back
with open('templates//indexlogin.html', 'w') as file:
file.writelines(first_part + str_list + end_part)
file.close()