Giter Site home page Giter Site logo

solidhal / spotify-ripper Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tmerten/spotify-ripper

81.0 12.0 22.0 612 KB

Command-line ripper for Spotify, with a workaround for playlist emptying

License: MIT License

Ruby 0.70% Shell 1.53% Python 97.77%

spotify-ripper's Introduction

NOTE: This fork is no longer actively maintained and by default empties the spotify playlist it rips irrelevant of the status of the remove from playlist flag as that is my use case.

If you are looking for a fork that has the webapi modifications from this repo, plus DOESN't wipe the playlist after ripping check out: https://github.com/wolfmanx/spotify-ripper/tree/pr-collect

spotify-ripper Version

A fork of `spotify-ripper <https://github.com/jrnewell/spotify-ripper`__ that uses spotipy for WebAPI integration and playlist updating

*IMPORTANT* Due to the playlist retreival method of libspotify (pyspotify library) no longer functioning, a spotify web api account is now required for playlist ripping and emptying

please read the section below "Remove From Playlist Option" for instructions and tips on setting up a web api client and generating a token

make sure you export the web api credentials in your unix shell export SPOTIPY_CLIENT_ID='77aa1aa93dc0416397f22a7a9b4a815b' export SPOTIPY_CLIENT_SECRET='0d79181c57ee412aaa770af257edf07a' export SPOTIPY_REDIRECT_URI='http://www.purple.com'

Spotify-ripper is a small ripper script for Spotify that rips Spotify URIs to audio files and includes ID3 tags and cover art. By default spotify-ripper will encode to MP3 files, but includes the ability to rip to WAV, FLAC, Ogg Vorbis, Opus, AAC, and MP4/M4A.

Note that stream ripping violates the libspotify's ToS

Libspotify’s Deprecation

From Mopidy's documentation

Note that as of May 2015 libspotify is officially deprecated by Spotify and is no longer actively maintained.

Note that as of Jan 2016 Spotify may no longer be issuing developer keys.

Spotify has published newer libraries intended for Android and iOS development, as well as web APIs to access track metadata and manage playlists. Though, for making apps with Spotify playback capabilities, on any other platform than Android and iOS, there is currently no alternative to libspotify.

libspotify has been the main way of integrating with Spotify since 2009, and is today a part of numerous open source projects and commercial applications, including many receivers and even cars. There’s no guarantees, but one can hope that the large deployment of libspotify means that the library will continue to work with the Spotify service for a long time into the future.

Features

  • real-time VBR or CBR ripping from Spotify PCM stream
  • writes ID3v2/metadata tags (including album covers)
  • rips files into the following directory structure: artist/album/artist - song.mp3 by default or optionally into a user-specified structure (see Format String section below)
  • option to skip or overwrite existing files
  • accepts tracks, playlists, albums, and artist URIs
  • search for tracks using Spotify queries
  • options for interactive login (no password in shell history) and to relogin using previous credentials
  • option to remove tracks from playlist after successful ripping
  • globally installs ripper script using pip
  • Python 2.7.x and 3.4.x compatible. Python 3 will occasionally throw a NameError: name '_lock' is not defined exception at the end of the script due to an upstream bug in pyspotify.
  • use a config file to specify common command-line options
  • helpful progress bar to gauge the time remaining until completion
  • keep local files in sync with a Spotify playlist, m3u and wpl playlist file
  • option to rip to ALAC, a loseless codec, instead of MP3 (requires extra avconv dependency)
  • option to rip to FLAC, a loseless codec, instead of MP3 (requires extra flac dependency)
  • option to rip to AIFF, a loseless codec, instead of MP3 (requires extra sox dependency)
  • option to rip to Ogg Vorbis instead of MP3 (requires extra vorbis-tools dependency)
  • option to rip to Opus instead of MP3 (requires extra opus-tools dependency)
  • option to rip to AAC instead of MP3 (requires extra faac dependency)
  • option to rip to MP4/M4A instead of MP3 (requires compiling fdkaac)
  • option to replace output filenames
  • option to normalize output filenames to NFKD (see http://unicode.org/faq/normalization.html)

Please note: Spotify’s highest quality setting is 320 kbps, so the benefit of ripping to a lossless format is to not double encode the audio data. It’s not possible to rip in true lossless quality.

Usage

Command Line

spotify-ripper takes many command-line options

usage: spotify-ripper [-h] [-S SETTINGS] [-a] [--aac] [--aiff] [--alac]
                      [--all-artists] [--artist-album-type ARTIST_ALBUM_TYPE]
                      [--artist-album-market ARTIST_ALBUM_MARKET] [-A]
                      [-b BITRATE] [-c] [--comp COMP] [--comment COMMENT]
                      [--cover-file COVER_FILE]
                      [--cover-file-and-embed COVER_FILE] [-d DIRECTORY]
                      [--fail-log FAIL_LOG] [--flac] [-f FORMAT]
                      [--format-case {upper,lower,capitalize}] [--flat]
                      [--flat-with-index] [-g {artist,album}]
                      [--grouping GROUPING] [--id3-v23] [-k KEY] [-u USER]
                      [-p PASSWORD] [--large-cover-art] [-l] [-L LOG] [--pcm]
                      [--mp4] [--normalize] [-na] [-o] [--opus]
                      [--partial-check {none,weak,strict}]
                      [--play-token-resume RESUME_AFTER] [--playlist-m3u]
                      [--playlist-wpl] [--playlist-sync] [--plus-pcm]
                      [--plus-wav] [-q VBR] [-Q {160,320,96}]
                      [--remove-offline-cache] [--resume-after RESUME_AFTER]
                      [-R REPLACE [REPLACE ...]] [-s]
                      [--stereo-mode {j,s,f,d,m,l,r}]
                      [--stop-after STOP_AFTER] [--timeout TIMEOUT] [-V]
                      [--wav] [--windows-safe] [--vorbis] [-r]
                      uri [uri ...]

Rips Spotify URIs to MP3s with ID3 tags and album covers

positional arguments:
  uri                   One or more Spotify URI(s) (either URI, a file of URIs or a search query)

optional arguments:
  -h, --help            show this help message and exit
  -S SETTINGS, --settings SETTINGS
                        Path to settings, config and temp files directory [Default=~/.spotify-ripper]
  -a, --ascii           Convert the file name and the metadata tags to ASCII encoding [Default=utf-8]
  --aac                 Rip songs to AAC format with FreeAAC instead of MP3
  --aiff                Rip songs to lossless AIFF encoding instead of MP3
  --alac                Rip songs to Apple Lossless format instead of MP3
  --all-artists         Store all artists, rather than just the main artist, in the track's metadata tag
  --artist-album-type ARTIST_ALBUM_TYPE
                        Only load albums of specified types when passing a Spotify artist URI [Default=album,single,ep,compilation,appears_on]
  --artist-album-market ARTIST_ALBUM_MARKET
                        Only load albums with the specified ISO2 country code when passing a Spotify artist URI. You may get duplicate albums if not set. [Default=any]
  -A, --ascii-path-only
                        Convert the file name (but not the metadata tags) to ASCII encoding [Default=utf-8]
  -b BITRATE, --bitrate BITRATE
                        CBR bitrate [Default=320]
  -c, --cbr             CBR encoding [Default=VBR]
  --comp COMP           compression complexity for FLAC and Opus [Default=Max]
  --comment COMMENT     Set comment metadata tag to all songs. Can include same tags as --format.
  --cover-file COVER_FILE
                        Save album cover image to file name (e.g "cover.jpg") [Default=embed]
  --cover-file-and-embed COVER_FILE
                        Same as --cover-file but embeds the cover image too
  -d DIRECTORY, --directory DIRECTORY
                        Base directory where ripped MP3s are saved [Default=cwd]
  --fail-log FAIL_LOG   Logs the list of track URIs that failed to rip
  --flac                Rip songs to lossless FLAC encoding instead of MP3
  -f FORMAT, --format FORMAT
                        Save songs using this path and filename structure (see README)
  --format-case {upper,lower,capitalize}
                        Convert all words of the file name to upper-case, lower-case, or capitalized
  --flat                Save all songs to a single directory (overrides --format option)
  --flat-with-index     Similar to --flat [-f] but includes the playlist index at the start of the song file
  -g {artist,album}, --genres {artist,album}
                        Attempt to retrieve genre information from Spotify's Web API [Default=skip]
  --grouping GROUPING   Set grouping metadata tag to all songs. Can include same tags as --format.
  --id3-v23             Store ID3 tags using version v2.3 [Default=v2.4]
  -k KEY, --key KEY     Path to Spotify application key file [Default=Settings Directory]
  -u USER, --user USER  Spotify username
  -p PASSWORD, --password PASSWORD
                        Spotify password [Default=ask interactively]
  --large-cover-art     Attempt to retrieve 640x640 cover art from Spotify's Web API [Default=300x300]
  -l, --last            Use last login credentials
  -L LOG, --log LOG     Log in a log-friendly format to a file (use - to log to stdout)
  --pcm                 Saves a .pcm file with the raw PCM data instead of MP3
  --mp4                 Rip songs to MP4/M4A format with Fraunhofer FDK AAC codec instead of MP3
  --normalize           Normalize volume levels of tracks
  -na, --normalized-ascii
                        Convert the file name to normalized ASCII with unicodedata.normalize (NFKD)
  -o, --overwrite       Overwrite existing MP3 files [Default=skip]
  --opus                Rip songs to Opus encoding instead of MP3
  --partial-check {none,weak,strict}
                        Check for and overwrite partially ripped files. "weak" will err on the side of not re-ripping the file if it is unsure, whereas "strict" will re-rip the file [Default=weak]
  --play-token-resume RESUME_AFTER
                        If the 'play token' is lost to a different device using the same Spotify account, the script will wait a speficied amount of time before restarting. This argument takes the same values as --resume-after [Default=abort]
  --playlist-m3u        create a m3u file when ripping a playlist
  --playlist-wpl        create a wpl file when ripping a playlist
  --playlist-sync       Sync playlist songs (rename and remove old songs)
  --plus-pcm            Saves a .pcm file in addition to the encoded file (e.g. mp3)
  --plus-wav            Saves a .wav file in addition to the encoded file (e.g. mp3)
  -q VBR, --vbr VBR     VBR quality setting or target bitrate for Opus [Default=0]
  -Q {160,320,96}, --quality {160,320,96}
                        Spotify stream bitrate preference [Default=320]
  --remove-offline-cache
                        Remove libspotify's offline cache directory after the ripis complete to save disk space
  --resume-after RESUME_AFTER
                        Resumes script after a certain amount of time has passed after stopping (e.g. 1h30m). Alternatively, accepts a specific time in 24hr format to start after (e.g 03:30, 16:15). Requires --stop-after option to be set
  -R REPLACE [REPLACE ...], --replace REPLACE [REPLACE ...]
                        pattern to replace the output filename separated by "/". The following example replaces all spaces with "_" and all "-" with ".":    spotify-ripper --replace " /_" "\-/." uri
  -s, --strip-colors    Strip coloring from output [Default=colors]
  --stereo-mode {j,s,f,d,m,l,r}
                        Advanced stereo settings for Lame MP3 encoder only
  --stop-after STOP_AFTER
                        Stops script after a certain amount of time has passed (e.g. 1h30m). Alternatively, accepts a specific time in 24hr format to stop after (e.g 03:30, 16:15)
  --timeout TIMEOUT     Override the PySpotify timeout value in seconds (Default=10 seconds)
  -V, --version         show program's version number and exit
  --wav                 Rip songs to uncompressed WAV file instead of MP3
  --windows-safe        Make filename safe for Windows file system (truncate filename to 255 characters)
  --vorbis              Rip songs to Ogg Vorbis encoding instead of MP3
  -r, --remove-from-playlist
                        [WARNING: READ BELOW TO SETUP WEB API FOR PLAYLIST EMPTYING] Delete tracks from playlist after successful ripping [Default=no]

Example usage:
    rip a single file: spotify-ripper -u user spotify:track:52xaypL0Kjzk0ngwv3oBPR
    rip entire playlist: spotify-ripper -u user spotify:user:username:playlist:4vkGNcsS8lRXj4q945NIA4
    rip a list of URIs: spotify-ripper -u user list_of_uris.txt
    rip tracks from Spotify's charts: spotify-ripper -l spotify:charts:regional:global:weekly:latest
    search for tracks to rip: spotify-ripper -l -Q 160 -o "album:Rumours track:'the chain'"

Facebook Login

Spotify-ripper will work with your regular Facebook login/password if you setup your Spotify account to login using your Facebook credentials. Otherwise, use your Spotify login/password.

Config File

For options that you want set on every run, you can use a config file named config.ini in the settings folder (defaults to ~/.spotify-ripper). The options in the config file use the same name as the command line options with the exception that dashes are translated to snake_case. Any option specified in the command line will overwrite any setting in the config file. Please put all options under a [main] section.

Here is an example config file

[main]
ascii = True
format = {album_artist}/{album}/{artist} - {track_name}.{ext}
quality = 160
vorbis = True
last = True

Format String

The format string dictates how spotify-ripper will organize your ripped files. This is controlled through the -f | --format option. The string should include the format of the file name and optionally a directory structure. If you do not include a format string, the default format will be used: {album_artist}/{album}/{artist} - {track_name}.{ext}.

The --flat option is shorthand for using the format string: {artist} - {track_name}.{ext}, and the --flat-with-index option is shorthand for using the format string: {idx:3} - {artist} - {track_name}.{ext}. The use of these shorthand options will override any --format string option given.

Your format string can include the following variables names, which are case-sensitive and wrapped in curly braces, if you want your file/path name to be overwritten with Spotify metadata.

Format String Variables

Names and Aliases Description
{track_artist}, {artist} The track's artist
{track_artists}, {artists} Similar to {track_artist} but will be join multiple artists with a comma (e.g. "artist 1, artist 2")
{album_artist} When passing an album, the album's artist (e.g. "Various Artists"). If no album artist exists, the track artist is used instead
{album_artists_web} Similar to {album_artist} but retrieves artist information from Spotify's Web API. Unlike {album_artist}, multiple album artists can be retrieved and will be joined with a comma (e.g. "artist 1, artist 2")
{album} Album name
{track_name}, {track} Track name
{year} Release year of the album
{ext}, {extension} Filename extension (i.e. "mp3", "ogg", "flac", ...)
{idx}, {index} Playlist index
{track_num}, {track_idx}, {track_index} The track number of the disc
{disc_num}, {disc_idx}, {disc_index} The disc number of the album
{smart_track_num}, {smart_track_idx}, {smart_track_index} For a multi-disc album, {smart_track_num} will return a number combining the disc and track number. e.g. for disc 2, track 4 it will return "204". For a single disc album, it will return the track num.
{playlist}, {playlist_name} Name of playlist if passed a playlist uri, otherwise "No Playlist"
{playlist_owner}, {playlist_user}, {playlist_username} User name of playlist's owner if passed a a playlist uri, otherwise "No Playlist Owner"
{playlist_track_add_time}, {track_add_time}, When the track was added to the playlist
{playlist_track_add_user}, {track_add_user}, The user that added the track to the playlist
{user}, {username} Spotify username of logged-in user
{feat_artists}, {featuring_artists} Featuring artists join by commas (see Prefix String section below)
{copyright} Album copyright message
{label}, {copyright_holder} Album copyright message with the year removed at the start of the string if it exists
{track_uri}, {uri} Spotify track uri

Any substring in the format string that does not match a variable above will be passed through to the file/path name unchanged.

Zero-Filled Padding

Format variables that represent an index can be padded with zeros to a user-specified length. For example, {idx:3} will produce the following output: 001, 002, 003, etc. If no number is provided, no zero-filled padding will occur (e.g. 8, 9, 10, 11, ...). The variables that accept this option include {idx}, {track_num}, {disc_num}, {smart_track_num} and their aliases.

Prefix String

Format variable feat_artists takes a prefix string to be prepended before the output. For example, {feat_artists:featuring} will produce the follow output ``featuing Bruno Mars. If there are no featuring artists, the prefix string (and any preceding spaces) will not be included.

Playlist Sync Option

By default, other than checking for an overwrite, spotify-ripper will not keep track of local files once they are ripped from Spotify. However, if you use the --playlist-sync option when passing a playlist URI, spotify-ripper will store a json file in your settings directory that keeps track of location of your ripped files for that playlist.

If at a later time, the playlist is changed on Spotify (i.e. songs reordered, removed or added), spotify-ripper will try to keep your local files "in sync" the playlist if you rerun the same command. For example, if your format string is {index} {artist} - {track_name}.{ext}, it will rename is existing files so the index is correct. Note that with option set, spotify-ripper will delete a song that was previously on the playlist, but was removed but still exists on your local machine. It does not affect files outside of the playlist and has no effect on non-playlist URIs.

If you want to redownload a playlist (for example with improved quality), you either need to remove the song files from your local or use the --overwrite option.

Remove From Playlist Option

Since the work around to remove songs from a playlist uses the Spotify Web API, to enable --remove-from-playlist you must go through a few steps

1: Make an application at https://developer.spotify.com/my-applications/ name it whatever you like

2: Generate and store you client_id and client_secret, you'll need these later

3: Add http://www.purple.com to your applications Redirect URI's, make sure to click the green "ADD" button to the right of the field before pressing SAVE. I am not affiliated with www.purple.com, I just like what they do. If you want to use a different URI, ensure it doesn't use https and change the redirect_uri in remove_all_from_playlist.py

4: Press the "SAVE" button at the bottom of the page

5: Install this package if you haven't already and navigate to it in the python version you installed it with (I would suggest Python 3 at least) For example, my installation directory is "/usr/local/lib/python3.4/dist-packages/spotify_ripper/"

6: open remove_all_from_playlist.py in your favorite text editor. Add your client_id and client_secret between the single quotes next to the variables named the same thing

7: If you have been using spotify-ripper for a while, it probably doesn't have accurate cache data on your playlists anymore. Find your ".spotify-ripper" folder, most likely in your home directory, and delete your "Users" folder. It will be regenerated on the next run.

8: Finally, run spotify-ripper with the --remove-from-playlist command. When prompted, open the link it says it's opening for you in a web browser. Log into spotify, give it permission, and the copy the entire url it redirects to. If you're using the default redirect_url, it should be in the form "http://www.purple.com/?code=XXXXXXXXXXXX....." Ensure you haven't typed any other characters into where it asks for the URL you were redirected to, paste the URL and press enter. For some reason, when run through SSH you won't see anything you type or paste into this field.

If you followed all of these steps correctly, spotify-ripper will completely empty the playlist you are ripping from when it finishes.

A couple notes about Spotify's WebAPI token authentication: - The token is stored in a file named .profile-“username” without quotes

  • The authentication token is stored where the script is executed from, so if you're in your home directory and execute a script thats in /usr/bin it will be stored in your home directory
  • If you are running this in a script or other form of automation, you'll have to manually authenticate once but after that as long as you always execute it from the same location you won't have to authenticate again.
  • Depending on your browser, it may redirect quickly after going to http://www.purple.com?code=XXXXXXXXXX.... you have to be quick to copy the url with the full code and paste it into your terminal otherwise you'll have to re run the program to generate a new token

Installation

Prerequisites

Mac OS X

Recommend approach uses homebrew and pyenv

To install pyenv using homebrew:

$ brew update
$ brew install pyenv
$ eval "$(pyenv init -)"
## the next line ensures 'eval "$(pyenv init -)"' is run everytime terminal is opened
$ echo 'if which pyenv > /dev/null; then eval "$(pyenv init -)"; fi' >> ~/.bash_profile
$ pyenv install 2.7.10  # or whatever version of python you want
$ pyenv global 2.7.10
$ python -V             # should say Python 2.7.10

To install spotify-ripper once pyenv is setup:

$ brew install homebrew/binary/libspotify
$ sudo ln -s /usr/local/opt/libspotify/lib/libspotify.12.1.51.dylib \
    /usr/local/opt/libspotify/lib/libspotify
$ brew install lame
$ pip install git+https://github.com/SolidHal/spotify-ripper
$ pyenv rehash

Note that Spotify may no longer be issuing developer keys. See Libspotify’s Deprecation

Download an application key file spotify_appkey.key from https://devaccount.spotify.com/my-account/keys/ (requires a Spotify Premium Account) and move the file to the ~/.spotify-ripper directory (or use the -k | --key option).

Ubuntu/Debian

Recommend approach uses pyenv. If you don't use pyenv, you need to install the python-dev package too. If you are installing on the Raspberry Pi (gen 1), use the eabi-armv6hf version of libspotify.

To install pyenv using pyenv-installer (requires git and curl):

$ curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash
## restart terminal ##
$ pyenv install 2.7.10  # or whatever version of python you want
$ pyenv global 2.7.10
$ python -V             # should say Python 2.7.10

To install spotify-ripper once pyenv is setup:

$ sudo apt-get install lame build-essential libffi-dev
$ wget https://developer.spotify.com/download/libspotify/libspotify-12.1.51-Linux-x86_64-release.tar.gz # (assuming 64-bit)
$ tar xvf libspotify-12.1.51-Linux-x86_64-release.tar.gz
$ cd libspotify-12.1.51-Linux-x86_64-release/
$ sudo make install prefix=/usr/local
$ pip install spotipy
$ pip3 install git+https://github.com/SolidHal/spotify-ripper --upgrade
$ pyenv rehash

Note that Spotify may no longer be issuing developer keys. See Libspotify’s Deprecation

Download an application key file spotify_appkey.key from https://devaccount.spotify.com/my-account/keys/ (requires a Spotify Premium Account) and move the file to the ~/.spotify-ripper directory (or use the -k | --key option).

Windows

Unfortunately, pyspotify seems to have an issue building on Windows (if someone can get this to work, please let me know). The best alternative is to run a linux distribution in a virtual machine. Basic instructions to install Ubuntu on Virtual Box can be found in the wiki.

Optional Encoding Formats

In addition to MP3 encoding, spotify-ripper supports encoding to FLAC, AAC, MP4/M4A, Ogg Vorbis and Opus. However, additional encoding tools need to be installed for each codec you wish to use.

Mac OS X

# FLAC
$ brew install flac

# ALAC
$ brew install libav

# AAC
$ brew install faac

# MP4/M4A
$ brew install fdk-aac-encoder

# Ogg Vorbis
$ brew install vorbis-tools

# Opus
$ brew install opus-tools

# SoX
$ brew install sox

Ubuntu/Debian

# FLAC
$ sudo apt-get install flac

# ALAC
$ sudo apt-get install libav-tools

# AAC
$ sudo apt-get install faac

# MP4/M4A (need to compile fdkaac from source)
$ sudo apt-get install libfdk-aac-dev automake autoconf
$ wget https://github.com/nu774/fdkaac/archive/v0.6.2.tar.gz
$ tar xvf v0.6.2.tar.gz
$ cd fdkaac-0.6.2
$ autoreconf -i
$ ./configure
$ sudo make install

# Ogg Vorbis
$ sudo apt-get install vorbis-tools

# Opus
$ sudo apt-get install opus-tools

# SoX
$ sudo apt-get install install sox

Upgrade

Use pip to upgrade to the latest version.

$ pip install --upgrade git+https://github.com/SolidHal/spotify-ripper

Common Issues and Problems

Help for common problems while using spotify-ripper can be found in the wiki.

Release Notes

Release notes can be found in the wiki.

License

MIT License

spotify-ripper's People

Contributors

bhelm avatar bluemeda avatar deerhunter91 avatar gervasiocaj avatar jerryz1982 avatar jrnewell avatar logiconcepts819 avatar notimplementedyet avatar solidhal avatar vikbez avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

spotify-ripper's Issues

Je n'y comprend rien du tout

Je suis débutant dans ubuntu, puisque j'utilise Windows. Du coup je ne comprends rien de ce qu'il faut faire, faut installer de tas de programmes dont je ne comprends pas l'utilité, et quand j'essaye de le faire ça me met des erreurs partout.

Est-ce qu'il serait possible d'avoir des instructions claires et précises ?

Au passage je me suis renseigné sur l'application libspotify, et apparemment elle n'existerait plus. Y'a-t-il une alternative à cela ?

Merci d'avance

Issues in download

Hi, I have premium Spotify account and use this command but doesn't work:

vagrant@vagrant-ubuntu-trusty-64:~$ spotify-ripper -u myusername -p mypassword spotify:track:2bOcIC4wFd6OENI7UGHzIg
Spotify Ripper - v2.9.1
Encoding output: MP3, VBR 0
Spotify bitrate: 160 kbps
Unicode support: Yes
Output directory: /vagrant/Music
Settings directory: /home/vagrant/.spotify-ripper
Format String: {artist} - {album}/{idx:3} - {artist} - {track_name}.{ext}
Overwrite files: No

Please copy your spotify_appkey.key to /home/vagrant/.spotify-ripper, or use the --key|-k option

Can't I download without appkey? or Do I have any other problems?
How can I generate appkey if it's necessary?

Thanks.

Use Web Playback API

Spotify recently released a Web Playback Javascript API which is beta at the time of writing.

Is this project actively developed? Building on top of that would remove the dependency on libspotify and their API keys which can no longer be easily obtained.

Thanks.

Logged in failed: BAD_USERNAME_OR_PASSWORD

Hey, I just tried to use this tool, but got a login error:
Logged in failed: BAD_USERNAME_OR_PASSWORD

I'm pretty certain I'm using the correct password.
I'm signed up to Spotify using my Facebook account.

Command line:
$ spotify-ripper
--normalized-ascii
--flat
--flac
--comp 5
-k <some_spotify_appkey.key>
-u [email protected]
spotify:user:1234:playlist:abc
Spotify Ripper - v2.10.5
Encoding output: FLAC, Compression Level: 5
Spotify bitrate: 320 kbps
Unicode support: Yes
Output directory: /Users/thowi/spotify-ripper
Settings directory: /Users/thowi/.spotify-ripper
Format String: {artist} - {track_name}.{ext}
Overwrite files: No
Logging in...
Password:
Logged in failed: BAD_USERNAME_OR_PASSWORD
Encountered issue while logging into Spotify, aborting...

Does anybody else have the same issue?

Can you rip playlists with more than 100 songs?

I'm having an issue downloading more than 100 songs.

For example, when running this command:

spotify-ripper -l spotify:user:USERNAME:playlist:612354abbc....

And you add a len(), it returns 100 songs:

track_list = playlist['tracks'].get('items')

https://github.com/SolidHal/spotify-ripper/blob/master/spotify_ripper/ripper.py#L433

I'll continue debugging, but if somebody knows if there's a limitation of the API or of any libs this program depends on that would be great

Downloading podcast (whole show or episode)

Is there any way to download whole podcasts? Or episodes?

URI code looks like:
spotify:show:070MmBvMBnTatKj5deEb59
or for one track:
spotify:episode:0eX9Z7YBJSIenAyZRSTmiz

Exception in thread SpotifyRipperThread: Traceback (most recent call last): File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner self.run() File "/usr/local/lib/python2.7/dist-packages/spotify_ripper/ripper.py", line 229, in run tracks = list(get_tracks_from_uri(uri)) File "/usr/local/lib/python2.7/dist-packages/spotify_ripper/ripper.py", line 224, in get_tracks_from_uri return self.load_link(uri) File "/usr/local/lib/python2.7/dist-packages/spotify_ripper/ripper.py", line 424, in load_link link = self.session.get_link(uri) File "/usr/local/lib/python2.7/dist-packages/spotify/session.py", line 376, in get_link return spotify.Link(self, uri=uri) File "/usr/local/lib/python2.7/dist-packages/spotify/link.py", line 73, in __init__ 'Failed to get link from Spotify URI: %r' % uri) ValueError: Failed to get link from Spotify URI: 'spotify:show:070MmBvMBnTatKj5deEb59'

ripper does not allow to generate WebAPI token

I just installed Spotify Ripper on Arch with Kernel 4.10.10 and tried authorizing the WebAPI.
I have a premium account and created the dummy App.
I stored the ID and Secret as enviroment var's and in "/usr/lib/python2.7/site-packages/spotify_ripper/remove_all_from_playlist.py". (printenv shows correctly)
Now for the problem:
as described in the readme i launched spotify-ripper with -r set
the output is as follows:

[user@arch Downloads]$ spotify-ripper -r -u user -p pass spotify:track:0eGsygTp906u18L0Oimnem
--REMOVE-FROM-PLAYLIST WARNING:
SPOTIFY HAS BROKEN libspotify
THE PLAYLIST WILL BE EMPTIED AT THE END USING THE WEB API
CHECK THE GITHUB FOR INSTRUCTIONS ON AUTHENTICATING THE WEB API
Spotify Ripper - v2.11
  Encoding output:	MP3, VBR 0
  Spotify bitrate:	320 kbps
  Unicode support:	Yes
  Output directory:	/home/user/Downloads
  Settings directory:	/home/user/.spotify-ripper
  Format String:	{album_artist}/{album}/{artist} - {track_name}.{ext}
  Overwrite files:	No

Please copy your spotify_appkey.key to /home/user/.spotify-ripper, or use the --key|-k option

python versions are: python2.7.13 / python3.6.0
python2-pyspotify: 2.0.5-2
python2-spotipy: 2.4.3-1

I assume that using the WebAPI i wont need the deprecated libspotify key?
Can i manually generate the WebAPI Token?

Mutagen Exception for skipping files in URI list file

So, as I tried the workaround for the workaround as suggested by @ramonskie in #25 (comment)_ (and it worked, thanks! 🙌 ), I could use a uri_list.txt successfully.
Now the process was aborted due to a wifi error locally, and now I can't restart the process in the same directory. I get the error below:

Exception in thread SpotifyRipperThread:
Traceback (most recent call last):
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 917, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.7/site-packages/spotify_ripper/ripper.py", line 241, in run
    self.progress.calc_total(all_tracks)
  File "/usr/local/lib/python3.7/site-packages/spotify_ripper/progress.py", line 76, in calc_total
    not is_partial(audio_file, track):
  File "/usr/local/lib/python3.7/site-packages/spotify_ripper/utils.py", line 446, in is_partial
    audio_file_dur = audio_file_duration(audio_file)
  File "/usr/local/lib/python3.7/site-packages/spotify_ripper/utils.py", line 441, in audio_file_duration
    _file = mutagen.File(audio_file)
  File "/usr/local/lib/python3.7/site-packages/mutagen/_file.py", line 235, in File
    return Kind(filename)
  File "/usr/local/lib/python3.7/site-packages/mutagen/_file.py", line 41, in __init__
    self.load(filename, *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/mutagen/id3/__init__.py", line 1084, in load
    self.info = self._Info(fileobj, offset)
  File "/usr/local/lib/python3.7/site-packages/mutagen/mp3.py", line 185, in __init__
    self.__try(fileobj, offset, size - offset, False)
  File "/usr/local/lib/python3.7/site-packages/mutagen/mp3.py", line 223, in __try
    raise HeaderNotFoundError("can't sync to an MPEG frame")
mutagen.mp3.HeaderNotFoundError: can't sync to an MPEG frame

If I trigger the action in a blank directory without files, it works perfectly (but downloads all files again..). Any idea how this error can happen and could be prevented?

All songs from playlist removed (new)

Hi,

I know there is issue #11, but I think this is a new issue? I downloaded a whole playlist correctly. Then I ran the spotify-ripper again on the same playlist and it removed all songs from that playlist, output:

Spotify Ripper - v2.10.5
  Encoding output:	FLAC, Compression Level: 8
  Spotify bitrate:	320 kbps
  Unicode support:	Yes
  Output directory:	/home/xxx/music
  Settings directory:	/home/xxx/.spotify-ripper
  Format String:	{artists} - {track_name}.{ext}
  Overwrite files:	No
Logging in...
Logged in as xxx
get playlist tracks
Getting Results
Loading playlist...
get playlist tracks
Getting Results
Loading playlist...
Getting Results
Playlist Emptied!
Logging out...

Python scripts errors

Hi,

anyone here could help me get rid of these errors?
I cannot understand why suddenly this script stopped working for me.
It worked till days ago, then stopped working.
tried reinstalling all dependencies and the ripper itself but still getting these errors.
It succesfully login, then disconnects giving me these errors

Here below what is happening.

Thanks a lot for Your kind help ;-)

Spotify Ripper - v2.10.5
Encoding output: FLAC, Compression Level: 8
Spotify bitrate: 320 kbps
Unicode support: Yes
Output directory: /home/bu/Music
Settings directory: /home/bu/.spotify-ripper
Format String: {album_artist}/{album}/{artist} - {track_name}.{ext}
Overwrite files: No
Logging in...
Logged in as ############
Traceback (most recent call last):
File "/usr/bin/spotify-ripper", line 11, in
load_entry_point('spotify-ripper==2.10.5', 'console_scripts', 'spotify-ripper')()
File "/usr/lib64/python3.4/site-packages/spotify_ripper-2.10.5-py3.4.egg/EGG-INFO/scripts/main.py", line 594, in main
stdin_settings = termios.tcgetattr(sys.stdin)
termios.error: (25, 'Inappropriate ioctl for device')
Logging out...

Trying to get this working in 2018... You need to set your Spotify API credentials?

Greetings,

So I have this application running very well on two Macs, tried to add a third and after following the standard installation instructions...

Spotify Ripper - v2.10.5 Encoding output: MP3, VBR 0 Spotify bitrate: 320 kbps Unicode support: Yes Output directory: /Users/kezz/Desktop Settings directory: /Users/kezz/.spotify-ripper Format String: {album_artist}/{album}/{artist} - {track_name}.{ext} Overwrite files: No Logging in...
That parts ✔️
but then:

get playlist tracks

            You need to set your Spotify API credentials. You can do this by
            setting environment variables like so:

            export SPOTIPY_CLIENT_ID='your-spotify-client-id'
            export SPOTIPY_CLIENT_SECRET='your-spotify-client-secret'
            export SPOTIPY_REDIRECT_URI='your-app-redirect-url'

            Get your credentials at     
                https://developer.spotify.com/my-applications
        
Exception in thread SpotifyRipperThread:
Traceback (most recent call last):
  File "/Users/kezz/.pyenv/versions/2.7.10/lib/python2.7/threading.py", line 810, in __bootstrap_inner
    self.run()
  File "/Users/kezz/.pyenv/versions/2.7.10/lib/python2.7/site-packages/spotify_ripper/ripper.py", line 229, in run
    tracks = list(get_tracks_from_uri(uri))
  File "/Users/kezz/.pyenv/versions/2.7.10/lib/python2.7/site-packages/spotify_ripper/ripper.py", line 224, in get_tracks_from_uri
    return self.load_link(uri)
  File "/Users/kezz/.pyenv/versions/2.7.10/lib/python2.7/site-packages/spotify_ripper/ripper.py", line 432, in load_link
    tracks = get_playlist_tracks(self.session.user.canonical_name, uri)
  File "/Users/kezz/.pyenv/versions/2.7.10/lib/python2.7/site-packages/spotify_ripper/remove_all_from_playlist.py", line 34, in get_playlist_tracks
    token = util.prompt_for_user_token(username, scope)
  File "/Users/kezz/.pyenv/versions/2.7.10/lib/python2.7/site-packages/spotipy/util.py", line 47, in prompt_for_user_token
    raise spotipy.SpotifyException(550, -1, 'no credentials set')
SpotifyException: http status: 550, code:-1 - no credentials set

I copied my .key file from one of the other macs, and I know it works on the other ones because I just tested it. However this is as far as I get here, any ideas?

Thanks

`WARNING: argument missing for 'V' lame: excess arg`

Seeing the following when ripping:

[ 3 / 32 ] Ripping spotify:track:1PDOZrlUSmXKEAe2xEnPDP	(ESC to skip)
/Users/goli/Music/DJ Music/Ripped/House/G Club - Guitarra G - G Club Original Mix.mp3
Track Download Size: 19.91 MB
Progress: [                                        ] 00:00 / 08:42
Total:    [                                        ] 00:00 / 03:02:13WARNING: argument missing for 'V'
lame: excess arg /Users/test/House/G Club - Guitarra G - G Club Original Mix.mp3
Spotify error detected
[Errno 32] Broken pipe
Traceback (most recent call last):
  File "/Users/goli/.pyenv/versions/2.7.10/lib/python2.7/site-packages/spotify_ripper/ripper.py", line 307, in run
    rip_item[1], rip_item[2])
  File "/Users/goli/.pyenv/versions/2.7.10/lib/python2.7/site-packages/spotify_ripper/ripper.py", line 818, in rip
    self.pipe.write(frame_bytes)
IOError: [Errno 32] Broken pipe
Skipping to next track...

This happens for all tracks.
Used to work, suddenly stopped working.

Any ideas? looks like lame might be throwing some kind of exception for some reason...

playlist download

i'm using the nice ripper for a long time.
and since the beginning of this week it failed to download the playlists

Logging in...
Logged in as 1131828447
Loading playlist...
Loading playlist...
Logging out...

i tried the export SPOTIPY_CLIENT_ID and secrets etc (creating my own credenials ofcourse.
got the latest spotipy-2.4.4
as the pip install/upgrade only install 2.0.5 for some reason.

but no luck so far. any other ideas?

Remove From Playlist Option Always Enabled

The code to Remove From Playlist is always enabled when the default for this is no. The older deprecated function 'queue_remove_from_playlist' in post_actions.py used to check the option and also checked if the playlist was owned by the loggedin user. The new function 'remove_tracks_from_playlist' needs to be modified to include these functions.

Any way to get rid of this crash code at the end?

So the good news is this script works just fine for most of the stuff I do, I don't have a particular need to remove things from my playlists after ripping them so I originally intended to leave that feature alone... But every time I try to rip something I always get this same error:

Exception in thread SpotifyRipperThread: Traceback (most recent call last): File "/Users/karibarry/.pyenv/versions/2.7.10/lib/python2.7/threading.py", line 810, in __bootstrap_inner self.run() File "/Users/karibarry/.pyenv/versions/2.7.10/lib/python2.7/site-packages/spotify_ripper/ripper.py", line 366, in run self.post.remove_tracks_from_playlist() File "/Users/karibarry/.pyenv/versions/2.7.10/lib/python2.7/site-packages/spotify_ripper/post_actions.py", line 287, in remove_tracks_from_playlist remove_all_from_playlist(ripper.session.user.canonical_name, ripper.playlist_uri) File "/Users/karibarry/.pyenv/versions/2.7.10/lib/python2.7/site-packages/spotify_ripper/remove_all_from_playlist.py", line 19, in remove_all_from_playlist tracks = get_playlist_tracks(username, playlistURI) File "/Users/karibarry/.pyenv/versions/2.7.10/lib/python2.7/site-packages/spotify_ripper/remove_all_from_playlist.py", line 31, in get_playlist_tracks p1, p2, p3, p4, rPlaylistID = playlistURI.split(':', 5) AttributeError: 'NoneType' object has no attribute 'split'

What does that mean exactly? Since then I've tried following your webAPI tutorial for setting up the feature that this links to anyway (remove_all_from_playlist) but there's been no changed result.

If nothing else I'd just like to hide the error since it isn't actually effecting anything.

-Cheers

Segfault: AttributeError: 'NoneType' object has no attribute 'split'

Hello, on the off chance that someone is still looking at this. I get this with every attempt to use spotify-ripper; the song downloads but corrupted, the file seems incomplete and there are no ID3 tags or album art. Any ideas?

Exception in thread SpotifyRipperThread:
Traceback (most recent call last):
  File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/home/marty/.local/lib/python3.6/site-packages/spotify_ripper/ripper.py", line 366, in run
    self.post.remove_tracks_from_playlist()
  File "/home/marty/.local/lib/python3.6/site-packages/spotify_ripper/post_actions.py", line 287, in remove_tracks_from_playlist
    remove_all_from_playlist(ripper.session.user.canonical_name, ripper.playlist_uri)
  File "/home/marty/.local/lib/python3.6/site-packages/spotify_ripper/remove_all_from_playlist.py", line 19, in remove_all_from_playlist
    tracks = get_playlist_tracks(username, playlistURI)
  File "/home/marty/.local/lib/python3.6/site-packages/spotify_ripper/remove_all_from_playlist.py", line 31, in get_playlist_tracks
    p1, p2, p3, p4, rPlaylistID = playlistURI.split(':', 5)
AttributeError: 'NoneType' object has no attribute 'split'

Segmentation fault

Up and running! Remember to completely clean out your .pyenv

(edit) I couldn't get this to work originally because it was being shortcircuited by hbashton's older version. I was able to get it to start working by rm -rf ing my .pyenv folder from my user directory and starting all over again.

I def recommend the pip install over the brew install, the only other working instance of spotifyripper I have used that and so does this current one.

Thanks for porting this over and keeping it current!

-Cheers

All songs deleted

I've tried this script and I'm happy because it works, but for some reasons it deleted all songs from my playlists, and it has not updated my local m3u playlist. I setted api credentials like in the README, but I have not setted the Remove From Playlist Option. For the songs is not a problem, I talked with customer service and was restored, but I don't really understand what happened.
I want the playlists updated like on Spotify. I need the web api key?
Is the --playlist-m3u parameter enough to update my local playlists?
Why my songs were deleted from my playlists? (I've seen a pull request about the Remove From Playlist Option)

Thank you

large-cover-art no longer works

large-cover-art no longer works,
the cover art is always in 300x300.
It used to work, so I suspect it has something to do with the web api policy change on 5/29.

Now I always get
"URL returned non-200 HTTP code: 401"
after
"Attempting to retrieve tracks from Spotify's Web API"
I suspect this is related to the cover art issue.

I have generated Web API tokens,
but how do I add them to make things work?

Playlist Cap from Spotify WebAPI

I've faced an issue: the WebAPI method of getting songs in a playlist only covers for the first hundred songs, after which, it no longer works for the remaining items in the playlist.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.