couldbejake / spotify2mp3

Simple free and unlimited Spotify playlist downloads. Spotify2mp3 - Spotify Downloader
MIT License
269 stars 42 forks source link

Add support for Liked songs, swap to Tekore client for Spotify #36

Closed CarvellWakeman closed 11 months ago

CarvellWakeman commented 11 months ago

Hey @couldbejake , I forked your repo to add support for downloading the user's spotify "liked songs". I plan to run this script on a cron job to keep a synced directory of my liked songs.

Wasn't really intending to submit this as a PR, which is why it contains so many unrelated changes. Feel free to leave a big list of suggestions, incorporate what you like (if anything), or ignore this unpolished PR :)

Changes:

couldbejake commented 11 months ago

I get:

Please provide a Spotify URL (right click, share, copy link):

> https://open.spotify.com/playlist/76iluwOVwnEWQ8SxJmNmwq?si=dbe7fa70715741da

Which quality would you like? (Options: low, medium, high, or specify bitrate): high

Chosen Settings

Playlist: https://open.spotify.com/playlist/76iluwOVwnEWQ8SxJmNmwq?si=dbe7fa70715741da
Song quality / bitrate: high / 160000 bps
Traceback (most recent call last):
  File "C:\Users\jakenelson\Downloads\spotify2mp3-main\spotify2mp3-main\spotify2mp3.py", line 172, in <module>
    main(playlist=url, quality=quality, min_views=DEFAULT_MIN_VIEWS_FOR_DOWNLOAD, max_length=DEFAULT_MAX_LENGTH_FOR_DOWNLOAD)
  File "C:\Users\jakenelson\Downloads\spotify2mp3-main\spotify2mp3-main\spotify2mp3.py", line 108, in main
    downloader = SpotifyDownloader(get_bitrate_from_quality(quality), max_length, min_views)
  File "C:\Users\jakenelson\Downloads\spotify2mp3-main\spotify2mp3-main\downloader.py", line 26, in __init__
    self.spotify_client = Spotify()
  File "C:\Users\jakenelson\Downloads\spotify2mp3-main\spotify2mp3-main\apis\spotify.py", line 17, in __init__
    user_token = self.get_stored_token()
  File "C:\Users\jakenelson\Downloads\spotify2mp3-main\spotify2mp3-main\apis\spotify.py", line 27, in get_stored_token
    refreshToken) = tk.config_from_file('tekore_cfg.ini', return_refresh=True)
  File "C:\Users\jakenelson\AppData\Local\Programs\Python\Python39\lib\site-packages\tekore\_config.py", line 146, in config_from_file
    c = _read_configfile(file_path)
  File "C:\Users\jakenelson\AppData\Local\Programs\Python\Python39\lib\site-packages\tekore\_config.py", line 100, in _read_configfile
    with open(file_path, "r") as f:
FileNotFoundError: [Errno 2] No such file or directory: 'tekore_cfg.ini'

The application needs the ability to download without logging in, as well as authenticated.

Regardless, thank you for your work.

CarvellWakeman commented 11 months ago

@couldbejake Alright, rewrote the login process completely. It can now do anonymous downloads or user login by the parameter --login.

In addition to the features in the PR, I've added these:

image image image image

couldbejake commented 11 months ago

The app looks brilliant so far.

The only changes I see:

I'm not asking you to implement, but we've had comments that the program should be able to download from YouTube music, I think this is the next milestone.

CarvellWakeman commented 11 months ago

Do you have an example playlist? I've seen that private playlists have &pt in the query params of the URL, but I was only checking for &. Fixed that. If your example public playlist has an & in the share URL that's probably why.

I missed a check for this when running from args vs interactive. Let me know if you have something else in mind than printing "Private Playlist" image

Added

Might be possible, I didn't see anything to help that process in Tekore library. With other services I've seen this app registration process occur between the tool and the service vendor, so the user doesn't have to perform that step. Maybe Spotify has something like that?

Oops, off by 1 :)

Removed. I think the youtube search code needs to be improved, I kept getting bad results for slightly less popular songs, so I added the URL to troubleshoot. Might be worth adding a Verbose flag and hide info behind it.

Removed

No problem! It was great to work on a lower stakes software project for a little bit. Thanks for making the project!

Youtube search improvement suggestions:

I might work on the above things in a separate MR at some point, calling this one done unless you have any other suggestions.

couldbejake commented 11 months ago

Brilliant, thanks @CarvellWakeman

It looks like we still have an issue regarding public playlists prompting auth, but it seems an easy fix.

Thank you so much for your contribution, I'm sure everyone will appreciate what you've added.

I will accept the PR tomorrow when I have a little time.

I hope we meet again!

Jake

couldbejake commented 11 months ago

Sorry for the delay everyone, I need some time to re-add the ability to download public playlists, albums.