diff --git a/tumblr_backup.py b/tumblr_backup.py index 6e3ee95..2fd0df7 100755 --- a/tumblr_backup.py +++ b/tumblr_backup.py @@ -756,13 +756,21 @@ def append_try(elt, fmt=u'%s'): src, "Your browser does not support the video element.", src, "Video file" )) else: - append(post['player'][-1]['embed_code']) + player = get_try('player') + if player: + append(player[-1]['embed_code']) + else: + append_try('video_url') append_try('caption') elif self.typ == 'audio': - src = '' + def make_player(src_): + append(u'
' + % (src_, "Your browser does not support the audio element.", src_, "Audio file")) + + src = None + audio_url = get_try('audio_url') or get_try('audio_source_url') if options.save_audio: - audio_url = get_try('audio_url') or get_try('audio_source_url') if post['audio_type'] == 'tumblr': if audio_url.startswith('https://a.tumblr.com/'): src = self.get_media_url(audio_url, '.mp3') @@ -771,12 +779,13 @@ def append_try(elt, fmt=u'%s'): src = self.get_media_url(audio_url, '.mp3') elif post['audio_type'] == 'soundcloud': src = self.get_media_url(audio_url, '.mp3') + player = get_try('player') if src: - append(u'' % ( - src, "Your browser does not support the audio element.", src, "Audio file" - )) - else: - append(post['player']) + make_player(src) + elif player: + append(player) + elif audio_url: + make_player(audio_url) append_try('caption') elif self.typ == 'answer':