Giter Site home page Giter Site logo

couldbejake / spotify2mp3 Goto Github PK

View Code? Open in Web Editor NEW
260.0 4.0 43.0 1.3 MB

Simple free and unlimited Spotify playlist downloads. Spotify2mp3 - Spotify Downloader

License: MIT License

Python 100.00%
spotify spotify-downloader pytube pytube3 download-music mp3 music python spotify-download spotify-download-music

spotify2mp3's Introduction




This project is currently inactive, and will not run without big changes to the code.



logo

Simple, free, and unlimited Spotify MP3 downloads

contributors forks stars open issues

🧰 Getting Started

‼️ Prerequisites

  1. Ideally use Python 3.8
  2. Install git.

🏃 Run Locally

Clone the project

$ git clone https://github.com/couldbejake/spotify2mp3.git

⚙️ Installation

Go to the project directory

$ cd spotify2mp3

Install packages using pip

$ pip install -r requirements.txt

Run the script

$ python spotify2mp3.py

Brew yourself a coffee, you deserved it!

If this project helped you, feel free to give us a star

Getting spotify playlist URL

Paste a Spotify Song, Playlist or Album URL into the program. You can also specify 'liked' to retrieve your liked songs.

To get the url:

  1. Right click on a Song, Playlist or Album
  2. Share
  3. Copy link

On mobile:

  1. Three dots
  2. Share
  3. Copy link

Troubleshooting

If you have any issues at all, please post a full log here

Support this project

"Buy Me A Coffee"

Coming soon

Documentation for the spotify2mp3 Python API.

spotify2mp3's People

Contributors

carvellwakeman avatar couldbejake avatar descent098 avatar dmaxence avatar fts18 avatar imaccia avatar secondary-smiles avatar snyk-bot 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

spotify2mp3's Issues

Error at the start of download

I have tried to download any playlist, but i always get this same error.
What should I do?

Traceback (most recent call last):
File "C:\Python310\lib\site-packages\pytube_main_.py", line 181, in fmt_streams
extract.apply_signature(stream_manifest, self.vid_info, self.js)
File "C:\Python310\lib\site-packages\pytube\extract.py", line 409, in apply_signature
cipher = Cipher(js=js)
File "C:\Python310\lib\site-packages\pytube\cipher.py", line 33, in init
raise RegexMatchError(
pytube.exceptions.RegexMatchError: init: could not find match for ^\w+\W

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "F:\test\spotify2mp3\run.py", line 276, in
main()
File "F:\test\spotify2mp3\run.py", line 270, in main
download_playlist(spotify_url_link, playlist_name)
File "F:\test\spotify2mp3\run.py", line 182, in download_playlist
yt_vid_obj = yt_dl_obj.streams.filter(only_audio=True).first()
File "C:\Python310\lib\site-packages\pytube_main_.py", line 296, in streams
return StreamQuery(self.fmt_streams)
File "C:\Python310\lib\site-packages\pytube_main_.py", line 188, in fmt_streams
extract.apply_signature(stream_manifest, self.vid_info, self.js)
File "C:\Python310\lib\site-packages\pytube\extract.py", line 409, in apply_signature
cipher = Cipher(js=js)
File "C:\Python310\lib\site-packages\pytube\cipher.py", line 33, in init
raise RegexMatchError(
pytube.exceptions.RegexMatchError: init: could not find match for ^\w+\W

List index out of range

when i put the url https://open.spotify.com/playlist/649OfpVgIVrppB0zRV7kAJ it showed the error list index out of range. and when i tried only putting the spotify playlist id 649OfpVgIVrppB0zRV7kAJ there was the same list index out of range error..

full error as follows :-
Enter the spotify URL link: https://open.spotify.com/playlist/649OfpVgIVrppB0zRV7kAJ Traceback (most recent call last): File "d:\Durgesh Files\Programming\spotify2mp3\spotify2mp3\run.py", line 296, in <module> main() File "d:\Durgesh Files\Programming\spotify2mp3\spotify2mp3\run.py", line 281, in main playlist_name = html.fromstring(page.content).xpath('/html/body/div/div/div/div/div[1]/div/div[2]/h1')[0].text_content().strip() IndexError: list index out of range

and when i tried putting only the id :-

Enter the spotify URL link: 649OfpVgIVrppB0zRV7kAJ Traceback (most recent call last): File "d:\Durgesh Files\Programming\spotify2mp3\spotify2mp3\run.py", line 296, in <module> main() File "d:\Durgesh Files\Programming\spotify2mp3\spotify2mp3\run.py", line 281, in main playlist_name = html.fromstring(page.content).xpath('/html/body/div/div/div/div/div[1]/div/div[2]/h1')[0].text_content().strip() IndexError: list index out of range

UnboundLocalError: local variable 'failed_song_names' referenced before assignment & Could not find playlist name please provide a name

Full Error As Follows

Enter the spotify URL link: https://open.spotify.com/playlist/649OfpVgIVrppB0zRV7kAJ?si=d0437a0d0962449d

Could not find playlist name please provide a name

Please open https://www.google.com/device and input code RPKM-CVMR
Press enter when you have completed this step.
HTTP Error 428: Precondition Required
Traceback (most recent call last):
File "D:\Durgesh Files\Programming\TESTS\spotify2mp3\run.py", line 176, in finalize_download
yt_vid_obj = yt_dl_obj.streams.filter(only_audio=True)
File "C:\Users\Durgesh\AppData\Local\Programs\Python\Python310\lib\site-packages\pytube_main_.py", line 296, in streams
return StreamQuery(self.fmt_streams)
File "C:\Users\Durgesh\AppData\Local\Programs\Python\Python310\lib\site-packages\pytube_main_.py", line 176, in fmt_streams
stream_manifest = extract.apply_descrambler(self.streaming_data)
File "C:\Users\Durgesh\AppData\Local\Programs\Python\Python310\lib\site-packages\pytube_main_.py", line 157, in streaming_data
if 'streamingData' in self.vid_info:
File "C:\Users\Durgesh\AppData\Local\Programs\Python\Python310\lib\site-packages\pytube_main_.py", line 246, in vid_info
innertube_response = innertube.player(self.video_id)
File "C:\Users\Durgesh\AppData\Local\Programs\Python\Python310\lib\site-packages\pytube\innertube.py", line 300, in player
return self._call_api(endpoint, query, self.base_data)
File "C:\Users\Durgesh\AppData\Local\Programs\Python\Python310\lib\site-packages\pytube\innertube.py", line 239, in _call_api
self.fetch_bearer_token()
File "C:\Users\Durgesh\AppData\Local\Programs\Python\Python310\lib\site-packages\pytube\innertube.py", line 187, in fetch_bearer_token
response = request._execute_request(
File "C:\Users\Durgesh\AppData\Local\Programs\Python\Python310\lib\site-packages\pytube\request.py", line 37, in _execute_request
return urlopen(request, timeout=timeout) # nosec
File "C:\Users\Durgesh\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 216, in urlopen
return opener.open(url, data, timeout)
File "C:\Users\Durgesh\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 525, in open
response = meth(req, response)
File "C:\Users\Durgesh\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 634, in http_response
response = self.parent.error(
File "C:\Users\Durgesh\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 563, in error
return self._call_chain(*args)
File "C:\Users\Durgesh\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 496, in _call_chain
result = func(*args)
File "C:\Users\Durgesh\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 643, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 428: Precondition Required

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "D:\Durgesh Files\Programming\TESTS\spotify2mp3\run.py", line 562, in
main()
File "D:\Durgesh Files\Programming\TESTS\spotify2mp3\run.py", line 546, in main
download_playlist(spotify_url_link, playlist_name, linkAdd, token)
File "D:\Durgesh Files\Programming\TESTS\spotify2mp3\run.py", line 423, in download_playlist
finalize_download(song, skipped_songs, failed_downloads, legal_path_characters, folder_name, spotify_playlist_id)
File "D:\Durgesh Files\Programming\TESTS\spotify2mp3\run.py", line 238, in finalize_download
failed_song_names = failed_song_names + "\t• " + song_name + " - " + artist + f" | Fail reason: {e}" + "\n"
UnboundLocalError: local variable 'failed_song_names' referenced before assignment

And Please make sure that this works with my playlist as well because when i entered my spotify playlist link that time it showed the error Could not find playlist name please provide a name

my spotify playlist link https://open.spotify.com/playlist/649OfpVgIVrppB0zRV7kAJ?si=17295df20e494ef7

Apart from views and Duration implement fuzzy match too

Hello, I like the idea of using spotify metadata to search for video on Youtube. Really neat concept. But it would be awesome if you add in fuzzy match too apart from duration and views constraint. You search for a spotify music title, if the first result video title and spotify video title fuzzy matches with more than 60% then download it, that way we can set duration and views won't matter.

Here is the tutorial that might help you.
https://towardsdatascience.com/fuzzy-string-matching-in-python-68f240d910fe

also it would be great if you use command line argument parser instead of using console input. Look into argparse

[Bug] I'm trying to use the script but facing bugs

I was trying to use the script to download a playlist and have configured everything.

CleanShot 2022-05-21 at 13 17 33@2x

I think the view count is being generated in UTF-8 unicode format (in this case: Bengali) from the localized version of Spotify website. The script is not being able to handle it.

Here's the error

Traceback (most recent call last): File "/Users/saif/Downloads/spotify2mp3/run.py", line 268, in <module> main() File "/Users/saif/Downloads/spotify2mp3/run.py", line 262, in main download_playlist(spotify_url_link, playlist_name) File "/Users/saif/Downloads/spotify2mp3/run.py", line 164, in download_playlist song_viewcount = int(yt_data['views'].split(' ')[0].replace(',', '')) ValueError: invalid literal for int() with base 10: '16992104টি'

Error when $ pip install -r requirements.txt

Collecting pytube (from -r requirements.txt (line 31))
Cloning https://github.com/abanand132/pytube.git (to revision master) to c:\users\snow\appdata\local\temp\pip-install-ltu0eo5l\pytube_5eb078e3107243139596b8ec38dd9aa0
Running command git clone --filter=blob:none --quiet https://github.com/abanand132/pytube.git 'C:\Users\Snow\AppData\Local\Temp\pip-install-ltu0eo5l\pytube_5eb078e3107243139596b8ec38dd9aa0'
fatal: unable to access 'https://github.com/abanand132/pytube.git/': Recv failure: Connection was reset
error: subprocess-exited-with-error

× git clone --filter=blob:none --quiet https://github.com/abanand132/pytube.git 'C:\Users\Snow\AppData\Local\Temp\pip-install-ltu0eo5l\pytube_5eb078e3107243139596b8ec38dd9aa0' did not run successfully.
│ exit code: 128
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× git clone --filter=blob:none --quiet https://github.com/abanand132/pytube.git 'C:\Users\Snow\AppData\Local\Temp\pip-install-ltu0eo5l\pytube_5eb078e3107243139596b8ec38dd9aa0' did not run successfully.
│ exit code: 128
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

[notice] A new release of pip is available: 23.2.1 -> 23.3.1
[notice] To update, run: python.exe -m pip install --upgrade pip

list index

list index out of range
Traceback (most recent call last):
  File "/Users/xxx/spotify2mp3/run.py", line 158, in download_playlist
    yt_data = json.loads(ya_results)['videos'][0]
IndexError: list index out of range

after 30 songs was aborted, with this code

The app does not work

After I enter the album link, this appears.

 Enter the spotify URL link: https://open.spotify.com/album/3HUbOOeUBHI0IiVllK9wHD?si=bGk371qwRlKBg0sCcYTHIw
Traceback (most recent call last):
  File "run.py", line 285, in <module>
    main()
  File "run.py", line 270, in main
    playlist_name = html.fromstring(page.content).xpath('/html/body/div/div/div/div/div[1]/div/div[2]/h1')[0].text_content().strip()
IndexError: list index out of range

requirements.txt

Any reason for not having a requirements.txt?

This is the one I've created as part of the install process
beautifulsoup4==4.11.1 bs4==0.0.1 certifi==2021.10.8 charset-normalizer==2.0.12 coverage==5.5 decorator==4.4.2 deprecation==2.1.0 eyed3==0.9.6 filetype==1.0.13 idna==3.3 imageio==2.19.2 imageio-ffmpeg==0.4.7 moviepy==1.0.3 numpy==1.22.3 packaging==21.3 Pillow==9.1.1 proglog==0.1.10 pyparsing==3.0.9 pytube==12.1.0 requests==2.27.1 soupsieve==2.3.2.post1 toml==0.10.2 tqdm==4.64.0 urllib3==1.26.9 youtube-search==2.1.0

Error

ali@DESKTOP-MOIQDK7 MINGW64 ~/spotify2mp3 (main)
$ python spotify2mp3.py
Traceback (most recent call last):
File "spotify2mp3.py", line 202, in
utils.print_splash_screen()
File "C:\Users\ali\spotify2mp3\utils.py", line 18, in print_splash_screen
print(colours.SPOTIFYGREEN + '''
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 51-65: character maps to

ali@DESKTOP-MOIQDK7 MINGW64 ~/spotify2mp3 (main)
$ python --version
Python 3.8.10

KeyError: 'streamingdata'

  • Downloading, please wait
    Traceback (most recent call last):
    File "spotify2mp3.py", line 206, in
    main(authtype=authtype, song=url, quality=quality, min_views=DEFAULT_MIN_VIEWS_FOR_DOWNLOAD, max_length=DEFAULT_MAX_LENGTH_FOR_DOWNLOAD)
    File "spotify2mp3.py", line 164, in main
    success = downloader.download_track(song)
    File "/home/adachi/spotify2mp3/downloader.py", line 189, in download_track
    video_downloaded_path, self.audio_quality = self.youtube_client.download(youtube_link, self.audio_quality)
    File "/home/adachi/spotify2mp3/apis/youtube.py", line 57, in download
    youtube_video_streams = youtube_video.streams.filter(only_audio=True)
    File "/home/adachi/.local/lib/python3.8/site-packages/pytube/main.py", line 296, in streams
    return StreamQuery(self.fmt_streams)
    File "/home/adachi/.local/lib/python3.8/site-packages/pytube/main.py", line 176, in fmt_streams
    stream_manifest = extract.apply_descrambler(self.streaming_data)
    File "/home/adachi/.local/lib/python3.8/site-packages/pytube/main.py", line 161, in streaming_data
    return self.vid_info['streamingData']
    KeyError: 'streamingData'

Index out of bounds error due to missing album cover

First of all thank you very much for such an amazing tool, it has been a great help in preserving my collection.
I copied all my library into 100 song playlists for downloading, in order to stop using Spotify. Cheers.

Two of my songs are missing album art on Spotify, I'm not sure how that happened. I assume it broke some terms and so was removed by Spotify (because I know it is a requirement of submission). In any case, this caused a null exception which was easy enough to identify and remedy. Here is the exception for reference:

Traceback (most recent call last):
File "/home/anon/spotify2mp3/spotify2mp3.py", line 164, in
main(playlist=url, quality=quality, min_views=DEFAULT_MIN_VIEWS_FOR_DOWNLOAD, max_length=DEFAULT_MAX_LENGTH_FOR_DOWNLOAD)
File "/home/anon/spotify2mp3/spotify2mp3.py", line 110, in main
success =downloader.download_playlist(playlist)
File "/home/anon/spotify2mp3/downloader.py", line 75, in download_playlist
self.prep_folder("downloads/playlists/" + playlist.get_title(True))
File "/home/anon/spotify2mp3/apis/spotify.py", line 133, in get_title
self.load_metadata()
File "/home/anon/spotify2mp3/apis/spotify.py", line 113, in load_metadata
this_track.load_metadata(track["track"])
File "/home/anon/spotify2mp3/apis/spotify.py", line 304, in load_metadata
"image_url": album_images[0].get("url", const.UNKNOWN_ALBUM_COVER_URL),
IndexError: list index out of range

How does this application work?

I'm trying to understand. Does this app take the Spotify link you input and then search YouTube for the song(s) and download them from there?

I apologize if this isn't the place for this question. I didn't know where else to ask.

Parsing issue from html

This is the Stack Trace of error

Traceback (most recent call last):
  File "run.py", line 296, in <module>
    main()
  File "run.py", line 281, in main
    playlist_name = html.fromstring(page.content).xpath('/html/body/div/div/div/div/div[1]/div/div[2]/h1')[0].text_content().strip()
IndexError: list index out of range

Error while installing requirements

Python version: 3.12
Elevated powershell: pip3 install -r requirements.txt

Collecting beautifulsoup4==4.11.1 (from -r requirements.txt (line 1))
  Using cached beautifulsoup4-4.11.1-py3-none-any.whl (128 kB)
Collecting bs4==0.0.1 (from -r requirements.txt (line 2))
  Using cached bs4-0.0.1.tar.gz (1.1 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting certifi==2021.10.8 (from -r requirements.txt (line 3))
  Using cached certifi-2021.10.8-py2.py3-none-any.whl (149 kB)
Collecting charset-normalizer==2.0.12 (from -r requirements.txt (line 4))
  Using cached charset_normalizer-2.0.12-py3-none-any.whl (39 kB)
Collecting coverage==5.5 (from -r requirements.txt (line 5))
  Using cached coverage-5.5.tar.gz (691 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting decorator==4.4.2 (from -r requirements.txt (line 6))
  Using cached decorator-4.4.2-py2.py3-none-any.whl (9.2 kB)
Collecting deprecation==2.1.0 (from -r requirements.txt (line 7))
  Using cached deprecation-2.1.0-py2.py3-none-any.whl (11 kB)
Collecting eyed3==0.9.6 (from -r requirements.txt (line 8))
  Using cached eyeD3-0.9.6-py3-none-any.whl (245 kB)
Collecting filetype==1.0.13 (from -r requirements.txt (line 9))
  Using cached filetype-1.0.13-py2.py3-none-any.whl (17 kB)
Collecting idna==3.3 (from -r requirements.txt (line 10))
  Using cached idna-3.3-py3-none-any.whl (61 kB)
Collecting imageio==2.19.2 (from -r requirements.txt (line 11))
  Using cached imageio-2.19.2-py3-none-any.whl (3.4 MB)
Collecting imageio-ffmpeg==0.4.7 (from -r requirements.txt (line 12))
  Using cached imageio_ffmpeg-0.4.7-py3-none-win_amd64.whl (22.6 MB)
Collecting moviepy==1.0.3 (from -r requirements.txt (line 13))
  Using cached moviepy-1.0.3.tar.gz (388 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting numpy==1.22.3 (from -r requirements.txt (line 14))
  Using cached numpy-1.22.3.zip (11.5 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error

  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [33 lines of output]
      Traceback (most recent call last):
        File "C:\Users\akitake\AppData\Local\Programs\Python\Python312\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
          main()
        File "C:\Users\akitake\AppData\Local\Programs\Python\Python312\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\akitake\AppData\Local\Programs\Python\Python312\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 112, in get_requires_for_build_wheel
          backend = _build_backend()
                    ^^^^^^^^^^^^^^^^
        File "C:\Users\akitake\AppData\Local\Programs\Python\Python312\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 77, in _build_backend
          obj = import_module(mod_path)
                ^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\akitake\AppData\Local\Programs\Python\Python312\Lib\importlib\__init__.py", line 90, in import_module
          return _bootstrap._gcd_import(name[level:], package, level)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "<frozen importlib._bootstrap>", line 1293, in _gcd_import
        File "<frozen importlib._bootstrap>", line 1266, in _find_and_load
        File "<frozen importlib._bootstrap>", line 1216, in _find_and_load_unlocked
        File "<frozen importlib._bootstrap>", line 400, in _call_with_frames_removed
        File "<frozen importlib._bootstrap>", line 1293, in _gcd_import
        File "<frozen importlib._bootstrap>", line 1266, in _find_and_load
        File "<frozen importlib._bootstrap>", line 1237, in _find_and_load_unlocked
        File "<frozen importlib._bootstrap>", line 841, in _load_unlocked
        File "<frozen importlib._bootstrap_external>", line 994, in exec_module
        File "<frozen importlib._bootstrap>", line 400, in _call_with_frames_removed
        File "C:\Users\akitake\AppData\Local\Temp\pip-build-env-nkpz_tt3\overlay\Lib\site-packages\setuptools\__init__.py", line 16, in <module>
          import setuptools.version
        File "C:\Users\akitake\AppData\Local\Temp\pip-build-env-nkpz_tt3\overlay\Lib\site-packages\setuptools\version.py", line 1, in <module>
          import pkg_resources
        File "C:\Users\akitake\AppData\Local\Temp\pip-build-env-nkpz_tt3\overlay\Lib\site-packages\pkg_resources\__init__.py", line 2172, in <module>
          register_finder(pkgutil.ImpImporter, find_on_path)
                          ^^^^^^^^^^^^^^^^^^^
      AttributeError: module 'pkgutil' has no attribute 'ImpImporter'. Did you mean: 'zipimporter'?
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

Git bash issue

(Name of my computer) MINGW64 ~/spotify2mp3 (main)
$ python spotify2mp3.py
Traceback (most recent call last):
  File "C:\Users\Assayes2.0\spotify2mp3\spotify2mp3.py", line 202, in <module>
    utils.print_splash_screen()
  File "C:\Users\Assayes2.0\spotify2mp3\utils.py", line 18, in print_splash_screen
    print(colours.SPOTIFYGREEN + '''
  File "C:\Python312\Lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeEncodeError: 'charmap' codec can't encode characters in position 51-65: character maps to <undefined>

my python is updated

Single Song

While im adding a single song in my playlist and trying to download it, it downloads another song from the album putting the name of the song that i was about to download. Why?

Example:

Link => A-song
Downloaded Song => audio[B-song] with name[A-song]

Error when downloading a playlist

Hi, good day! I'm receiving this error when I tried to download a playlist from Spotify.
Tried searching for any fix to this but couldn't. Tried 2 more playlists with the same error.


Searching for song: The Most Beautiful Thing by Bruno Major
   - Downloading the song, please wait
Traceback (most recent call last):
  File "spotify2mp3.py", line 164, in <module>
    main(playlist=url, quality=quality, min_views=DEFAULT_MIN_VIEWS_FOR_DOWNLOAD, max_length=DEFAULT_MAX_LENGTH_FOR_DOWNLOAD)
  File "spotify2mp3.py", line 110, in main
    success =downloader.download_playlist(playlist)
  File "C:\Users\gbrls\Documents\Spotify Downloader\spotify2mp3\downloader.py", line 91, in download_playlist
    self.download_track(None, track, "downloads/playlists/" + playlist.get_title(True) + "/", True)
  File "C:\Users\gbrls\Documents\Spotify Downloader\spotify2mp3\downloader.py", line 150, in download_track
    video_downloaded_path, self.audio_quality = self.youtube_client.download(youtube_link, self.audio_quality)
  File "C:\Users\gbrls\Documents\Spotify Downloader\spotify2mp3\apis\youtube.py", line 41, in download
    youtube_video_streams = youtube_video.streams.filter(only_audio=True)
  File "C:\Users\gbrls\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\pytube\__main__.py", line 296, in streams
    return StreamQuery(self.fmt_streams)
  File "C:\Users\gbrls\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\pytube\__main__.py", line 176, in fmt_streams
    stream_manifest = extract.apply_descrambler(self.streaming_data)
  File "C:\Users\gbrls\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\pytube\__main__.py", line 160, in streaming_data
    self.bypass_age_gate()
  File "C:\Users\gbrls\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\pytube\__main__.py", line 264, in bypass_age_gate
    raise exceptions.AgeRestrictedError(self.video_id)
pytube.exceptions.AgeRestrictedError: 1nml-_YE2OU is age restricted, and can't be accessed without logging in.


Python version: 3.8.10 (Was having installation issues with 3.11, so I downgraded to 3.8)
Possible Issue: pytube.exceptions.AgeRestrictedError: 1nml-_YE2OU is age restricted, and can't be accessed without logging in.

Affected Songs in 3 Different Playlists:

  • The Most Beautiful Thing by Bruno Major
  • Dance The Night - From Barbie The Album by Dua Lipa
  • Put My Hands On You by DEAN Anderson .Paak

Thanks for the awesome work!

no idea what to do. on a Mac

here is the fail log

Good Good Things Descendents
[Errno 2] No such file or directory: '/usr/bin/ffmpeg'
Traceback (most recent call last):
File "/Users/elijahprovis/Documents/spotify2mp3-main/run.py", line 198, in download_playlist
clip = AudioFileClip(yt_tmp_out)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/moviepy/audio/io/AudioFileClip.py", line 70, in init
self.reader = FFMPEG_AudioReader(filename, fps=fps, nbytes=nbytes,
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/moviepy/audio/io/readers.py", line 51, in init
infos = ffmpeg_parse_infos(filename)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/moviepy/video/io/ffmpeg_reader.py", line 257, in ffmpeg_parse_infos
proc = sp.Popen(cmd, **popen_params)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 951, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 1821, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/usr/bin/ffmpeg'

Debian Linux conda Python 3.11 issues and missing inport os issue

FYI - In case it helps. This relates to install issues I had using a conda environment on Debian Linux - Tried with Python 3.11 environment. However, had all sort of issues with pip install requirements.txt failing -

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for lxml
  Running setup.py clean for lxml
  Building wheel for python-Levenshtein (setup.py) ... done
  Created wheel for python-Levenshtein: filename=python_Levenshtein-0.12.2-cp311-cp311-linux_x86_64.whl size=79926 sha256=e69a83d9feb6068b08c36444b35be3d8cd453fe2af27429ec506f507bc4a4ffd
  Stored in directory: .../.cache/pip/wheels/08/39/17/367da5b72aee88c27ba574660010188efcad074dc4d02060ed
Successfully built bs4 coverage moviepy numpy python-Levenshtein
Failed to build Pillow lxml
ERROR: Could not build wheels for Pillow, lxml, which is required to install pyproject.toml-based projects

Changed conda environment to Python 3.10.9 and all requirements installed without a problem. However, I still needed to add import os to the imports in const.py - otherwise it would not run. Here is the error -

# python spotify2mp3.py
Traceback (most recent call last):
  File "/spotify2mp3/spotify2mp3.py", line 10, in <module>
    import utils
  File "/spotify2mp3/utils.py", line 1, in <module>
    from const import colours, BASE62
  File "/spotify2mp3/const.py", line 11, in <module>
    class colours:
  File "/spotify2mp3/const.py", line 25, in colours
    SPOTIFYGREEN = '\033[38;2;30;215;96m' if supports_24bit_color() else '\033[92m'
  File "/spotify2mp3/const.py", line 7, in supports_24bit_color
    return os.getenv("COLORTERM") == "truecolor"
NameError: name 'os' is not defined
  • adding import os to const.py fixed this

Error running python script

I am using Linux Mint 20.03 cinnamon.
I installed the requirements and when I run the spotify2mp2.py script I received the the following error message:
File "spotify2mp3.py", line 38
raise argparse.ArgumentTypeError(f"Bitrate outside of typical YouTube range (64 kbps to 320 kbps): {quality}")
^
SyntaxError: invalid syntax

Update: I changed the command from "python spotify2mp3.py" to "python3 spotify2mp3.py" and that seems to work. Now when I enter a spotify link, it tells me that the link is not valid.

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

https://open.spotify.com/episode/6VzFDErBqgeSShBJIQkWq6?si=vp2KgOGQToaCnEmGx_r4uA

Error:Invalid Spotify URL: https://open.spotify.com/episode/6VzFDErBqgeSShBJIQkWq6?si=vp2KgOGQToaCnEmGx_r4uA

minimum view count

Hi all,
Your program is working really nice, thanks.
However, how do I get around this notification:
Skipped a song - The found song had less views than the minimum view count, (use the cli to increase this).
and this one:
[View count 5676 does not meet MIN_VIEW_COUNT value of 10000 [a-youtube-url-comes-her]]

Many thanks,
Jurgen

[BUG]

After yesterday's fixes, I tried today again but facing this issue after running the script

`View Count: 1,70,10,808টি ভিউ
Duration: 3:42

Traceback (most recent call last):
File "/Users/saif/Downloads/spotify2mp3/run.py", line 276, in
main()
File "/Users/saif/Downloads/spotify2mp3/run.py", line 270, in main
download_playlist(spotify_url_link, playlist_name)
File "/Users/saif/Downloads/spotify2mp3/run.py", line 182, in download_playlist
yt_vid_obj = yt_dl_obj.streams.filter(only_audio=True).first()
File "/opt/homebrew/lib/python3.9/site-packages/pytube/main.py", line 295, in streams
self.check_availability()
File "/opt/homebrew/lib/python3.9/site-packages/pytube/main.py", line 210, in check_availability
status, messages = extract.playability_status(self.watch_html)
File "/opt/homebrew/lib/python3.9/site-packages/pytube/main.py", line 102, in watch_html
self._watch_html = request.get(url=self.watch_url)
File "/opt/homebrew/lib/python3.9/site-packages/pytube/request.py", line 53, in get
response = _execute_request(url, headers=extra_headers, timeout=timeout)
File "/opt/homebrew/lib/python3.9/site-packages/pytube/request.py", line 37, in _execute_request
return urlopen(request, timeout=timeout) # nosec
File "/opt/homebrew/Cellar/[email protected]/3.9.12_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 214, in urlopen
return opener.open(url, data, timeout)
File "/opt/homebrew/Cellar/[email protected]/3.9.12_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 523, in open
response = meth(req, response)
File "/opt/homebrew/Cellar/[email protected]/3.9.12_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 632, in http_response
response = self.parent.error(
File "/opt/homebrew/Cellar/[email protected]/3.9.12_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 561, in error
return self._call_chain(*args)
File "/opt/homebrew/Cellar/[email protected]/3.9.12_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 494, in _call_chain
result = func(*args)
File "/opt/homebrew/Cellar/[email protected]/3.9.12_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 641, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 429: Too Many Requests`

more resilient code for trying to convert with int()

the line for getting "song_viewcount" can fail if yt_data['views'] contains the string "No views", a simple fix for this is

                sd_data = yt_data['duration'].split(':')
                try:
                    song_duration = int(sd_data[0]) * 60  + int(sd_data[1])
                except ValueError:
                    print(f"Song duration unavailable, got string {yt_data['duration']}")

                try:
                    song_viewcount = int(re.sub('[^0-9]','', yt_data['views']))
                except ValueError:
                    print(f"Song viewcount unavailable, got string {yt_data['views']}")

a recent example of this is "Larina Sin Valor", the 10th song in https://open.spotify.com/playlist/37i9dQZF1DWWQRwui0ExPn
unless of course someone has viewed it once by now

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.