cleanup and docs

This commit is contained in:
msramalho
2022-02-23 16:07:58 +01:00
parent 9550cd509e
commit 9a264a7dfe
6 changed files with 55 additions and 27 deletions

View File

@@ -10,7 +10,7 @@ class TelegramArchiver(Archiver):
def download(self, url, check_if_exists=False):
# detect URLs that we definitely cannot handle
if 'http://t.me/' not in url and 'https://t.me/' not in url:
if 't.me' != self.get_netloc(url):
return False
headers = {
@@ -20,7 +20,7 @@ class TelegramArchiver(Archiver):
original_url = url
# TODO: check if we can do this more resilient to user-input
# TODO: check if we can do this more resilient to variable URLs
if url[-8:] != "?embed=1":
url += "?embed=1"
@@ -32,8 +32,8 @@ class TelegramArchiver(Archiver):
return False # could not find video
video_url = video.get('src')
key = video_url.split('/')[-1].split('?')[0]
key = self.get_key(key)
video_id = video_url.split('/')[-1].split('?')[0]
key = self.get_key(video_id)
filename = 'tmp/' + key
@@ -60,7 +60,7 @@ class TelegramArchiver(Archiver):
duration = float(duration)
# process thumbnails
key_thumb, thumb_index = self.get_thumbnails(filename, duration=duration)
key_thumb, thumb_index = self.get_thumbnails(filename, key, duration=duration)
os.remove(filename)
return ArchiveResult(status=status, cdn_url=cdn_url, thumbnail=key_thumb, thumbnail_index=thumb_index,