diff --git a/README.md b/README.md index db12a9f..e235393 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ > A music downloader that understands your metadata needs. -A tool to download your music with metadata. It uses [Spotify](https://www.spotify.com/) for finding metadata and [Youtube](https://www.youtube.com/) for the actual audio source. +A tool to download your music with metadata. It uses [Spotify](https://www.spotify.com/) for finding metadata and [Youtube](https://www.youtube.com/) for the actual audio source. You will need to have some Spotify tokens, the instructions to set them up are [here](https://github.com/kepoorhampond/irs#spotify-tokens). Works with Python 2 and 3. @@ -74,9 +74,11 @@ Other than `ffmpeg` though, all other dependencies are automatically installed w $ sudo pip install irs ``` -## Spotify Playlists +**You will need to have some Spotify tokens, the instructions to set them up are [here](https://github.com/kepoorhampond/irs#spotify-tokens).** -To download spotify playlists, you'll want to head to their Dev Apps page, [here](https://developer.spotify.com/my-applications/). After doing that you'll want to create a new app. Name it whatever you want and then once you've done that, find the `Client ID` and `Client Secret` keys. You'll want to take those keys and paste them into your system's environment variables as `SPOTIFY_CLIENT_ID` and `SPOTIFY_CLIENT_SECRET`, correspondingly. Viola! You can now download playlists! +## Spotify Tokens + +To download metadata through spotify, you'll want to head to their Dev Apps page, [here](https://developer.spotify.com/my-applications/). After doing that you'll want to create a new app. Name it whatever you want and then once you've done that, find the `Client ID` and `Client Secret` keys. You'll want to take those keys and paste them into your system's environment variables as `SPOTIFY_CLIENT_ID` and `SPOTIFY_CLIENT_SECRET`, correspondingly. Viola! You can now download metadata with IRS! ## Metadata diff --git a/irs/metadata.py b/irs/metadata.py index 6e9c599..a26fc5d 100644 --- a/irs/metadata.py +++ b/irs/metadata.py @@ -56,9 +56,9 @@ class Metadata: mp3.save() -def find_album_and_track(song, artist): - tracks = spotipy.Spotify().search(q=song, type="track" - )["tracks"]["items"] +def find_album_and_track(song, artist, spotify=spotipy.Spotify()): + tracks = spotify.search(q=song, type="track")["tracks"]["items"] + for track in tracks: if om.blank_include(track["name"], song): if om.blank_include(track["artists"][0]["name"], artist): diff --git a/irs/ripper.py b/irs/ripper.py index bf2f527..925c43f 100644 --- a/irs/ripper.py +++ b/irs/ripper.py @@ -324,7 +324,7 @@ with init, or in method arguments.") return locations def parse_song_data(self, song, artist): - album, track = find_album_and_track(song, artist) + album, track = find_album_and_track(song, artist, self.spotify) if album is False: return {} diff --git a/tests/song.py b/tests/song.py index ed0f18f..1950ba3 100644 --- a/tests/song.py +++ b/tests/song.py @@ -1,9 +1,5 @@ -# from irs.ripper import Ripper +from irs.ripper import Ripper -# print ("[*] Testing `song.py`") - -print("Currently spotify has made it required for you to have a token to \ -search through songs, so I'm skipping testing this file for Travic CI.") - -# Ripper().song("Da Frame 2R", "Arctic Monkeys") -# print ("[+] Passed!") +print ("[*] Testing `song.py`") +Ripper().song("Da Frame 2R", "Arctic Monkeys") +print ("[+] Passed!")