Skip to content

Commit

Permalink
Artist display traceback fixed, s2yt_search added
Browse files Browse the repository at this point in the history
  • Loading branch information
linsomniac committed Jan 13, 2024
1 parent 3be8dd5 commit 299376e
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ For example:
Re-running "copy_playlist" or "load_liked" in the event that it fails should be safe, it
will not duplicate entries on the playlist.

## Searching for YTMusic Tracks

This is mostly for debugging, but there is a command to search for tracks in YTMusic:

`s2yt_search --artist <ARTIST> --album <ALBUM> <TRACK_NAME>`

## FAQ

- How does the lookup algorithm work?
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ s2yt_copy_playlist = "spotify2ytmusic.cli:copy_playlist"
s2yt_copy_all_playlists = "spotify2ytmusic.cli:copy_all_playlists"
s2yt_create_playlist = "spotify2ytmusic.cli:create_playlist"
s2yt_list_playlists = "spotify2ytmusic.cli:list_playlists"
s2yt_search = "spotify2ytmusic.cli:search"
34 changes: 33 additions & 1 deletion spotify2ytmusic/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,35 @@ def lookup_song(yt, track_name, artist_name, album_name):
raise ValueError(f"Did not find {track_name} by {artist_name} from {album_name}")


def search():
"""Search for a track on ytmusic"""

def parse_arguments():
parser = ArgumentParser()
parser.add_argument(
"track_name",
type=str,
help="Name of track to search for",
)
parser.add_argument(
"--artist",
type=str,
help="Artist to look up",
)
parser.add_argument(
"--album",
type=str,
help="Album name",
)
return parser.parse_args()

args = parse_arguments()

yt = get_ytmusic()
ret = lookup_song(yt, args.track_name, args.artist, args.album)
print(ret)


def load_liked():
"""
Load the "Liked Songs" playlist from Spotify into YTMusic.
Expand Down Expand Up @@ -301,8 +330,11 @@ def copier(
error_count += 1
continue

yt_artist_name = "<Unknown>"
if "artists" in dst_track and len(dst_track["artists"]) > 0:
yt_artist_name = dst_track["artists"][0]["name"]
print(
f" Youtube: {dst_track['title']} - {dst_track['artists'][0]['name']} - {dst_track['album']}"
f" Youtube: {dst_track['title']} - {yt_artist_name} - {dst_track['album']}"
)

if dst_track["videoId"] in tracks_added_set:
Expand Down

0 comments on commit 299376e

Please sign in to comment.