Skip to content

Commit

Permalink
Readded playlist to like action from guglielmobartelloni:playlist-to-…
Browse files Browse the repository at this point in the history
…like (sigma67#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 <[email protected]>

* Update spotify_to_ytmusic/controllers.py

Remove debug print

Co-authored-by: sigma67 <[email protected]>

---------

Co-authored-by: sigma67 <[email protected]>
  • Loading branch information
Tim-Odermatt and sigma67 authored Jun 18, 2024
1 parent 6ff686d commit 67572be
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
6 changes: 6 additions & 0 deletions spotify_to_ytmusic/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)}")
Expand All @@ -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
Expand Down
12 changes: 12 additions & 0 deletions spotify_to_ytmusic/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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)

Expand Down
3 changes: 3 additions & 0 deletions spotify_to_ytmusic/ytmusic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 67572be

Please sign in to comment.