Browse Source

don't kill entire upload operation on playlist error

Tom Lee 9 years ago
parent
commit
f1cd4e4d0f
1 changed files with 11 additions and 12 deletions
  1. 11 12
      youtube_upload/main.py

+ 11 - 12
youtube_upload/main.py

@@ -185,19 +185,18 @@ def run_main(parser, options, args, output=sys.stdout):
                 # something has gone wrong
                 if existing_playlist_id is None:
                     debug('Error creating playlist')
-                    sys.exit(1)
-
-                # add video to playlist
-                youtube.playlistItems().insert(part='snippet', body={
-                    "snippet": {
-                        "playlistId": existing_playlist_id,
-                        "resourceId": {
-                            "kind": "youtube#video",
-                            "videoId": video_id
+                else:
+                    # add video to playlist
+                    youtube.playlistItems().insert(part='snippet', body={
+                        "snippet": {
+                            "playlistId": existing_playlist_id,
+                            "resourceId": {
+                                "kind": "youtube#video",
+                                "videoId": video_id
+                            }
                         }
-                    }
-                }).execute()
-                debug("Added video to playlist '{0}'".format(options.playlist))
+                    }).execute()
+                    debug("Added video to playlist '{0}'".format(options.playlist))
 
             debug("Video URL: {0}".format(video_url))
             output.write(video_id + "\n")