From fbc28562a5514455e4baad70932e1f18c7b6a737 Mon Sep 17 00:00:00 2001 From: Georg Krause Date: Thu, 23 Apr 2020 17:47:27 +0200 Subject: [PATCH] Catch crash when trying to upload a not available video file (#18) This happens for example when a Live Stream is scheduled on a YT-Channel. In this case the download of the video file is not possible and therefore the attempt to upload leads to a crash. --- youtube2peertube.py | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/youtube2peertube.py b/youtube2peertube.py index e478b46..2b3d698 100644 --- a/youtube2peertube.py +++ b/youtube2peertube.py @@ -166,22 +166,25 @@ def upload_to_pt(dl_dir, channel_conf, queue_item, access_token, thumb_extension # MultipartEncoder does not support list refer # https://github.com/requests/toolbelt/issues/190 and # https://github.com/requests/toolbelt/issues/205 - fields = [ - ("name", queue_item["title"]), - ("licence", "1"), - ("description", description), - ("nsfw", channel_conf["nsfw"]), - ("channelId", channel_id), - ("originallyPublishedAt", queue_item["published"]), - ("category", channel_conf["pt_channel_category"]), - ("language", channel_conf["default_lang"]), - ("privacy", str(channel_conf["pt_privacy"])), - ("commentsEnabled", channel_conf["comments_enabled"]), - ("videofile", get_file(video_file)), - ("thumbnailfile", get_file(thumb_file)), - ("previewfile", get_file(thumb_file)), - ("waitTranscoding", 'false') - ] + try: + fields = [ + ("name", queue_item["title"]), + ("licence", "1"), + ("description", description), + ("nsfw", channel_conf["nsfw"]), + ("channelId", channel_id), + ("originallyPublishedAt", queue_item["published"]), + ("category", channel_conf["pt_channel_category"]), + ("language", channel_conf["default_lang"]), + ("privacy", str(channel_conf["pt_privacy"])), + ("commentsEnabled", channel_conf["comments_enabled"]), + ("videofile", get_file(video_file)), + ("thumbnailfile", get_file(thumb_file)), + ("previewfile", get_file(thumb_file)), + ("waitTranscoding", 'false') + ] + except: + return if channel_conf["pt_tags"] != "": fields.append(("tags", "[" + channel_conf["pt_tags"] + "]"))