Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -103,8 +103,9 @@ def make_animation():
|
|
103 |
get_url=f'{main_directory}images/animations/'
|
104 |
feed1 = requests.get(get_url)
|
105 |
spl = feed1.text.split("href=")
|
106 |
-
gif_box=[]
|
107 |
for line in spl:
|
|
|
|
|
108 |
spl2 = line.split(">")[0].strip('""')
|
109 |
if spl2.endswith("/"):
|
110 |
feed2 = requests.get(f'{get_url}{spl2}')
|
@@ -114,16 +115,16 @@ def make_animation():
|
|
114 |
if spl3.endswith(".png") or spl3.endswith(".gif") or spl3.endswith(".jpg"):
|
115 |
gif_box.append(f'{get_url}{spl2}{spl3}')
|
116 |
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
html_out+='</div>'
|
128 |
return html_out
|
129 |
|
|
|
103 |
get_url=f'{main_directory}images/animations/'
|
104 |
feed1 = requests.get(get_url)
|
105 |
spl = feed1.text.split("href=")
|
|
|
106 |
for line in spl:
|
107 |
+
gif_box=[]
|
108 |
+
|
109 |
spl2 = line.split(">")[0].strip('""')
|
110 |
if spl2.endswith("/"):
|
111 |
feed2 = requests.get(f'{get_url}{spl2}')
|
|
|
115 |
if spl3.endswith(".png") or spl3.endswith(".gif") or spl3.endswith(".jpg"):
|
116 |
gif_box.append(f'{get_url}{spl2}{spl3}')
|
117 |
|
118 |
+
#frames = [Image.open(image) for image in glob.glob(f"{frame_folder}/*.JPG")]
|
119 |
+
frames = []
|
120 |
+
for i,ea in enumerate(gif_box):
|
121 |
+
urllib.request.urlretrieve(ea,f'tmp{i}.png')
|
122 |
+
frames.append(Image.open(f'tmp{i}.png'))
|
123 |
+
frame_one = frames[0]
|
124 |
+
filename=f'{spl3.split(".")[0]}.gif'
|
125 |
+
frame_one.save(filename, format="GIF", append_images=frames,
|
126 |
+
save_all=True, duration=100, loop=0)
|
127 |
+
html_out+=f'<div class="img_class"><img src="{filename}"></div>'
|
128 |
html_out+='</div>'
|
129 |
return html_out
|
130 |
|