Skip to content

Commit

Permalink
Merge pull request #1232 from spotDL/dev
Browse files Browse the repository at this point in the history
* Fix MikhailZex GitHub's link (#1215)
Authored by @jcs090218 

* Use the proper name for beautifulsoup4 (#1210)
Authored by @timschumi

* Refactor spotify client (#1188)
Authored by @aklajnert  

* Switch to rich (#1098)
Authored by @phcreery 

* Bump version number to 3.5.0

Co-authored-by: Jen-Chieh Shen <jcs090218@gmail.com>
Co-authored-by: Tim Schumacher <timschumi@gmx.de>
Co-authored-by: Andrzej Klajnert <github@aklajnert.pl>
Co-authored-by: Peyton Creery <44987569+phcreery@users.noreply.github.com>
Co-authored-by: Michael George <MikhailZex@gmail.com>
Co-authored-by: Jakub <42355410+xnetcat@users.noreply.github.com>
  • Loading branch information
7 people authored Mar 26, 2021
2 parents 5dfe080 + f614191 commit 1634a5f
Show file tree
Hide file tree
Showing 18 changed files with 56,602 additions and 74,018 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,3 @@ dist

# Jetbrains IDEs; PyCharm/IntelliJ
.idea

# tox
.tox
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,4 +177,4 @@ pipx run spotdl ...
1. [@ritiek](https://github.com/ritiek) for creating and maintaining spotDL for 4 years
2. [@rocketinventor](https://github.com/rocketinventor) for figuring out YouTube Music querying
3. [@Mikhail-Zex](https://github.com/Mikhail-Zex) for, never mind...
3. [@MikhailZex](https://github.com/MikhailZex) for, never mind...
6 changes: 3 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[metadata]
version = 3.4.2
version = 3.5.0

name = spotdl
url = https://github.com/spotDL/spotify-downloader
Expand Down Expand Up @@ -35,7 +35,7 @@ install_requires =
mutagen
ytmusicapi
tqdm
bs4
beautifulsoup4
requests
python_requires = >=3.6
packages = find:
Expand All @@ -61,4 +61,4 @@ ignore_missing_imports = True

[flake8]
max-line-length = 100
ignore = E301
ignore = E301,W605
77 changes: 37 additions & 40 deletions spotdl/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

# ! The actual download stuff
from spotdl.download.downloader import DownloadManager
from spotdl.search import spotifyClient
from spotdl.search.songObj import SongObj
from spotdl.search.spotifyClient import SpotifyClient
# ! Song Search from different start points
from spotdl.search.utils import (
get_playlist_tracks,
Expand Down Expand Up @@ -90,9 +90,9 @@ def console_entry_point():
'''
arguments = parse_arguments()

spotifyClient.initialize(
clientId='4fe3fecfe5334023a1472516cc99d805',
clientSecret='0f02b7c483c04257984695007a4a8d5c'
SpotifyClient.init(
client_id='4fe3fecfe5334023a1472516cc99d805',
client_secret='0f02b7c483c04257984695007a4a8d5c'
)

if arguments.path:
Expand All @@ -101,52 +101,49 @@ def console_entry_point():
print(f"Will download to: {os.path.abspath(arguments.path)}")
os.chdir(arguments.path)

downloader = DownloadManager()
with DownloadManager() as downloader:

for request in arguments.url:
if 'open.spotify.com' in request and 'track' in request:
print('Fetching Song...')
song = SongObj.from_url(request)
for request in arguments.url:
if 'open.spotify.com' in request and 'track' in request:
print('Fetching Song...')
song = SongObj.from_url(request)

if song.get_youtube_link() is not None:
downloader.download_single_song(song)
else:
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:
print('Fetching Album...')
songObjList = get_album_tracks(request)
if song.get_youtube_link() is not None:
downloader.download_single_song(song)
else:
print('Skipping %s (%s) as no match could be found on youtube' % (
song.get_song_name(), request
))

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

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

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

elif 'open.spotify.com' in request and 'artist' in request:
print('Fetching artist...')
artistObjList = get_artist_tracks(request)
downloader.download_multiple_songs(songObjList)

downloader.download_multiple_songs(artistObjList)
elif 'open.spotify.com' in request and 'artist' in request:
print('Fetching artist...')
artistObjList = get_artist_tracks(request)

elif request.endswith('.spotdlTrackingFile'):
print('Preparing to resume download...')
downloader.resume_download_from_tracking_file(request)
downloader.download_multiple_songs(artistObjList)

else:
print('Searching for song "%s"...' % request)
try:
song = search_for_song(request)
downloader.download_single_song(song)
elif request.endswith('.spotdlTrackingFile'):
print('Preparing to resume download...')
downloader.resume_download_from_tracking_file(request)

except Exception:
print('No song named "%s" could be found on spotify' % request)

downloader.close()
else:
print('Searching for song "%s"...' % request)
try:
song = search_for_song(request)
downloader.download_single_song(song)
except Exception as e:
print(e)


def parse_arguments():
Expand Down
Loading

0 comments on commit 1634a5f

Please sign in to comment.