diff --git a/README.rst b/README.rst index 149f7f1..f5e4f3b 100644 --- a/README.rst +++ b/README.rst @@ -27,8 +27,10 @@ spotify_to_ytmusic A simple command line script to clone a Spotify playlist to YouTube Music. - Transfer a single Spotify playlist +- Like all the songs in a Spotify playlist - Update a transferred playlist on YouTube Music - Transfer all playlists for a Spotify user +- Like all songs from all playlists for a Spotify user - Remove playlists from YouTube Music diff --git a/spotify_to_ytmusic/controllers.py b/spotify_to_ytmusic/controllers.py index 24856ee..d9d686f 100644 --- a/spotify_to_ytmusic/controllers.py +++ b/spotify_to_ytmusic/controllers.py @@ -46,6 +46,9 @@ def all(args): "PUBLIC" if p["public"] else "PRIVATE", videoIds, ) + if args.like: + for id in videoIds: + ytmusic.rate_song(id, "LIKE") _print_success(p["name"], playlist_id) except Exception as ex: print(f"Could not transfer playlist {p['name']}. {str(ex)}") @@ -58,6 +61,9 @@ def _create_ytmusic(args, playlist, ytmusic): name = args.name + date if args.name else playlist["name"] + date info = playlist["description"] if (args.info is None) else args.info videoIds = ytmusic.search_songs(playlist["tracks"]) + if args.like: + for id in videoIds: + ytmusic.rate_song(id, "LIKE") playlistId = ytmusic.create_playlist( name, info, "PUBLIC" if args.public else "PRIVATE", videoIds diff --git a/spotify_to_ytmusic/main.py b/spotify_to_ytmusic/main.py index 73eb8a8..b5a8dd3 100644 --- a/spotify_to_ytmusic/main.py +++ b/spotify_to_ytmusic/main.py @@ -40,6 +40,12 @@ def get_args(args=None): action="store_true", help="Make created playlist public. Default: private", ) + spotify_playlist_create.add_argument( + "-l", + "--like", + action="store_true", + help="Like the songs in the specified playlist", + ) create_parser = subparsers.add_parser( "create", @@ -77,6 +83,12 @@ def get_args(args=None): ) all_parser.add_argument("user", type=str, help="Spotify userid of the specified user.") all_parser.set_defaults(func=controllers.all) + all_parser.add_argument( + "-l", + "--like", + action="store_true", + help="Like the songs in all of the public playlist", + ) return parser.parse_args(args) diff --git a/spotify_to_ytmusic/ytmusic.py b/spotify_to_ytmusic/ytmusic.py index a8ba645..906c78e 100644 --- a/spotify_to_ytmusic/ytmusic.py +++ b/spotify_to_ytmusic/ytmusic.py @@ -20,6 +20,9 @@ def __init__(self): def create_playlist(self, name, info, privacy="PRIVATE", tracks=None): return self.api.create_playlist(name, info, privacy, video_ids=tracks) + def rate_song(self, id, rating): + return self.api.rate_song(id, rating) + def search_songs(self, tracks): videoIds = [] songs = list(tracks)