Show gifv as mp4 video's
This commit is contained in:
parent
e0744d3a68
commit
0579d6f61b
1 changed files with 12 additions and 0 deletions
|
|
@ -43,6 +43,7 @@ RATE_LIMIT = 60
|
||||||
RATE_LIMIT_DURATION = timedelta(seconds=60)
|
RATE_LIMIT_DURATION = timedelta(seconds=60)
|
||||||
|
|
||||||
REDDIT_IMAGE_EXTENSIONS = (".jpg", ".png", ".gif")
|
REDDIT_IMAGE_EXTENSIONS = (".jpg", ".png", ".gif")
|
||||||
|
REDDIT_VIDEO_EXTENSIONS = (".mp4", ".gifv", ".webm")
|
||||||
|
|
||||||
|
|
||||||
def get_reddit_authorization_url(user):
|
def get_reddit_authorization_url(user):
|
||||||
|
|
@ -149,6 +150,17 @@ class RedditBuilder(Builder):
|
||||||
video_info = post["data"]["secure_media"]["reddit_video"]
|
video_info = post["data"]["secure_media"]["reddit_video"]
|
||||||
|
|
||||||
body = f"<div><video controls muted><source src='{video_info['fallback_url']}' type='video/mp4' /></video></div>"
|
body = f"<div><video controls muted><source src='{video_info['fallback_url']}' type='video/mp4' /></video></div>"
|
||||||
|
elif not is_text_post and direct_url.endswith(REDDIT_VIDEO_EXTENSIONS):
|
||||||
|
extension = next(
|
||||||
|
extension.replace(".", "")
|
||||||
|
for extension in REDDIT_VIDEO_EXTENSIONS
|
||||||
|
if direct_url.endswith(extension)
|
||||||
|
)
|
||||||
|
|
||||||
|
if extension == "gifv":
|
||||||
|
body = f"<div><video controls muted><source src='{direct_url.replace(extension, 'mp4')}' type='video/mp4' /></video></div>"
|
||||||
|
else:
|
||||||
|
body = f"<div><video controls muted><source src='{direct_url}' type='video/{extension}' /></video></div>"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
parsed_date = datetime.fromtimestamp(post["data"]["created_utc"])
|
parsed_date = datetime.fromtimestamp(post["data"]["created_utc"])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue