Clean duplicates from playlist
This commit is contained in:
parent
b00e309aa0
commit
f33297382e
16
main.py
16
main.py
@ -221,6 +221,11 @@ def main():
|
||||
parser_move.add_argument('-l', '--limit', type=int, default=-1,
|
||||
help='Limit number of videos to process')
|
||||
|
||||
parser_dups = subparsers.add_parser('dups', help='Remove duplicate videos in a playlist')
|
||||
parser_dups.add_argument('playlist', help='Playlist name/ID')
|
||||
parser_dups.add_argument('-l', '--limit', type=int, default=-1,
|
||||
help='Limit number of videos to process')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
# Disable OAuthlib's HTTPS verification when running locally.
|
||||
@ -262,6 +267,17 @@ def main():
|
||||
continue
|
||||
add_video_to_playlist(youtube, video, playlist, args.dry_run)
|
||||
|
||||
elif args.command == 'dups':
|
||||
playlist = get_playlist_id(args.playlist)
|
||||
videos = list_playlist(youtube, playlist)
|
||||
video_map = {}
|
||||
for video in videos[:args.limit]:
|
||||
video_id = video['snippet']['resourceId']['videoId']
|
||||
if video_id in video_map:
|
||||
remove_video_from_playlist(youtube, video, playlist, args.dry_run)
|
||||
else:
|
||||
video_map[video_id] = video
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
|
||||
Loading…
Reference in New Issue
Block a user