Proxy images through nginx v1

This commit is contained in:
pluja 2020-09-14 20:39:10 +02:00
parent 23a2809e0b
commit d2dfbbdb5f
3 changed files with 9 additions and 1 deletions

View File

@ -775,7 +775,11 @@ def getYoutubePosts(ids):
video.channelUrl = vid.author_detail.href
video.id = vid.yt_videoid
video.videoTitle = vid.title
video.videoThumb = vid.media_thumbnail[0]['url'].replace('/', '~')
if config['nginxVideoStream']:
hostName = urllib.parse.urlparse(vid.media_thumbnail[0]['url']).netloc
video.videoThumb = vid.media_thumbnail[0]['url'].replace(hostName, config['serverName'])+"?hostname="+hostName
else:
video.videoThumb = vid.media_thumbnail[0]['url'].replace('/', '~')
video.views = vid.media_statistics['views']
video.description = vid.summary_detail.value
video.description = re.sub(r'^https?:\/\/.*[\r\n]*', '', video.description[0:120]+"...", flags=re.MULTILINE)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 59 KiB

View File

@ -1,6 +1,10 @@
<div class="card">
<div class="image">
{%if config.nginxVideoStream%}
<img alt="Thumbnail" src="{{video.videoThumb}}">
{%else%}
<img alt="Thumbnail" src="/img/{{video.videoThumb.replace('/', '~')}}">
{%endif%}
</div>
<div class="content">
{% if video.views == "Livestream" %}