1
0
Fork 0
forked from github/pelican

Deal with broken embedded video links when importing from Tumblr (#3218)

Co-authored-by: boxydog <boxydog@users.noreply.github.com>
Co-authored-by: Will Thong <will@willthong.com>
This commit is contained in:
boxydog 2023-10-28 05:56:00 -05:00 committed by GitHub
commit 9c87d8f3a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 120 additions and 2 deletions

View file

@ -459,8 +459,16 @@ def tumblr2fields(api_key, blogname):
fmtstr = '<p><a href="%s">via</a></p>\n'
source = fmtstr % post.get('source_url')
caption = post.get('caption')
players = '\n'.join(player.get('embed_code')
for player in post.get('player'))
players = [
# If embed_code is False, couldn't get the video
player.get('embed_code') or None
for player in post.get('player')]
# If there are no embeddable players, say so, once
if len(players) > 0 and all(
player is None for player in players):
players = "<p>(This video isn't available anymore.)</p>\n"
else:
players = '\n'.join(players)
content = source + caption + players
elif type == 'answer':
title = post.get('question')