aboutsummaryrefslogtreecommitdiffstats
path: root/youtube/util.py
diff options
context:
space:
mode:
authorzrose584 <57181548+zrose584@users.noreply.github.com>2020-10-07 19:28:52 +0200
committerzrose584 <57181548+zrose584@users.noreply.github.com>2020-10-07 19:28:52 +0200
commitf8d9be2d5a947a2adde12d187a52b18b7218c541 (patch)
treee0c2943b1de9f400acdbd25db2492c3673d88733 /youtube/util.py
parent9123d9a6cfa2af511b17591541ab2e67aa83475f (diff)
downloadyt-local-f8d9be2d5a947a2adde12d187a52b18b7218c541.tar.lz
yt-local-f8d9be2d5a947a2adde12d187a52b18b7218c541.tar.xz
yt-local-f8d9be2d5a947a2adde12d187a52b18b7218c541.zip
settings.py: add 'proxy_images'
Diffstat (limited to 'youtube/util.py')
-rw-r--r--youtube/util.py13
1 files changed, 7 insertions, 6 deletions
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'])