Giter Site home page Giter Site logo

devlocalhost / pyspodl Goto Github PK

View Code? Open in Web Editor NEW
7.0 2.0 1.0 2.51 MB

pyspodl - a spotify downloader using librespot

License: MIT License

Python 100.00%
spotify songs playlists music music-downloader playlist-downloader spotify-api librespot librespot-python python3

pyspodl's Introduction

pyspodl - a spotify downloader using librespot

using the module librespot-python by kokarare1212

important

I may not work on pyspodl anymore. I dont want to work on this program anymore, im just tired of it. So please do not expect any new features. I will of course update the program if a bug or problem is found, I just will not add any features. Feel free to fork and add your own features

What is different from other downloaders?

Well, maybe nothing. pyspodl can only do these things: download tracks, albums and playlists in "high" (non-premium) and "very high" (premium account required) quality. It downloads them from Spotify, it does not use another source like some other programs do.

how to use

Requirements: python3, git. Make sure you have those and a linux PC/environment, then

  • Create an application from spotify dashboard, and copy the client ID and secret
  • Run this command: git clone https://github.com/devlocalhost/pyspodl
  • Paste the client id and secret into the config file, inside the "pyspodl" directory.
  • Run pip3 install git+https://github.com/kokarare1212/librespot-python.
  • You will also need Pillow for the album cover, mutagen for tags, and toml to read the config file: pip3 install Pillow mutagen toml.
  • Now you can use pyspodl like this: python3 pyspodl

examples

python pyspodl -l LINK

python pyspodl -l "LINK1 LINK2 LINK3"

python pyspodl -l ... -c /path/to/config.file

Or, check python -h

updating pyspodl

When there's a new update, you can simply run git pull in the directory where you cloned pyspodl.

the config file

Before you start using pyspodl, you need to fill out the config file.

config entries

  • email: your account email
  • password: your accounts password
  • token: used to send request to spotify api. you do not need to touch this.
  • client_id: used to get the token
  • client_secret: used to get the token
  • timeout: tells the program to wait x seconds before downloading the next song from a playlist or album (to avoid account bans, but I never had an account get banned by using my program).
  • premium_downloads: download tracks in higher quality. only for premium accounts.
  • download_path: the path to download the tracks
  • set_metadata: set tags for the tracks
  • track_format: the format the tracks will be saved in. check the config file for possible entries

config example

[account]
email = "" # your accounts email
password = "" # the password
token = "" # used to communicate with spotify api
client_id = "" # used to get the token
client_secret = "" # same thing as above

[downloading]
timeout = 2 # in seconds
premium_downloads = false # can be false or true
download_path = "" # download path for the tracks
set_metadata = true # can be false or true
track_format = "{artist}/{album}/{title}" # can be: artist, album, title, tracknumber, year
# the above format will save a song like this: download_path/Nas/Illmatic/The World Is Yours.ogg
#                                                         artist    album              title

help

Feel free to fork or make PR's (pull requests). If you're forking, please leave this repos link in your readme and kokarare1212's module repo link. If you have any problems/want to report a bug or request a feature, open an issue

pyspodl's People

Contributors

devlocalhost avatar skyblueborb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

skyblueborb

pyspodl's Issues

Bug: randomly failing while downloading a playlists

I am not sure what causes this issue and why. It's not a token issue, or auth issue. But, it could be "offset/limit" (line 366)

This is what "print(tracks)" (line 371) gives, which is not supposed to give that

{'added_at': '2022-05-07T23:02:21Z',
 'added_by': {'external_urls': {'spotify': 'https://open.spotify.com/user/3zgl6uyvesfl7j2mksnvm3zqh'},
              'href': 'https://api.spotify.com/v1/users/3zgl6uyvesfl7j2mksnvm3zqh',
              'id': '3zgl6uyvesfl7j2mksnvm3zqh',
              'type': 'user',
              'uri': 'spotify:user:3zgl6uyvesfl7j2mksnvm3zqh'},
 'is_local': False,
 'primary_color': None,
 'track': None,
 'video_thumbnail': None}

[Program finished]

It also fails with:
Screenshot_20220807-030058

set_metadata function randomly breaking

mutagen.oggvorbis.OggVorbisHeaderError: unable to read full header; got b'\x00'

In a email I sent,

"And yes, I'm aware of that issue. The set_metadata function is kinda broken. It works, but also breaks, and I am not really sure why. I suspect it might be because of the extension.

The library I'm using to download the track, librespot, downloads the track as a OGG Vorbis file (if you use mpv, press "i"), not as a mp3 file. The extension of the track should not be .mp3, but .ogg instead

The reason I am not using the ogg extension, is because I am not sure if media players are going to play ogg files (well, they should), since mp3 is more common than ogg

A fix to this issue is converting the ogg file to a mp3 one, but that will probably require another module, and it could take some time converting it, so I choose to stick with mp3 extension (that doesn't make it a mp3 file! It's still a ogg file)"

To the people using pyspodl, if this affects your usage (keeps failing/erroring, etc) do the following:

  1. Delete the entire set_metadata function (if you want, it's up to you)
  2. Delete the line no. 366, 420, and 464 (or, comment these lines by adding a hashtag Infront of them)

gettoken fails: error invalid_client

Response from the spotify API is

{'error': 'invalid_client', 'error_description': 'Invalid client'}

I have registered a new app in my premium account. Does pyspodl still work?

Private playlist download error

thanks for script. all good in download song function, but playlist download wont work here.

Traceback (most recent call last):
File "/Users/myuser/Downloads/pyspodl-main/main.py", line 424, in
main()
File "/Users/myuser/Downloads/pyspodl-main/main.py", line 341, in main
isvalid(TOKEN)
File "/Users/myuser/Downloads/pyspodl-main/main.py", line 82, in isvalid
main()
File "/Users/myuser/Downloads/pyspodl-main/main.py", line 358, in main
downloader(uri, EMAIL, PASSWD, TOKEN)
File "/Users/myuser/Downloads/pyspodl-main/main.py", line 305, in downloader
main()
File "/Users/myuser/Downloads/pyspodl-main/main.py", line 388, in main
playlist_download(playid, TOKEN, EMAIL, PASSWD)
File "/Users/myuser/Downloads/pyspodl-main/main.py", line 233, in playlist_download
target = info['tracks']['total']
KeyError: 'tracks'

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.