mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-04-13 09:42:01 +00:00
Adding Twitter video support.
This commit is contained in:
parent
bb0f309ba9
commit
77ba037fa7
2 changed files with 21 additions and 1 deletions
|
@ -2390,7 +2390,7 @@ class _HTMLSanitizer(_BaseHTMLProcessor):
|
||||||
'template', 'title', 'toppadding', 'type', 'unselectable', 'usemap',
|
'template', 'title', 'toppadding', 'type', 'unselectable', 'usemap',
|
||||||
'urn', 'valign', 'value', 'variable', 'volume', 'vspace', 'vrml',
|
'urn', 'valign', 'value', 'variable', 'volume', 'vspace', 'vrml',
|
||||||
'width', 'wrap', 'xml:lang',
|
'width', 'wrap', 'xml:lang',
|
||||||
'allowfullscreen'])
|
'allowfullscreen', 'autoplay', 'muted', 'playsinline'])
|
||||||
|
|
||||||
unacceptable_elements_with_end_tag = set(['script', 'applet', 'style'])
|
unacceptable_elements_with_end_tag = set(['script', 'applet', 'style'])
|
||||||
|
|
||||||
|
|
|
@ -227,6 +227,26 @@ class TwitterFetcher:
|
||||||
entities += "<img src=\"%s\"> <hr>" % media['media_url_https']
|
entities += "<img src=\"%s\"> <hr>" % media['media_url_https']
|
||||||
if 'photo' not in categories:
|
if 'photo' not in categories:
|
||||||
categories.add('photo')
|
categories.add('photo')
|
||||||
|
if media['type'] == 'video':
|
||||||
|
if media.get('url') and media['url'] in tweet_text:
|
||||||
|
tweet_title = tweet_title.replace(media['url'], media['display_url'])
|
||||||
|
replacement = "<a href=\"%s\">%s</a>" % (media['expanded_url'], media['display_url'])
|
||||||
|
if not replaced.get(media['url']):
|
||||||
|
tweet_text = tweet_text.replace(media['url'], replacement)
|
||||||
|
replaced[media['url']] = True
|
||||||
|
bitrate = 0
|
||||||
|
chosen_variant = None
|
||||||
|
for variant in media['video_info']['variants']:
|
||||||
|
if not chosen_variant:
|
||||||
|
chosen_variant = variant
|
||||||
|
if variant.get('bitrate', 0) > bitrate:
|
||||||
|
bitrate = variant['bitrate']
|
||||||
|
chosen_variant = variant
|
||||||
|
if chosen_variant:
|
||||||
|
entities += "<video src=\"%s\" autoplay loop muted playsinline> <hr>" % chosen_variant['url']
|
||||||
|
if 'video' not in categories:
|
||||||
|
categories.add('video')
|
||||||
|
|
||||||
|
|
||||||
for url in content_tweet['entities'].get('urls', []):
|
for url in content_tweet['entities'].get('urls', []):
|
||||||
if url['url'] in tweet_text:
|
if url['url'] in tweet_text:
|
||||||
|
|
Loading…
Add table
Reference in a new issue