From f8d9be2d5a947a2adde12d187a52b18b7218c541 Mon Sep 17 00:00:00 2001 From: zrose584 <57181548+zrose584@users.noreply.github.com> Date: Wed, 7 Oct 2020 19:28:52 +0200 Subject: settings.py: add 'proxy_images' --- youtube/util.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'youtube/util.py') diff --git a/youtube/util.py b/youtube/util.py index 3c32ddb..a75a7b5 100644 --- a/youtube/util.py +++ b/youtube/util.py @@ -342,8 +342,8 @@ def video_id(url): # default, sddefault, mqdefault, hqdefault, hq720 def get_thumbnail_url(video_id): - return "/i.ytimg.com/vi/" + video_id + "/mqdefault.jpg" - + return f"{settings.img_prefix}https://i.ytimg.com/vi/" + video_id + "/mqdefault.jpg" + def seconds_to_timestamp(seconds): seconds = int(seconds) hours, seconds = divmod(seconds,3600) @@ -394,10 +394,11 @@ def concat_or_none(*strings): def prefix_urls(item): - try: - item['thumbnail'] = prefix_url(item['thumbnail']) - except KeyError: - pass + if settings.proxy_images: + try: + item['thumbnail'] = prefix_url(item['thumbnail']) + except KeyError: + pass try: item['author_url'] = prefix_url(item['author_url']) -- cgit v1.2.3