Browse Source

Fix slide update on download

- Also fix ssl error for image download

Fixes #1
refactor
octogene 4 years ago
parent
commit
f297cb56bb
  1. 18
      hadaly/app.py

18
hadaly/app.py

@ -369,8 +369,12 @@ class HadalyApp(App):
url = quote(url, safe="%/:=&?~#+!$,;'@()*[]")
path = os.path.join(self.tempdir,
os.path.basename(urlparse(url).path))
headers = {"User-Agent": "Mozilla/5.0 (Windows NT 5.1; rv:31.0) Gecko/20100101 Firefox/31.0"}
req = UrlRequest(url, self.reload_slide, file_path=path, on_progress=self.show_download_progress,
headers = {"User-Agent": "Mozilla/5.0 (Windows NT 5.1; rv:31.0) "
"Gecko/20100101 Firefox/31.0"}
url = url.replace("https", "http")
req = UrlRequest(url, self.reload_slide,
file_path=path,
on_progress=self.show_download_progress,
req_headers=headers, debug=True)
self.progress_dialog.open()
@ -389,10 +393,13 @@ class HadalyApp(App):
for slide in slides:
img_src = urlparse(slide.img.img_src)
if img_src[0] == 'http' and img_src[2].endswith(filename):
Logger.debug('Application: Found slide ! Updating image source...')
slide.img.img_src = os.path.join(self.tempdir, filename)
Logger.debug('Application: Found slide ! '
'Updating image source...')
# Update presentation info
idx = self.presentation['slides'].index(slide.img.get_slide_info())
slide.img.img_src = self.presentation['slides'][idx]['img_src'] = os.path.join(self.tempdir, filename)
Logger.debug('Application: {src}'.format(src=slide.img.img_src))
slide.img.thumb_src = self.create_thumbnail(slide.img.img_src)
slide.img.thumb_src = self.presentation['slides'][idx]['thumb_src'] =self.create_thumbnail(slide.img.img_src)
slide.img.update_texture_size()
self.root.current = 'editor'
@ -471,6 +478,7 @@ class HadalyApp(App):
)
for photo in results:
photo['thumb'] = photo['thumb'].replace("https", "http")
Logger.debug('Search : Loading {url}'.format(url=photo['thumb']))
image = ItemButton(photo=photo, source=photo['thumb'], keep_ratio=True)
search_screen.box.grid.add_widget(image)

Loading…
Cancel
Save