@@ -370,7 +370,7 @@ def sort_playlist(ctx: click.Context, shuffle, playlist_titles):
370
370
]
371
371
for selected_playlist in selected_playlist_list :
372
372
logging .info (f'Processing playlist: { selected_playlist ["title" ]} ' )
373
- playlist = yt_auth .get_playlist (selected_playlist ["playlistId" ], sys . maxsize )
373
+ playlist = yt_auth .get_playlist (selected_playlist ["playlistId" ], limit = None )
374
374
if not can_edit_playlist (playlist ):
375
375
logging .error (f"Cannot modify playlist { playlist .get ('title' )!r} . You are not the owner of this playlist." )
376
376
continue
@@ -395,11 +395,21 @@ def sort_playlist(ctx: click.Context, shuffle, playlist_titles):
395
395
396
396
cur_artist = cur_track ["artists" ][0 ]["name" ] if cur_track ["artists" ] else UNKNOWN_ARTIST
397
397
track_after_artist = track_after ["artists" ][0 ]["name" ] if track_after ["artists" ] else UNKNOWN_ARTIST
398
- logging .debug (
399
- f"Moving { cur_artist } - { cur_track ['title' ]!r} before { track_after_artist } - { track_after ['title' ]!r} "
400
- )
401
398
if cur_track != track_after :
399
+ logging .debug (
400
+ f"Moving { cur_artist } - { cur_track ['title' ]!r} before { track_after_artist } - { track_after ['title' ]!r} "
401
+ )
402
402
try :
403
+ if "setVideoId" not in cur_track or "setVideoId" not in track_after :
404
+ logging .error (
405
+ "Encountered track(s) with missing 'setVideoId'. Cannot sort the following track(s):"
406
+ )
407
+ if "setVideoId" not in cur_track :
408
+ logging .error (f"setVideoId attribute not in cur_track: { cur_track } " )
409
+ if "setVideoId" not in track_after :
410
+ logging .error (f"setVideoId attribute not in track_after: { track_after } " )
411
+ continue
412
+
403
413
response = yt_auth .edit_playlist (
404
414
playlist ["id" ],
405
415
moveItem = (
0 commit comments