From 177f72b532a0472610cea059603ed573df0ade8e Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Fri, 2 Feb 2018 15:19:12 +0100 Subject: [PATCH 01/11] Prepare for releases --- .gitignore | 110 +++++++++++++++++++++++++++++++++++++++++++++-- CHANGES.md | 13 ++++++ README.md | 36 ++++++++++------ requirements.txt | 10 ----- setup.py | 53 +++++++++++++++++++++++ spotdl.py | 9 +++- 6 files changed, 202 insertions(+), 29 deletions(-) create mode 100644 CHANGES.md delete mode 100755 requirements.txt create mode 100644 setup.py diff --git a/.gitignore b/.gitignore index 39259af..a933daf 100755 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,111 @@ config.yml Music/ *.txt -.coverage - -*.pyc -__pycache__/ .cache/ +README.rst +upload.sh + +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +.static_storage/ +.media/ +local_settings.py + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv .python-version + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ diff --git a/CHANGES.md b/CHANGES.md new file mode 100644 index 0000000..4dfaf32 --- /dev/null +++ b/CHANGES.md @@ -0,0 +1,13 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +## 1.0.0-alpha.1 - 2018-02-02 +### Added +- Initial release, prepare for 1.0.0 + +[Unreleased]: https://github.com/olivierlacan/keep-a-changelog/compare/v1.0.0-alpha.1...HEAD diff --git a/README.md b/README.md index 3235d0f..644f4e4 100755 --- a/README.md +++ b/README.md @@ -38,26 +38,31 @@ If you need to use Python 2 though, check out the (old) `python2` branch. since they were not of much use and created unnecessary clutter. You can still get them back by using `old` branch though. -### Debian, Ubuntu, Linux & Mac +### Debian-like GNU/Linux & macOS ``` -$ cd -$ git clone https://github.com/ritiek/spotify-downloader -$ cd spotify-downloader -$ pip install -U -r requirements.txt +$ pip install spotify-downloader ``` **Important:** if you have installed both Python 2 and 3, the `pip` command could invoke an installation for Python 2. To see which Python version `pip` refers to, try `$ pip -V`. If it turns out `pip` is your Python 2 pip, try -`$ pip3 install -U -r requirements.txt` instead. +`$ pip3 install spotify-downloader` instead. You'll also need to install FFmpeg for conversion (use `--avconv` if you'd like to use that instead): -Linux: `$ sudo apt-get install ffmpeg` +GNU/Linux: -Mac: `$ brew install ffmpeg --with-libmp3lame --with-libass --with-opus --with-fdk-aac` +``` +$ sudo apt-get install ffmpeg +``` + +macOS: + +``` +$ brew install ffmpeg --with-libmp3lame --with-libass --with-opus --with-fdk-aac +``` If it does not install correctly, you may have to build it from source. For more info see https://trac.ffmpeg.org/wiki/CompilationGuide. @@ -65,18 +70,21 @@ For more info see https://trac.ffmpeg.org/wiki/CompilationGuide. ### Windows Assuming you have Python 3 -([preferably v3.6 or above to stay away from Unicode errors](https://stackoverflow.com/questions/30539882/whats-the-deal-with-python-3-4-unicode-different-languages-and-windows)) already installed and in PATH. - -- Download and extract the [zip file](https://github.com/ritiek/spotify-downloader/archive/master.zip) -from master branch. +([preferably v3.6 or above to stay away from Unicode errors](https://stackoverflow.com/questions/30539882/whats-the-deal-with-python-3-4-unicode-different-languages-and-windows)) and pip already installed and in PATH. - Download FFmpeg for Windows from [here](http://ffmpeg.zeranoe.com/builds/). Copy `ffmpeg.exe` from `ffmpeg-xxx-winxx-static\bin\ffmpeg.exe` to PATH (usually C:\Windows\System32\) or just place it in the root directory extracted from the above step. -- Open `cmd` and type `$ pip install -U -r requirements.txt` to install dependencies. -The same note about `pip` as for Debian, Ubuntu, Linux & Mac applies. +- Open `cmd` and type `pip install spotify-downloader`. +The same note about `pip` as for GNU/Linux and macOS applies. + +### From GitHub releases + +- Download and extract the [latest](https://github.com/ritiek/spotify-downloader/releases/latest) or a [specific](https://github.com/ritiek/spotify-downloader/releases/latest) release archive file. + +- `cd` into the directory and `python3 setup.py install` ## Instructions for Downloading Songs diff --git a/requirements.txt b/requirements.txt deleted file mode 100755 index 3927114..0000000 --- a/requirements.txt +++ /dev/null @@ -1,10 +0,0 @@ -pathlib >= 1.0.1 -youtube_dl >= 2017.5.1 -pafy >= 0.5.3.1 -spotipy >= 2.4.4 -mutagen >= 1.37 -unicode-slugify >= 0.1.3 -titlecase >= 0.10.0 -logzero >= 1.3.1 -lyricwikia >= 0.1.8 -PyYAML >= 3.12 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..a603573 --- /dev/null +++ b/setup.py @@ -0,0 +1,53 @@ +from setuptools import setup +from spotdl import __version__ + +# Created from README.md using pandoc +with open('README.rst', 'r') as f: + long_description = f.read() + +setup( + name='spotify-downloader', + py_modules=['spotdl'], + # Tests are included automatically: + # https://docs.python.org/3.6/distutils/sourcedist.html#specifying-the-files-to-distribute + packages=['core'], + version=__version__, + install_requires=[ + 'pathlib >= 1.0.1', + 'youtube_dl >= 2017.5.1', + 'pafy >= 0.5.3.1', + 'spotipy >= 2.4.4', + 'mutagen >= 1.37', + 'unicode-slugify >= 0.1.3', + 'titlecase >= 0.10.0', + 'logzero >= 1.3.1', + 'lyricwikia >= 0.1.8', + 'PyYAML >= 3.12' + ], + description='Download songs from YouTube using Spotify song URLs or playlists with albumart and meta-tags.', + long_description=long_description, + author='Ritiek Malhotra and the spotify-downloader contributors', + license='MIT', + url='https://github.com/ritiek/spotify-downloader', + download_url='https://pypi.org/project/spotify-downloader/', + keywords=['spotify', 'downloader', 'download', 'music', 'youtube', 'mp3', 'album', 'metadata'], + classifiers=[ + 'Development Status :: 4 - Beta', + 'Intended Audience :: End Users/Desktop', + 'License :: OSI Approved :: MIT License', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3 :: Only', + 'Topic :: Multimedia', + 'Topic :: Multimedia :: Sound/Audio', + 'Topic :: Utilities' + ], + entry_points={ + 'console_scripts': [ + 'spotdl = spotdl:cli', + ], + } +) diff --git a/spotdl.py b/spotdl.py index f175680..8d7528a 100755 --- a/spotdl.py +++ b/spotdl.py @@ -16,6 +16,8 @@ import time import platform import pprint +__version__ = '1.0.0b1' + def check_exists(music_file, raw_song, meta_tags): """ Check if the input song already exists in the given folder. """ @@ -167,12 +169,13 @@ def download_single(raw_song, number=None): return True -if __name__ == '__main__': +def main(): const.args = handle.get_arguments() internals.filter_path(const.args.folder) const.log = const.logzero.setup_logger(formatter=const.formatter, level=const.args.log_level) + global log log = const.log log.debug('Python version: {}'.format(sys.version)) log.debug('Platform: {}'.format(platform.platform())) @@ -197,3 +200,7 @@ if __name__ == '__main__': except KeyboardInterrupt as e: log.exception(e) sys.exit(3) + + +if __name__ == '__main__': + main() From 76ef1ffcb23c5787b39b9df64a133d2a873440f3 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Fri, 2 Feb 2018 15:21:29 +0100 Subject: [PATCH 02/11] Change alpha to beta --- CHANGES.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 4dfaf32..c3a532f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,8 +6,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] -## 1.0.0-alpha.1 - 2018-02-02 +## 1.0.0-beta.1 - 2018-02-02 ### Added - Initial release, prepare for 1.0.0 -[Unreleased]: https://github.com/olivierlacan/keep-a-changelog/compare/v1.0.0-alpha.1...HEAD +[Unreleased]: https://github.com/olivierlacan/keep-a-changelog/compare/v1.0.0-beta.1...HEAD From 56d24f03ae5c7117e3ef1110205a0f61593e3d90 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Fri, 2 Feb 2018 15:31:47 +0100 Subject: [PATCH 03/11] Fix tests --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e78439d..9757f2e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,7 +34,7 @@ addons: - libmp3lame-dev - libav-tools install: - - pip install -r requirements.txt + - python setup.py install - tinydownload 22684734659253158385 -o ~/bin/ffmpeg - chmod 755 ~/bin/ffmpeg script: python -m pytest test --cov=. From 7fa85af61615757f7ef07e08dff3fc426371a7e2 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Fri, 2 Feb 2018 16:05:59 +0100 Subject: [PATCH 04/11] Fix setup.py by not importing __version__ --- setup.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index a603573..c7e5b14 100644 --- a/setup.py +++ b/setup.py @@ -1,17 +1,28 @@ +import re +import ast from setuptools import setup -from spotdl import __version__ # Created from README.md using pandoc with open('README.rst', 'r') as f: long_description = f.read() + +# This does not work as the dependencies imported are most +# likely just about to be installed :/ +# from spotdl import __version__ + +_version_re = re.compile(r'__version__\s+=\s+(.*)') + +with open('spotdl.py', 'r') as f: + version = str(ast.literal_eval(_version_re.search(f.read()).group(1))) + setup( name='spotify-downloader', py_modules=['spotdl'], # Tests are included automatically: # https://docs.python.org/3.6/distutils/sourcedist.html#specifying-the-files-to-distribute packages=['core'], - version=__version__, + version=version, install_requires=[ 'pathlib >= 1.0.1', 'youtube_dl >= 2017.5.1', @@ -27,6 +38,7 @@ setup( description='Download songs from YouTube using Spotify song URLs or playlists with albumart and meta-tags.', long_description=long_description, author='Ritiek Malhotra and the spotify-downloader contributors', + author_email='ritiekmalhotra123@gmail.com', license='MIT', url='https://github.com/ritiek/spotify-downloader', download_url='https://pypi.org/project/spotify-downloader/', From 9699dab99c369a65cac2b2ae6d7c097c8be4d098 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Fri, 2 Feb 2018 16:09:30 +0100 Subject: [PATCH 05/11] Change command for GitHub releases installation --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 644f4e4..466ed81 100755 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ The same note about `pip` as for GNU/Linux and macOS applies. - Download and extract the [latest](https://github.com/ritiek/spotify-downloader/releases/latest) or a [specific](https://github.com/ritiek/spotify-downloader/releases/latest) release archive file. -- `cd` into the directory and `python3 setup.py install` +- `cd` into the directory and `pip install -e .` ## Instructions for Downloading Songs From 819fbe0c875e092757dfa96a46ecfb4b7ecbee11 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Fri, 2 Feb 2018 16:11:06 +0100 Subject: [PATCH 06/11] Fix Travis builds --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9757f2e..4346112 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,8 +33,10 @@ addons: - nasm - libmp3lame-dev - libav-tools + - pandoc install: - - python setup.py install + - pandoc --from=markdown --to=rst --output=README.rst README.md + - pip install -e . - tinydownload 22684734659253158385 -o ~/bin/ffmpeg - chmod 755 ~/bin/ffmpeg script: python -m pytest test --cov=. From 38b51486233031325a303f4cc869e395653b9696 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Fri, 2 Feb 2018 16:24:20 +0100 Subject: [PATCH 07/11] Fix link in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 466ed81..7e2102a 100755 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ The same note about `pip` as for GNU/Linux and macOS applies. ### From GitHub releases -- Download and extract the [latest](https://github.com/ritiek/spotify-downloader/releases/latest) or a [specific](https://github.com/ritiek/spotify-downloader/releases/latest) release archive file. +- Download and extract the [latest](https://github.com/ritiek/spotify-downloader/releases/latest) or a [specific](https://github.com/ritiek/spotify-downloader/releases) release archive file. - `cd` into the directory and `pip install -e .` From 225aec5df7714353a8920308e3ed558086b31312 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Tue, 17 Apr 2018 12:58:12 +0200 Subject: [PATCH 08/11] Remove local config.yml backup --- config.yml.bak | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100755 config.yml.bak diff --git a/config.yml.bak b/config.yml.bak deleted file mode 100755 index 465f47c..0000000 --- a/config.yml.bak +++ /dev/null @@ -1,14 +0,0 @@ -spotify-downloader: - avconv: false - download-only-metadata: false - dry-run: false - file-format: '{artist} - {track_name}' - folder: /home/linus/GitHub/spotify-downloader/Music - input-ext: .m4a - log-level: INFO - manual: false - music-videos-only: false - no-metadata: false - no-spaces: false - output-ext: .mp3 - overwrite: prompt From 8d569aca3f551c5930c41899542a0736283833df Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Tue, 17 Apr 2018 13:02:45 +0200 Subject: [PATCH 09/11] Fix tests --- setup.py | 1 + test/test_with_metadata.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 00099ba..97b9415 100644 --- a/setup.py +++ b/setup.py @@ -29,6 +29,7 @@ setup( 'pafy >= 0.5.3.1', 'spotipy >= 2.4.4', 'mutagen >= 1.37', + 'beautifulsoup4 >= 4.6.0', 'unicode-slugify >= 0.1.3', 'titlecase >= 0.10.0', 'logzero >= 1.3.1', diff --git a/test/test_with_metadata.py b/test/test_with_metadata.py index ec3bb3d..1a1ef53 100644 --- a/test/test_with_metadata.py +++ b/test/test_with_metadata.py @@ -16,7 +16,7 @@ raw_song = 'http://open.spotify.com/track/0JlS7BXXD07hRmevDnbPDU' def test_metadata(): - expect_number = 22 + expect_number = 23 global meta_tags meta_tags = spotify_tools.generate_metadata(raw_song) assert len(meta_tags) == expect_number From 12d3da0f8d5e6bab45d5df6248bfb65d013075dc Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Tue, 17 Apr 2018 13:15:34 +0200 Subject: [PATCH 10/11] Fix PyPI Markdown, lower version to 0.9.0 --- setup.py | 1 + spotdl.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 97b9415..a3c5e6d 100644 --- a/setup.py +++ b/setup.py @@ -38,6 +38,7 @@ setup( ], description='Download songs from YouTube using Spotify song URLs or playlists with albumart and meta-tags.', long_description=long_description, + long_description_content_type='text/markdown', author='Ritiek Malhotra and the spotify-downloader contributors', author_email='ritiekmalhotra123@gmail.com', license='MIT', diff --git a/spotdl.py b/spotdl.py index ac63a26..a30977d 100755 --- a/spotdl.py +++ b/spotdl.py @@ -16,7 +16,7 @@ import time import platform import pprint -__version__ = '1.0.0b1' +__version__ = '0.9.0' def check_exists(music_file, raw_song, meta_tags): From b0d5895180c584ba45831549b5bb8812a3479860 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Tue, 17 Apr 2018 13:20:01 +0200 Subject: [PATCH 11/11] Bump version --- spotdl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spotdl.py b/spotdl.py index a30977d..c59452a 100755 --- a/spotdl.py +++ b/spotdl.py @@ -16,7 +16,7 @@ import time import platform import pprint -__version__ = '0.9.0' +__version__ = '0.9.1' def check_exists(music_file, raw_song, meta_tags):