Skip to content

Commit

Permalink
added multi processing (#300)
Browse files Browse the repository at this point in the history
* added multiprocessing feature
deleted redundant lines of code
still editing

* corrected some deep source noticed errors

* more deepsource error correction

* deep source

* corrected imports

* updated imports

* correcting errors shown by deep source

* deep source errors

* deep source errors

* correcting deepsource errors

* Update spotify_dl.py

* Update youtube.py

* Update youtube.py

* Update youtube.py

* Update scaffold.py

* Update youtube.py

* Update youtube.py

* Update youtube.py

* Update scaffold.py

* Update youtube.py

* Update scaffold.py

* Update youtube.py

* Update youtube.py

* Update youtube.py

* Update spotify_dl.py

* Update youtube.py

* Update youtube.py

* Update youtube.py

* Update youtube.py

* Update spotify_dl.py

* updated readme

* Update README.md

* fixed comma delimiter confusion [csv]

making local repo up to date with remote repo

* corrected some errors in the tag editing code

* changed tests.. still editing though

* Remove unused imports

* Remove commented out code

* all tests now pass.. made some changes to tests
manually fixed merge conflict

* corrected get_tokens import

* added yt search to requirements.txt

* update tests.yml

added youtube search to dependencies

* removed youtube search, added backlash to special chars

* Update youtube.py

* readme update to include multiprocessing

* Update README.md

* Delete tags.txt

* Delete setup_creds.sh

* Delete All Songs For This Download.txt

* Update youtube.py

* Delete .cache

* Update scaffold.py

* Update scaffold.py

* Update youtube.py

* Update spotify_dl.py

validated number of cpu cores requested

* Update spotify_dl.py

* Update spotify_dl.py

* Update spotify_dl.py

* Update youtube.py

removed un used variable

* Update spotify.py

* Update youtube.py

* Delete .cache

* Update .gitignore

* Update README.md

Co-authored-by: Sathyajith Bhat <sathya@sathyasays.com>

* edits on file names

* updated black formatter configs

* Update tests.yml

* Delete setup_creds.sh

* Delete .cache

* corrected deepsource errors

* corrected deepsource errors

* Update youtube.py

* Update youtube.py

* all tests now pass

* Update youtube.py

* Update youtube.py

* Update youtube.py

* Update spotify_dl.py

removed the else bit from local config parser

* Update utils.py

* Update utils.py

* Update utils.py

* Update GETTING_STARTED.md

fixed windows cmd tokens config instruction

* fixed verbose mode

* Update spotify.py

Co-authored-by: kithstack <kithstack@pop-os.localdomain>
Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
Co-authored-by: Sathyajith Bhat <sathya@sathyasays.com>
  • Loading branch information
4 people authored Oct 10, 2022
1 parent 956501c commit a0650f2
Show file tree
Hide file tree
Showing 15 changed files with 1,081 additions and 619 deletions.
4 changes: 2 additions & 2 deletions GETTING_STARTED.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ You need Python 3.6+. To download songs as MP3, you will need ffmpeg.
$env:SPOTIPY_CLIENT_SECRET='your-spotify-client-secret'

Windows CMD:
set SPOTIPY_CLIENT_ID='your-spotify-client-id'
set SPOTIPY_CLIENT_SECRET='your-spotify-client-secret'
set SPOTIPY_CLIENT_ID=your-spotify-client-id
set SPOTIPY_CLIENT_SECRET=your-spotify-client-secret

See [this question](http://superuser.com/a/284351/4377) for more info,

Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ For more details and other arguments, issue `-h`

spotify_dl -h

For downloading using multiple cores


spotify_dl -l [link] -mc [number of cores to use]

See [the getting started guide](https://github.com/SathyaBhat/spotify-dl/blob/master/GETTING_STARTED.md) for more details.

### Demo
Expand Down
56 changes: 28 additions & 28 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,47 @@
from setuptools import setup, find_packages
from spotify_dl.constants import VERSION

with open('README.md') as f:
with open("README.md") as f:
long_description = f.read()

with open('requirements.txt') as f:
with open("requirements.txt") as f:
requirements = f.read().splitlines()

setup(
name='spotify_dl',
name="spotify_dl",
version=VERSION,
python_requires='>=3.6',
python_requires=">=3.6",
install_requires=requirements,
author='Sathya Bhat',
author_email='sathya@sathyasays.com',
author="Sathya Bhat",
author_email="sathya@sathyasays.com",
packages=find_packages(),
include_package_data=True,
url='https://github.com/SathyaBhat/spotify-dl/',
license='MIT',
description='Downloads songs from a Spotify Playlist/Track/Album that you provide',
url="https://github.com/SathyaBhat/spotify-dl/",
license="MIT",
description="Downloads songs from a Spotify Playlist/Track/Album that you provide",
long_description=long_description,
long_description_content_type='text/markdown',
long_description_content_type="text/markdown",
entry_points={
'console_scripts': [
'spotify_dl=spotify_dl.spotify_dl:spotify_dl',
"console_scripts": [
"spotify_dl=spotify_dl.spotify_dl:spotify_dl",
],
},
classifiers=[
'Development Status :: 5 - Production/Stable',
'License :: OSI Approved :: MIT License',
'Operating System :: POSIX',
'Natural Language :: English',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Topic :: Internet',
'Topic :: Software Development :: Libraries',
'Topic :: Software Development :: Libraries :: Python Modules',
'Topic :: Utilities',
"Development Status :: 5 - Production/Stable",
"License :: OSI Approved :: MIT License",
"Operating System :: POSIX",
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Topic :: Internet",
"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Utilities",
],
)
2 changes: 2 additions & 0 deletions spotify_dl/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bkup/
.cache
4 changes: 3 additions & 1 deletion spotify_dl/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import signal
import sys


def signal_handler(sig, frame):
# Signal handler to handle SIGINT, usually when Ctrl+C is pressed.. or if SIGINT is sent.
# Thanks to https://stackoverflow.com/a/1112350/92837
print('\nCaught interrupt(did you press Ctrl+C?), stopping spotify_dl')
print("\nCaught interrupt(did you press Ctrl+C?), stopping spotify_dl")
sys.exit(0)


signal.signal(signal.SIGINT, signal_handler)
4 changes: 2 additions & 2 deletions spotify_dl/constants.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import os
from pathlib import Path

__all__ = ['VERSION']
__all__ = ["VERSION"]

VERSION = '8.3.0'
VERSION = "8.3.0"

if os.getenv("XDG_CACHE_HOME") is not None:
SAVE_PATH = os.getenv("XDG_CACHE_HOME") + "/spotifydl"
Expand Down
34 changes: 19 additions & 15 deletions spotify_dl/scaffold.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
from rich.logging import RichHandler
from rich.console import Console

__all__ = ['log', 'get_tokens', 'console']

logging.basicConfig(level=logging.INFO,
format="%(message)s",
datefmt="[%X]",
handlers=[RichHandler(show_level=False, show_time=False)])
__all__ = ["log", "get_tokens", "console"]

logging.basicConfig(
level=logging.INFO,
format="%(message)s",
datefmt="[%X]",
handlers=[RichHandler(show_level=False, show_time=False)],
)
console = Console()
log = logging.getLogger('sdl')
log = logging.getLogger("sdl")
sentry_sdk.init("https://fc66a23d79634b9bba1690ea13e289f0@o321064.ingest.sentry.io/2383261")


Expand All @@ -21,13 +23,14 @@ def get_tokens():
:param name: Name to be cleaned up
:return string containing the cleaned name
"""
log.debug('Checking for tokens')
CLIENT_ID = getenv('SPOTIPY_CLIENT_ID')
CLIENT_SECRET = getenv('SPOTIPY_CLIENT_SECRET')
log.debug("Tokens fetched: {} {}".format(CLIENT_ID, CLIENT_SECRET))
log.debug("Checking for tokens")
CLIENT_ID = getenv("SPOTIPY_CLIENT_ID")
CLIENT_SECRET = getenv("SPOTIPY_CLIENT_SECRET")
log.debug("Tokens fetched : %s %s ", CLIENT_ID, CLIENT_SECRET)

if CLIENT_ID is None or CLIENT_SECRET is None:
print('''
print(
"""
You need to set your Spotify API credentials. You can do this by
setting environment variables like so:
Linux:
Expand All @@ -39,11 +42,12 @@ def get_tokens():
$env:SPOTIPY_CLIENT_SECRET='your-spotify-client-secret'
Windows CMD:
set SPOTIPY_CLIENT_ID='your-spotify-client-id'
set SPOTIPY_CLIENT_SECRET='your-spotify-client-secret'
set SPOTIPY_CLIENT_ID=your-spotify-client-id
set SPOTIPY_CLIENT_SECRET=your-spotify-client-secret
Get your credentials at
https://developer.spotify.com/my-applications
''')
"""
)
return None
return CLIENT_ID, CLIENT_SECRET
Loading

0 comments on commit a0650f2

Please sign in to comment.