Skip to content

Commit 67572be

Browse files
Readded playlist to like action from guglielmobartelloni:playlist-to-like (#102)
* Update controllers.py Added guglielmobartelloni:playlist-to-like to the newer version of spotify_to_ytmusic * Update main.py Added guglielmobartelloni:playlist-to-like to the newer version of spotify_to_ytmusic * Update ytmusic.py Added guglielmobartelloni:playlist-to-like to the newer version of spotify_to_ytmusic * Update controllers.py Added guglielmobartelloni:playlist-to-like to the newer version of spotify_to_ytmusic for the all argument * Update main.py Added guglielmobartelloni:playlist-to-like to the newer version of spotify_to_ytmusic for the all argument * Update README.rst Added guglielmobartelloni:playlist-to-like to the newer version of spotify_to_ytmusic * Update spotify_to_ytmusic/controllers.py Remove debug print Co-authored-by: sigma67 <16363825+sigma67@users.noreply.github.com> * Update spotify_to_ytmusic/controllers.py Remove debug print Co-authored-by: sigma67 <16363825+sigma67@users.noreply.github.com> --------- Co-authored-by: sigma67 <16363825+sigma67@users.noreply.github.com>
1 parent 6ff686d commit 67572be

File tree

4 files changed

+23
-0
lines changed

4 files changed

+23
-0
lines changed

README.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ spotify_to_ytmusic
2727
A simple command line script to clone a Spotify playlist to YouTube Music.
2828

2929
- Transfer a single Spotify playlist
30+
- Like all the songs in a Spotify playlist
3031
- Update a transferred playlist on YouTube Music
3132
- Transfer all playlists for a Spotify user
33+
- Like all songs from all playlists for a Spotify user
3234
- Remove playlists from YouTube Music
3335

3436

spotify_to_ytmusic/controllers.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ def all(args):
4646
"PUBLIC" if p["public"] else "PRIVATE",
4747
videoIds,
4848
)
49+
if args.like:
50+
for id in videoIds:
51+
ytmusic.rate_song(id, "LIKE")
4952
_print_success(p["name"], playlist_id)
5053
except Exception as ex:
5154
print(f"Could not transfer playlist {p['name']}. {str(ex)}")
@@ -58,6 +61,9 @@ def _create_ytmusic(args, playlist, ytmusic):
5861
name = args.name + date if args.name else playlist["name"] + date
5962
info = playlist["description"] if (args.info is None) else args.info
6063
videoIds = ytmusic.search_songs(playlist["tracks"])
64+
if args.like:
65+
for id in videoIds:
66+
ytmusic.rate_song(id, "LIKE")
6167

6268
playlistId = ytmusic.create_playlist(
6369
name, info, "PUBLIC" if args.public else "PRIVATE", videoIds

spotify_to_ytmusic/main.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ def get_args(args=None):
4040
action="store_true",
4141
help="Make created playlist public. Default: private",
4242
)
43+
spotify_playlist_create.add_argument(
44+
"-l",
45+
"--like",
46+
action="store_true",
47+
help="Like the songs in the specified playlist",
48+
)
4349

4450
create_parser = subparsers.add_parser(
4551
"create",
@@ -77,6 +83,12 @@ def get_args(args=None):
7783
)
7884
all_parser.add_argument("user", type=str, help="Spotify userid of the specified user.")
7985
all_parser.set_defaults(func=controllers.all)
86+
all_parser.add_argument(
87+
"-l",
88+
"--like",
89+
action="store_true",
90+
help="Like the songs in all of the public playlist",
91+
)
8092

8193
return parser.parse_args(args)
8294

spotify_to_ytmusic/ytmusic.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ def __init__(self):
2020
def create_playlist(self, name, info, privacy="PRIVATE", tracks=None):
2121
return self.api.create_playlist(name, info, privacy, video_ids=tracks)
2222

23+
def rate_song(self, id, rating):
24+
return self.api.rate_song(id, rating)
25+
2326
def search_songs(self, tracks):
2427
videoIds = []
2528
songs = list(tracks)

0 commit comments

Comments
 (0)