aboutsummaryrefslogtreecommitdiffstats
path: root/youtube/util.py
diff options
context:
space:
mode:
authorJames Taylor <28744867+user234683@users.noreply.github.com>2020-10-12 09:37:54 -0700
committerGitHub <noreply@github.com>2020-10-12 09:37:54 -0700
commit641af53e2ea0cb7ea398631d13c804d7ac1e0a8a (patch)
tree7dfecaadce3cc58ddcc86e2cd9d5ef762563e9ce /youtube/util.py
parent2cfc6dec39ccdcc0c5fe2eea73f47b7040e51833 (diff)
parentfd253d9e07fa34e2a22d28d445839147daca9ee0 (diff)
downloadyt-local-641af53e2ea0cb7ea398631d13c804d7ac1e0a8a.tar.lz
yt-local-641af53e2ea0cb7ea398631d13c804d7ac1e0a8a.tar.xz
yt-local-641af53e2ea0cb7ea398631d13c804d7ac1e0a8a.zip
Merge pull request #24 from zrose584/optional_proxy_images
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..579f512 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 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'])