From 350f2c6b557ef8482663cf8c7ef49a10ec41ff3d Mon Sep 17 00:00:00 2001 From: Kepoor Hampond Date: Sun, 30 Apr 2017 11:46:15 -0700 Subject: [PATCH] Version error with python 2 and 3 causing issue #20 --- .travis.yml | 10 ++++------ README.md | 25 +++++++++++++++---------- irs/cli.py | 7 ++++++- irs/ripper.py | 4 +++- tests/README.md | 2 +- tests/test_all.py | 7 ------- 6 files changed, 29 insertions(+), 26 deletions(-) delete mode 100644 tests/test_all.py diff --git a/.travis.yml b/.travis.yml index 258566f..d96b021 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,13 +11,11 @@ before_script: # I've gone through 25 seperate commits to get it working. install: - - pip install coveralls # For coveralls.io - - pip install nose - python setup.py install script: - irs -u "spotify" -p "Coffee Table Jazz" - - nosetests --with-coverage --cover-package=irs - -after_success: - - coveralls + - python tests/album.py + - python tests/playlist.py + - python tests/post_processors.py + - python tests/song.py diff --git a/README.md b/README.md index 4ce2634..92d89f4 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,6 @@ Ironic Redistribution System [![Stars](https://img.shields.io/github/stars/kepoorhampond/irs.svg?style=flat-square)](https://github.com/kepoorhampond/irs/stargazers) [![Build Status](https://img.shields.io/travis/kepoorhampond/irs/master.svg?style=flat-square)](https://travis-ci.org/kepoorhampond/irs) [![Say Thanks](https://img.shields.io/badge/say-thanks-ff69b4.svg?style=flat-square)](https://saythanks.io/to/kepoorhampond) -[![Coverage Status](http://img.shields.io/coveralls/kepoorhampond/irs.svg?style=flat-square)](https://coveralls.io/github/kepoorhampond/irs?branch=master&style=flat-square) [![PyPI](https://img.shields.io/badge/pypi-irs-blue.svg?style=flat-square)](https://pypi.python.org/pypi/irs) [![Beerpay](https://beerpay.io/kepoorhampond/irs/badge.svg?style=flat-square)](https://beerpay.io/kepoorhampond/irs) @@ -19,8 +18,9 @@ A tool to download your music with metadata. It uses [Spotify](https://www.spoti Works with Python 2 and 3. ___ -Demo and Usages ---- + +## Demo and Usages + This is a demo of the CLI displayling its features: [![demo](https://asciinema.org/a/105993.png)](https://asciinema.org/a/105993?autoplay=1) @@ -56,8 +56,8 @@ $ irs -s "Bohemian Rhapsody" $ irs -p "Best Nirvana" ``` -Install & The Dependencies (my new band name) ---- +## Install & The Dependencies (my new band name) + Really there's only one actual external dependency: `ffmpeg`. For windows, you'll want to follow [this](http://www.wikihow.com/Install-FFmpeg-on-Windows) guide. For OSX, you'll want to install it through [`brew`](https://brew.sh/) with this command: ``` $ brew install ffmpeg @@ -73,8 +73,12 @@ Other than `ffmpeg` though, all other dependencies are automatically installed w $ sudo pip install irs ``` -Metadata ---- +## Spotify Playlists + +To download spotify playlists, you'll want to head to their Dev Apps page, [here](https://developer.spotify.com/my-applications/). After doing that you'll want to create a new app. Name it whatever you want and then once you've done that, find the `Client ID` and `Client Secret` keys. You'll want to take those keys and paste them into your system's environment variables as `SPOTIFY_CLIENT_ID` and `SPOTIFY_CLIENT_SECRET`, correspondingly. Viola! You can now download playlists! + +## Metadata + Currently, the program attaches the following metadata to the downloaded files: - Title - Artist @@ -85,16 +89,17 @@ Currently, the program attaches the following metadata to the downloaded files: - Disc Number - Compilation (iTunes only) -### Philosophy +## Philosophy + When I made this program I was pretty much broke and my music addiction wasn't really helping that problem. So, I did the obvious thing: make an uber-complicated program to ~~steal~~ download music for me! As for the name, its acronym spells IRS, which I found amusing, seeing as the IRS ~~takes~~ steals money while my program ~~gives~~ reimburses you with music. The design/style inspiration of pretty much everything goes to [k4m4](https://github.com/k4m4). -### Wishlist +## Wishlist + - [x] Full album downloading - [x] Album art metadata correctly displayed - [x] Spotify playlist downloading - [ ] GUI/Console interactive version - *in progress* - [ ] Lyric metadata - [ ] 99% success rate for automatic song choosing - diff --git a/irs/cli.py b/irs/cli.py index c2456af..37d6db8 100644 --- a/irs/cli.py +++ b/irs/cli.py @@ -56,7 +56,12 @@ directory to place files in.") # Combiner args from argparse and the ripper_args as above and then # remove all keys with the value of "None" ripper_args.update(vars(args)) - ripper_args = dict((k, v) for k, v in ripper_args.iteritems() if v) + + # Python 2 and below uses list.iteritems() while Python 3 uses list.items() + if sys.version_info[0] >= 3: + ripper_args = dict((k, v) for k, v in ripper_args.items() if v) + elif sys.version_info[0] < 3: + ripper_args = dict((k, v) for k, v in ripper_args.iteritems() if v) ripper = Ripper(ripper_args) diff --git a/irs/ripper.py b/irs/ripper.py index 6cd3b01..fc64727 100644 --- a/irs/ripper.py +++ b/irs/ripper.py @@ -208,7 +208,9 @@ with init, or in method arguments.") list_of_lists = self.spotify.search(q=search, type="album") list_of_lists = list_of_lists["albums"]["items"] elif type == "playlist": - list_of_lists = self.spotify.user_playlists(username)["items"] + try: + list_of_lists = self.spotify.user_playlists(username)["items"] + except if len(list_of_lists) > 0: the_list = None diff --git a/tests/README.md b/tests/README.md index 98df056..c8e0231 100644 --- a/tests/README.md +++ b/tests/README.md @@ -1,2 +1,2 @@ # Travis CI tests are wierd -Tests with `ffmpeg` are wierd on Travis. It's a fact that I've had to deal with for 25 commits in total. So, the only songs I've found *so far* that work with ffmpeg are from the album `Da Frame 2R / Matador` by `Arctic Monkeys`. It's really lame, but don't mess around with them. \ No newline at end of file +Tests with `ffmpeg` are wierd on Travis. It's a fact that I've had to deal with for 25 commits in total. So, the only songs I've found *so far* that work with ffmpeg are from the album `Da Frame 2R / Matador` by `Arctic Monkeys`. It's really lame, but don't mess around with them. diff --git a/tests/test_all.py b/tests/test_all.py deleted file mode 100644 index 6b979d8..0000000 --- a/tests/test_all.py +++ /dev/null @@ -1,7 +0,0 @@ -from os import system, chdir -chdir("tests/") - -system("python album.py") -system("python playlist.py") -system("python post_processors.py") -system("python song.py") \ No newline at end of file