rv3392 / spotify-to-pocketcasts Goto Github PK
View Code? Open in Web Editor NEWA script to transfer podcast subscriptions and listening history from Spotify to Pocket Casts
A script to transfer podcast subscriptions and listening history from Spotify to Pocket Casts
At the beginning I had troubles to get the script running because I didn't understand first that the POCKETCASTS_USER was not set (I had set the POCKETCASTS_EMAIL per instructions), because the script kept running and the "No Pocket Casts username given! ..." error message got lost in the output flow. The script stopped later during the execution when there was error caused by the missing user id. It would be better to stop the script immediately when the missing user id is noticed.
Here is an example run:
/Users/-/opt/spotify-to-pocketcasts-master/python spotify_to_pocketcasts.py
No Pocket Casts username given! Please set POCKETCASTS_USER or use the --pocketcasts_user option
Logged In!
Got podcast subscriptions from Spotify.
Processing The Hacker Mind
There are 86 episodes!
There are 8 started episodes!
The Hacker Mind: Syncing 8 episodes from Spotify to Pocketcasts
{'Authorization': 'Bearer None', 'content-length': 27}
b'{"term": "The Hacker Mind"}'
Traceback (most recent call last):
File "/Users/-/opt/spotify-to-pocketcasts-master/spotify_to_pocketcasts.py", line 109, in <module>
main()
File "/Users/-/opt/spotify-to-pocketcasts-master/spotify_to_pocketcasts.py", line 91, in main
uuid = pocketcasts.search_podcasts_and_get_first_uuid(http, token, podcast.title)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/-/opt/spotify-to-pocketcasts-master/pocketcasts.py", line 57, in search_podcasts_and_get_first_uuid
search_result = search_podcasts(http, token, term)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/-/opt/spotify-to-pocketcasts-master/pocketcasts.py", line 53, in search_podcasts
return json.loads(response.data)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/-/opt/anaconda3/anaconda3/lib/python3.11/json/__init__.py", line 346, in loads
return _default_decoder.decode(s)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/-/opt/anaconda3/anaconda3/lib/python3.11/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/-/opt/anaconda3/anaconda3/lib/python3.11/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
It would be better to end the script after the second row:
/Users/-/opt/spotify-to-pocketcasts-master/python spotify_to_pocketcasts.py
No Pocket Casts username given! Please set POCKETCASTS_USER or use the --pocketcasts_user option
It became as a bit of a surprise that I needed to copy the url from the browser to the terminal window during the script execution. It wasn't difficult, but instructions beforehand would have made the experience even smoother :)
Current requirements.txt
spotipy==2.22.0
urllib3==1.26.14
Is it important, that the packages are exactly those version?
Would these be enough:
spotipy>=2.22.0
urllib3>=1.26.14
(or if the bigger changes of 2.x break things: urllib3>=1.26.14, <2)
Add instructions how to use the CLI options instead of the environtment variables
Most of my podcasts matched correctly but some of them were incorrectly matched. Within the incorrect ones some of them:
Fix the environment variables in the instructions to match ones used in the code:
The linked Spotipy package's documentation uses SPOTIPY in the env variables and the code uses SPOTIFY so either code should be changed or instructions clarified. Also the word "CLIENT" is missing from the variable used for the secret in the code:
Before adding any new features, there needs to be a way to test the script without actually logging into Spotify + Pocket Casts and doing a transfer.
This needs to:
There was one podcast that caused the script to stop in a error. The podcast was found in both services, but was maybe incorrectly matched because of the quite common word in the name or something. Unsubscribing the show in Spotify let the script run completely.
Here is the error dump:
Processing Singletracks Mountain Bike Podcast
There are 396 episodes!
Traceback (most recent call last):
File "/Users/-/opt/spotify-to-pocketcasts-master/spotify_to_pocketcasts.py", line 109, in <module>
main()
File "/Users/-/opt/spotify-to-pocketcasts-master/spotify_to_pocketcasts.py", line 87, in main
podcast.episodes = spotify.get_listened_episodes_for_show(spotify_client, podcast)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/-/opt/spotify-to-pocketcasts-master/spotify.py", line 69, in get_listened_episodes_for_show
episode["name"],
~~~~~~~^^^^^^^^
TypeError: 'NoneType' object is not subscriptable
Same happened with the "Rise and Play Podcast".
For example what shoud be entered in the Redirect URI field.
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.