Skip to content

Commit

Permalink
Revert "Added support for downloading artist songs. (#904)"
Browse files Browse the repository at this point in the history
This reverts commit 095c260.
  • Loading branch information
Michael George authored Oct 25, 2020
1 parent 095c260 commit a40fa19
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 73 deletions.
19 changes: 7 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
⚠ We are dropping active development of spotDL v2. No focused efforts will be made to resolve v2
specific issues.

⚠ We are actively looking for Contributors/Organization Members for all projects under development.
⚠ We are actively looking for Contributors/Organization Members for all projects under development.
If interested, see [#857](https://github.com/spotDL/spotify-downloader/issues/857)

⚠ There are a few feature requests we'd like the community to vote on. Do voice your support for features you'd like.
Expand Down Expand Up @@ -47,7 +47,7 @@ you use spotDL v3 and open issues for problems that you come across.
```
$pip install https://github.com/spotDL/spotify-downloader/archive/master.zip
```
3. Voila !
# How to use (instructions for v3)
Expand All @@ -57,27 +57,22 @@ To download a song run,
spotdl https://open.spotify.com/track/08mG3Y1vljYA6bvDt4Wqkj?si=SxezdxmlTx-CaVoucHmrUA
To download an album run,
# spotdl $albumUrl
spotdl https://open.spotify.com/album/2YMWspDGtbDgYULXvVQFM6?si=gF5dOQm8QUSo-NdZVsFjAQ
To download a playlist run,
# spotdl $playlistUrl
spotdl https://open.spotify.com/playlist/37i9dQZF1DWXhcuQw7KIeM?si=xubKHEBESM27RqGkqoXzgQ
To download an artist's songs run,
# spotdl $artistUrl
spotdl https://open.spotify.com/artist/6fOMl44jA4Sp5b9PpYCkzz
To search for and download a song (not very accurate) run,
# spotdl $songQuery
spotdl 'The HU - Sugaan Essenna'
To resume a failed/incomplete download run,
- ```
# spotdl $pathToTrackingFile
spotdl 'Sugaan Essenna.spotdlTrackingFile'
Expand All @@ -87,7 +82,7 @@ To resume a failed/incomplete download run,
download completion
You can chain up download tasks by seperating them with spaces:
# spotdl $songQuery1 $albumUrl $songQuery2 ... (order does not matter)
spotdl 'The Hu - Sugaan Essenna' https://open.spotify.com/playlist/37i9dQZF1DWXhcuQw7KIeM?si=xubKHEBESM27RqGkqoXzgQ ...
Expand Down
16 changes: 3 additions & 13 deletions spotdl/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from sys import argv as cliArgs

#! Song Search from different start points
from spotdl.search.utils import get_playlist_tracks, get_album_tracks, search_for_song, get_artist_tracks
from spotdl.search.utils import get_playlist_tracks, get_album_tracks, search_for_song
from spotdl.search.songObj import SongObj

#! The actual download stuff
Expand All @@ -30,10 +30,6 @@
spotdl $playlistUrl
eg. spotdl https://open.spotify.com/playlist/37i9dQZF1DWXhcuQw7KIeM?si=xubKHEBESM27RqGkqoXzgQ
To download an artist's songs run,
spotdl $artistUrl
eg. spotdl https://open.spotify.com/artist/6fOMl44jA4Sp5b9PpYCkzz
To search for and download a song (not very accurate) run,
spotdl $songQuery
eg. spotdl 'The HU - Sugaan Essenna'
Expand Down Expand Up @@ -90,25 +86,19 @@ def console_entry_point():
print('Skipping %s (%s) as no match could be found on youtube' % (
song.get_song_name(), request
))

elif ('open.spotify.com' in request and 'album' in request) or 'spotify:album:' in request:
print('Fetching Album...')
songObjList = get_album_tracks(request)

downloader.download_multiple_songs(songObjList)

elif ('open.spotify.com' in request and 'playlist' in request) or 'spotify:playlist:' in request:
print('Fetching Playlist...')
songObjList = get_playlist_tracks(request)

downloader.download_multiple_songs(songObjList)

elif ('open.spotify.com' in request and 'artist' in request) or 'spotify:artist:' in request:
print('Fetching Artist\'s Tracks...')
songObjList = get_artist_tracks(request)

downloader.download_multiple_songs(songObjList)

elif request.endswith('.txt'):
print('Fetching songs from %s...' % request)
songObjList = []
Expand Down
58 changes: 10 additions & 48 deletions spotdl/search/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ def search_for_song(query: str) -> SongObj:
for songResult in result['tracks']['items']:
songUrl = 'http://open.spotify.com/track/' + songResult['id']
song = SongObj.from_url(songUrl)

if song.get_youtube_link() != None:
return song

raise Exception('Could not match any of the results on YouTube')

def get_album_tracks(albumUrl: str) -> List[SongObj]:
'''
`str` `albumUrl` : Spotify Url of the album whose tracks are to be
Expand All @@ -47,10 +47,10 @@ def get_album_tracks(albumUrl: str) -> List[SongObj]:

for track in trackResponse['items']:
song = SongObj.from_url('https://open.spotify.com/track/' + track['id'])

if song.get_youtube_link() != None:
albumTracks.append(song)

# check if more tracks are to be passed
if trackResponse['next']:
trackResponse = spotifyClient.album_tracks(
Expand All @@ -59,7 +59,7 @@ def get_album_tracks(albumUrl: str) -> List[SongObj]:
)
else:
break

return albumTracks

def get_playlist_tracks(playlistUrl: str) -> List[SongObj]:
Expand All @@ -81,55 +81,17 @@ def get_playlist_tracks(playlistUrl: str) -> List[SongObj]:
for songEntry in playlistResponse['items']:
song = SongObj.from_url(
'https://open.spotify.com/track/' + songEntry['track']['id'])

if song.get_youtube_link() != None:
playlistTracks.append(song)

# check if more tracks are to be passed
# check if more tracks are to be passed
if playlistResponse['next']:
playlistResponse = spotifyClient.playlist_tracks(
playlistUrl,
offset = len(playlistTracks)
)
else:
break

return playlistTracks


def get_artist_tracks(artistUrl: str) -> List[SongObj]:
'''
`str` `artistUrl` : Spotify Url of the artist whose tracks are to be
retrieved
returns a `List` containing Url's of each track of the artist.
'''

spotifyClient = get_spotify_client()
artistAlbums = []
artistTracks = []

artistResponse = spotifyClient.artist_albums(artistUrl)

while True:

for album in artistResponse['items']:
albumUrl = album['external_urls']['spotify']

artistAlbums.append(albumUrl)

# Check if the artist has more albums.
if artistResponse['next']:
artistResponse = spotifyClient.artist_albums(
artistUrl,
offset = len(artistAlbums)
)
else:
break

for album in artistAlbums:
albumTracks = get_album_tracks(album)

artistTracks += albumTracks

return artistTracks

return playlistTracks

0 comments on commit a40fa19

Please sign in to comment.