Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev to Master #1171

Merged
merged 10 commits into from
Feb 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/spotify-downloader-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,54 @@ jobs:
tox
env:
PLATFORM: ${{ matrix.platform }}

mypy:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install tox
- name: Run mypy
run: |
tox -e mypy

flake8:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install tox
- name: Run flake8
run: |
tox -e flake8

regressions:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
sudo add-apt-repository ppa:jonathonf/ffmpeg-4 -y
sudo apt-get update
sudo apt install ffmpeg -y
python -m pip install -e .[test]
- name: Run tests
run: |
pytest tests/regressions.py
10 changes: 7 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[metadata]
version = 3.3.1
version = 3.3.2

name = spotdl
url = https://github.com/spotDL/spotify-downloader
Expand Down Expand Up @@ -39,14 +39,16 @@ python_requires = >=3.6
packages = find:

[options.extras_require]
test =
test =
pytest >= 6.0
pytest-mock >= 3.3.1
pytest-vcr >= 1.0.2
pyfakefs >= 4.3.0
pytest-cov >= 2.10.1
dev =
dev =
tox
mypy==0.790
flake8==3.8.4

[options.entry_points]
console_scripts=
Expand All @@ -55,3 +57,5 @@ console_scripts=
[mypy]
ignore_missing_imports = True

[flake8]
max-line-length = 100
1 change: 1 addition & 0 deletions spotdl/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from .__main__ import console_entry_point

__all__ = [
'console_entry_point',
'search',
'download',
]
107 changes: 61 additions & 46 deletions spotdl/__main__.py
Original file line number Diff line number Diff line change
@@ -1,42 +1,47 @@
#! Basic necessities to get the CLI running
from spotdl.search import spotifyClient
import sys

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

#! The actual download stuff
# ! The actual download stuff
from spotdl.download.downloader import DownloadManager
from spotdl.search import spotifyClient
from spotdl.search.songObj import SongObj
# ! Song Search from different start points
from spotdl.search.utils import get_playlist_tracks, get_album_tracks, search_for_song


#! Usage is simple - call 'python __main__.py <links, search terms, tracking files seperated by spaces>
#! Eg.
#! python __main__.py https://open.spotify.com/playlist/37i9dQZF1DWXhcuQw7KIeM?si=xubKHEBESM27RqGkqoXzgQ 'old gods of asgard Control' https://open.spotify.com/album/2YMWspDGtbDgYULXvVQFM6?si=gF5dOQm8QUSo-NdZVsFjAQ https://open.spotify.com/track/08mG3Y1vljYA6bvDt4Wqkj?si=SxezdxmlTx-CaVoucHmrUA
#!
#! Well, yeah its a pretty long example but, in theory, it should work like a charm.
#!
#! A '.spotdlTrackingFile' is automatically created with the name of the first song in the playlist/album or
#! the name of the song supplied. We don't really re re re-query YTM and SPotify as all relevant details are
#! stored to disk.
#!
#! Files are cleaned up on download failure.
#!
#! All songs are normalized to standard base volume. the soft ones are made louder, the loud ones, softer.
#!
#! The progress bar is synched across multiple-processes (4 processes as of now), getting the progress bar to
#! synch was an absolute pain, each process knows how much 'it' progressed, but the display has to be for the
#! overall progress so, yeah... that took time.
#!
#! spotdl will show you its true speed on longer download's - so make sure you try downloading a playlist.
#!
#! still yet to try and package this but, in theory, there should be no errors.
#!
#! - cheerio! (Michael)
#!
#! P.S. Tell me what you think. Up to your expectations?

#! Script Help
# ! Usage is simple - call:
# 'python __main__.py <links, search terms, tracking files separated by spaces>
# ! Eg.
# ! python __main__.py
# ! https://open.spotify.com/playlist/37i9dQZF1DWXhcuQw7KIeM?si=xubKHEBESM27RqGkqoXzgQ
# ! 'old gods of asgard Control'
# ! https://open.spotify.com/album/2YMWspDGtbDgYULXvVQFM6?si=gF5dOQm8QUSo-NdZVsFjAQ
# ! https://open.spotify.com/track/08mG3Y1vljYA6bvDt4Wqkj?si=SxezdxmlTx-CaVoucHmrUA
# !
# ! Well, yeah its a pretty long example but, in theory, it should work like a charm.
# !
# ! A '.spotdlTrackingFile' is automatically created with the name of the first song in the
# ! playlist/album or the name of the song supplied. We don't really re re re-query YTM and Spotify
# ! as all relevant details are stored to disk.
# !
# ! Files are cleaned up on download failure.
# !
# ! All songs are normalized to standard base volume. the soft ones are made louder,
# ! the loud ones, softer.
# !
# ! The progress bar is synched across multiple-processes (4 processes as of now), getting the
# ! progress bar to synch was an absolute pain, each process knows how much 'it' progressed,
# ! but the display has to be for the overall progress so, yeah... that took time.
# !
# ! spotdl will show you its true speed on longer download's - so make sure you try
# ! downloading a playlist.
# !
# ! still yet to try and package this but, in theory, there should be no errors.
# !
# ! - cheerio! (Michael)
# !
# ! P.S. Tell me what you think. Up to your expectations?

# ! Script Help
help_notice = '''
To download a song run,
spotdl [trackUrl]
Expand All @@ -63,36 +68,34 @@

You can queue up multiple download tasks by separating the arguments with spaces:
spotdl [songQuery1] [albumUrl] [songQuery2] ... (order does not matter)
ex. spotdl 'The Weeknd - Blinding Lights' https://open.spotify.com/playlist/37i9dQZF1E8UXBoz02kGID?si=oGd5ctlyQ0qblj_bL6WWow ...
ex. spotdl 'The Weeknd - Blinding Lights'
https://open.spotify.com/playlist/37i9dQZF1E8UXBoz02kGID?si=oGd5ctlyQ0qblj_bL6WWow ...

spotDL downloads up to 4 songs in parallel, so for a faster experience, download albums and playlist, rather than tracks.
spotDL downloads up to 4 songs in parallel, so for a faster experience,
download albums and playlist, rather than tracks.
'''


def console_entry_point():
'''
This is where all the console processing magic happens.
Its super simple, rudimentary even but, it's dead simple & it works.
'''

if '--help' in sys.argv or '-H' in sys.argv or '-h' in sys.argv or len(sys.argv) == 1:
print(help_notice)

#! We use 'return None' as a convenient exit/break from the function
return None
arguments = parse_arguments()

spotifyClient.initialize(
clientId='4fe3fecfe5334023a1472516cc99d805',
clientSecret='0f02b7c483c04257984695007a4a8d5c'
)
)

downloader = DownloadManager()

for request in sys.argv[1:]:
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() != None:
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' % (
Expand Down Expand Up @@ -126,5 +129,17 @@ def console_entry_point():

downloader.close()


def parse_arguments():
parser = argparse.ArgumentParser(
prog="spotdl",
description=help_notice,
formatter_class=argparse.RawDescriptionHelpFormatter,
)
parser.add_argument("url", type=str, nargs="+")

return parser.parse_args()


if __name__ == '__main__':
console_entry_point()
2 changes: 1 addition & 1 deletion spotdl/download/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__all__ = [
'progressHandlers',
'downloader'
]
]
Loading