radujica / tospotify Goto Github PK
View Code? Open in Web Editor NEWUtility to parse m3u local playlists and add to Spotify
License: GNU General Public License v3.0
Utility to parse m3u local playlists and add to Spotify
License: GNU General Public License v3.0
Hi, I have seen a closed ticket on that topic but would like to raise the same issue.
I am getting the same error: Illegal redirect_uri
This message appears in my browser after I run the command (python -m tospotify "my_spotify_email" "playlist_path.m3u").
I have tried different URIs (http://localhost:8080/; http://localhost:8080; http://localhost:8888/; ...).
Of course setting it up in both the spotify dev dashboard and with "set SPOTIPY_REDIRECT_URI" but still getting that error.
Even with --verbose active and everything setup there is no Output in the Terminal.
It just does nothing. Everything is set up as explained but the Terminal stays empty.
I think it is related to the redirect with locahost:8888.
Im running on a qnap nas directly in the admin terminal..
Sorry if it is my fault, it is the first time I am using Python... But I always get the following error "Illegal redirect_uri". I am using
the default redirect uri: http://localhost:8888/. What can be wrong?
Thank you very much!
Hi there, does this error mean it couldn't find any tracks on Spotify corresponding to those in the playlist? Seems weird and I get the same error for all my playlists (50-100 songs in each).
Double-check if any other relevant args from spotipy could be added.
Ubuntu 22.04
Python 3.10.12
INFO:root:Created playlist with name=Test at id=4rkgtHurcTnsGjp7lHNFMr
Traceback (most recent call last):
File "/usr/local/bin/tospotify", line 8, in
sys.exit(main())
File "/home/serenity/.local/lib/python3.10/site-packages/tospotify/run.py", line 87, in main
update_spotify_playlist(spot, playlist_path, playlist_id, args.convert)
File "/home/serenity/.local/lib/python3.10/site-packages/tospotify/search.py", line 120, in update_spotify_playlist
songs = parse_songs(playlist_path)
File "/home/serenity/.local/lib/python3.10/site-packages/tospotify/parser.py", line 33, in parse_songs
playlist = m3u8.load(playlist_path)
File "/home/serenity/.local/lib/python3.10/site-packages/m3u8/init.py", line 49, in load
return _load_from_file(uri, custom_tags_parser)
File "/home/serenity/.local/lib/python3.10/site-packages/m3u8/init.py", line 56, in _load_from_file
return M3U8(raw_content, base_uri=base_uri, custom_tags_parser=custom_tags_parser)
File "/home/serenity/.local/lib/python3.10/site-packages/m3u8/model.py", line 153, in init
self.data = parse(content, strict, custom_tags_parser)
File "/home/serenity/.local/lib/python3.10/site-packages/m3u8/parser.py", line 143, in parse
_parse_extinf(line, data, state, lineno, strict)
File "/home/serenity/.local/lib/python3.10/site-packages/m3u8/parser.py", line 261, in _parse_extinf
state['segment']['duration'] = float(duration)
ValueError: could not convert string to float: ''
If it actually works now, remove the note from the README. If not, give it another shot.
Hi, I tried to use the tool, did the required steps:
set SPOTIPY_CLIENT_ID="my client id"
set SPOTIPY_CLIENT_SECRET="my client secret"
set SPOTIPY_REDIRECT_URI="http://localhost:8888/callback/"
But when I try this code:
python -m tospotify "11153396121" "C:/Users/Desktop/playlist.m3u8"
It opens this page:
And says:
Illegal redirect_uri
And after that it asks me to copy paste the url that I got and i get into a loop.
And if I try this one:
tospotify [-h] [--verbose] [--public] [--convert] [--playlist-id 4BcjgCsCGScaUO3RMNm7lA] "11153396121" "C:\Users\user\Desktop\playlist.m3u8"
I get the following message:
C:\Users\user>tospotify [-h] [--verbose] [--public] [--convert] [--playlist-id 4BcjgCsCGScaUO3RMNm7lA] "11153396121" "C:\Users\user\Desktop\playlist.m3u8"
usage: tospotify [-h] [--verbose] [--public] [--convert] [--playlist-id PLAYLIST_ID] spotify_username playlist_path
tospotify: error: argument playlist_path: Could not determine file extension
What can I do to import my 1600 piece playlist to spotify?
set SPOTIPY_CLIENT_ID=""
set SPOTIPY_CLIENT_SECRET=""
set SPOTIPY_REDIRECT_URI="http://127.0.0.1/callback"
python -m tospotify ="*********************************"mp3tag2.m3u
url shows "Illegal redirect_uri" but booth urls are equal (the app in spotify and the env variable).
raise SpotifyOauthError(
spotipy.oauth2.SpotifyOauthError: error: invalid_request, error_description: code must be supplied
What am i doing wrong?
As triggered by #20, it seems that newer m3u8 versions handle paths differently in >3.4.0.
Latest m3u8 internally uses urllib.parse.urlsplit(uri).scheme
. While related issue should work with this, what if tospotify
also supported web uri? It should work out of the box with m3u8.
Try it out.
# Given pwd is HOME
tospotify --public --playlist-id 76EnUBXM3JIGN9L9YbXleN 1274469315 "C:\MEGA\Music\Jafet Meza\Halo\SPV3\mp3tag.m3u8"
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "C:\Users\Noah\AppData\Roaming\Python\Python312\Scripts\tospotify.exe\__main__.py", line 7, in <module>
File "C:\Users\Noah\AppData\Roaming\Python\Python312\site-packages\tospotify\run.py", line 87, in main
update_spotify_playlist(spot, playlist_path, playlist_id, args.convert)
File "C:\Users\Noah\AppData\Roaming\Python\Python312\site-packages\tospotify\search.py", line 120, in update_spotify_playlist
songs = parse_songs(playlist_path)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Noah\AppData\Roaming\Python\Python312\site-packages\tospotify\parser.py", line 33, in parse_songs
playlist = m3u8.load(playlist_path)
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Noah\AppData\Roaming\Python\Python312\site-packages\m3u8\__init__.py", line 49, in load
return _load_from_file(uri, custom_tags_parser)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Noah\AppData\Roaming\Python\Python312\site-packages\m3u8\__init__.py", line 53, in _load_from_file
with open(uri, encoding='utf8') as fileobj:
^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\Noah\\MEGA\\Music\\Jafet Meza\\Halo\\SPV3\\mp3tag.m3u8'
Hello I get this error on windows or debian.
user@DESKTOP-H87NGVR:/mnt/c/Users/user/Desktop/toSpotify$ tospotify 1167047623 mp3tag2.m3u
Traceback (most recent call last):
File "/home/user/.local/bin/tospotify", line 10, in
sys.exit(main())
File "/home/user/.local/lib/python3.7/site-packages/tospotify/run.py", line 87, in main
update_spotify_playlist(spot, playlist_path, playlist_id, args.convert)
File "/home/user/.local/lib/python3.7/site-packages/tospotify/search.py", line 120, in update_spotify_playlist
songs = parse_songs(playlist_path)
File "/home/user/.local/lib/python3.7/site-packages/tospotify/parser.py", line 33, in parse_songs
playlist = m3u8.load(playlist_path)
File "/home/user/.local/lib/python3.7/site-packages/m3u8/init.py", line 49, in load
return _load_from_file(uri, custom_tags_parser)
File "/home/user/.local/lib/python3.7/site-packages/m3u8/init.py", line 54, in _load_from_file
raw_content = fileobj.read().strip()
File "/usr/lib/python3.7/codecs.py", line 322, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe3 in position 3815: invalid continuation byte
prompt_for_user_token
is deprecated; need to upgrade to latest usage
Is this still working? I am getting errors when trying the valid_playlist.m3u file. I tried using tospotify 0.3.1 on Windows 10 with Python 3.6.0, 3.10.4 and 3.12.0. Here is the output.
Python 3.10.4
tospotify 0.3.1
INFO:root:Created playlist with name=valid_playlist at id=REDACTED
Traceback (most recent call last):
File "C:\Users\REDACTED\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\REDACTED\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Users\REDACTED\AppData\Local\Programs\Python\Python310\Scripts\tospotify.exe\__main__.py", line 7, in <module>
File "C:\Users\REDACTED\AppData\Local\Programs\Python\Python310\lib\site-packages\tospotify\run.py", line 87, in main
update_spotify_playlist(spot, playlist_path, playlist_id, args.convert)
File "C:\Users\REDACTED\AppData\Local\Programs\Python\Python310\lib\site-packages\tospotify\search.py", line 120, in update_spotify_playlist
songs = parse_songs(playlist_path)
File "C:\Users\REDACTED\AppData\Local\Programs\Python\Python310\lib\site-packages\tospotify\parser.py", line 33, in parse_songs
playlist = m3u8.load(playlist_path)
File "C:\Users\REDACTED\AppData\Local\Programs\Python\Python310\lib\site-packages\m3u8\__init__.py", line 96, in load
content, base_uri = http_client.download(uri, timeout, headers, verify_ssl)
File "C:\Users\REDACTED\AppData\Local\Programs\Python\Python310\lib\site-packages\m3u8\httpclient.py", line 16, in download
resource = opener.open(uri, timeout=timeout)
File "C:\Users\REDACTED\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 519, in open
response = self._open(req, data)
File "C:\Users\REDACTED\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 541, in _open
return self._call_chain(self.handle_open, 'unknown',
File "C:\Users\REDACTED\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 496, in _call_chain
result = func(*args)
File "C:\Users\REDACTED\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 1419, in unknown_open
raise URLError('unknown url type: %s' % type)
urllib.error.URLError: <urlopen error unknown url type: c>
Artists Names and Song Titles often contain dashes.
However, It's less likely that the Artist Name would contain " - ".
As such, everything after " - " could be assumed to be a Title—including any remaining " - " in that Title.
My personal motivation for this issue? Dash-separated dates in the Title denoting the date the track was exported. This is often the case when an artist puts out early previews of tracks.
WARNING:root:Encountered more than 2 chunks when splitting song into artist and title. song=Jafet Meza - Brother In Arms 2022-08-24
WARNING:root:Encountered more than 2 chunks when splitting song into artist and title. song=Jafet Meza - Brother In Arms 2022-08-28
WARNING:root:Encountered more than 2 chunks when splitting song into artist and title. song=Jafet Meza - Brother In Arms 2022-12-22 (End)
WARNING:root:Encountered more than 2 chunks when splitting song into artist and title. song=Jafet Meza - Brother In Arms 2022-12-22
WARNING:root:Encountered more than 2 chunks when splitting song into artist and title. song=Jafet Meza - In Amber Clad (2023-04-07)
WARNING:root:Encountered more than 2 chunks when splitting song into artist and title. song=Jafet Meza - In Amber Clad (2024-01-05)
WARNING:root:Encountered more than 2 chunks when splitting song into artist and title. song=Jafet Meza - In Amber Clad (2024-01-05, Gtr)
WARNING:root:Encountered more than 2 chunks when splitting song into artist and title. song=Jafet Meza - In Amber Clad (2024-01-05, Nogtr)
WARNING:root:Encountered more than 2 chunks when splitting song into artist and title. song=Jafet Meza - Leonidas (2024-01-08)
WARNING:root:Encountered more than 2 chunks when splitting song into artist and title. song=Jafet Meza - Leonidas (2024-01-09)
WARNING:root:Encountered more than 2 chunks when splitting song into artist and title. song=Jafet Meza - Leonidas (2024-01-12)
WARNING:root:Encountered more than 2 chunks when splitting song into artist and title. song=Jafet Meza - On A Pale Horrse 2022-08-22
WARNING:root:Encountered more than 2 chunks when splitting song into artist and title. song=Jafet Meza - On A Pale Horrse 2022-12-22
As triggered by #20, it seems that newer m3u8 versions handle paths differently in >3.4.0.
tospotify
should work with both >3.4.0 and <=3.4.0 versions of m3u8. Figure out the correct way of using m3u8.load here and at least update these tests.
Finally, remove the m3u8<3.5.0 dependency restriction.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.