Pocket-Casts
Pocket-Casts copied to clipboard
Several of the methods return a json error
For instance, calling get_in_progress() dumps
Traceback (most recent call last):
File "sync_podcasts.py", line 115, in <module>
main()
File "sync_podcasts.py", line 110, in main
pp.pprint(pcasts.api.get_in_progress())
File "/home/user/.local/share/virtualenvs/gmusic-to-pocketcasts-LBVa381A/lib/python3.6/site-packages/pocketcasts/api.py", line 246, in get_in_progress
for episode in attempt.json()['episodes']:
File "/home/user/.local/share/virtualenvs/gmusic-to-pocketcasts-LBVa381A/lib/python3.6/site-packages/requests/models.py", line 897, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/lib/python3.6/json/__init__.py", line 354, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.6/json/decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.6/json/decoder.py", line 357, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Ran with python version 3.6
See #6 where I made some code changes to improve the errors returned.
I then ran the tests and you can see many calls are using the wrong method. I tried dropping the POST method from get_starred (which defaults then to GET) and then it returned HTML so it looks like PocketCasts changed a lot of this and it may no longer work.
======================================================================
ERROR: test_get_episode (__main__.PocketcastTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File ".../Pocket-Casts/tests/test_api.py", line 34, in test_get_episode
pod = self.pocket.get_podcast("12012c20-0423-012e-f9a0-00163e1b201c")
File "...\pocket-casts\pocketcasts\api.py", line 184, in get_podcast
attempt = self._make_req('https://play.pocketcasts.com/web/podcasts/podcast.json', data=data).json()['podcast']
File "...\pocket-casts\pocketcasts\api.py", line 55, in _make_req
raise Exception(f"Request Error: {response.status_code} - {response.reason}")
Exception: Request Error: 405 - Method Not Allowed
======================================================================
ERROR: test_get_episode_notes (__main__.PocketcastTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File ".../Pocket-Casts/tests/test_api.py", line 49, in test_get_episode_notes
response = self.pocket.get_episode_notes('a35748e0-bb4d-0134-10a8-25324e2a541d')
File "...\pocket-casts\pocketcasts\api.py", line 253, in get_episode_notes
return self._make_req('https://play.pocketcasts.com/web/episodes/show_notes.json', data=data) \
File "...\pocket-casts\pocketcasts\api.py", line 55, in _make_req
raise Exception(f"Request Error: {response.status_code} - {response.reason}")
Exception: Request Error: 405 - Method Not Allowed
======================================================================
ERROR: test_get_in_progress (__main__.PocketcastTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File ".../Pocket-Casts/tests/test_api.py", line 58, in test_get_in_progress
response = self.pocket.get_in_progress()
File "...\pocket-casts\pocketcasts\api.py", line 294, in get_in_progress
attempt = self._make_req('https://play.pocketcasts.com/web/episodes/in_progress_episodes.json', method='POST')
File "...\pocket-casts\pocketcasts\api.py", line 55, in _make_req
raise Exception(f"Request Error: {response.status_code} - {response.reason}")
Exception: Request Error: 405 - Method Not Allowed
======================================================================
ERROR: test_get_new_releases (__main__.PocketcastTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File ".../Pocket-Casts/tests/test_api.py", line 55, in test_get_new_releases
response = self.pocket.get_new_releases()
File "...\pocket-casts\pocketcasts\api.py", line 276, in get_new_releases
attempt = self._make_req('https://play.pocketcasts.com/web/episodes/new_releases_episodes.json', method='POST')
File "...\pocket-casts\pocketcasts\api.py", line 55, in _make_req
raise Exception(f"Request Error: {response.status_code} - {response.reason}")
Exception: Request Error: 405 - Method Not Allowed
======================================================================
ERROR: test_get_podcast (__main__.PocketcastTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File ".../Pocket-Casts/tests/test_api.py", line 28, in test_get_podcast
response = self.pocket.get_podcast('12012c20-0423-012e-f9a0-00163e1b201c')
File "...\pocket-casts\pocketcasts\api.py", line 184, in get_podcast
attempt = self._make_req('https://play.pocketcasts.com/web/podcasts/podcast.json', data=data).json()['podcast']
File "...\pocket-casts\pocketcasts\api.py", line 55, in _make_req
raise Exception(f"Request Error: {response.status_code} - {response.reason}")
Exception: Request Error: 405 - Method Not Allowed
======================================================================
ERROR: test_get_podcast_episodes (__main__.PocketcastTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File ".../Pocket-Casts/tests/test_api.py", line 31, in test_get_podcast_episodes
response = self.pocket.get_podcast_episodes(self.pocket.get_trending()[0])
File "...\pocket-casts\pocketcasts\api.py", line 230, in get_podcast_episodes
attempt = self._make_req('https://play.pocketcasts.com/web/episodes/find_by_podcast.json', data=data).json()
File "...\pocket-casts\pocketcasts\api.py", line 55, in _make_req
raise Exception(f"Request Error: {response.status_code} - {response.reason}")
Exception: Request Error: 405 - Method Not Allowed
======================================================================
ERROR: test_get_starred (__main__.PocketcastTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File ".../Pocket-Casts/tests/test_api.py", line 38, in test_get_starred
self.pocket.get_starred()
File "...\pocket-casts\pocketcasts\api.py", line 311, in get_starred
attempt = self._make_req('https://play.pocketcasts.com/web/episodes/starred_episodes.json', method='POST')
File "...\pocket-casts\pocketcasts\api.py", line 55, in _make_req
raise Exception(f"Request Error: {response.status_code} - {response.reason}")
Exception: Request Error: 405 - Method Not Allowed
======================================================================
ERROR: test_get_subscribed_podcasts (__main__.PocketcastTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File ".../Pocket-Casts/tests/test_api.py", line 52, in test_get_subscribed_podcasts
response = self.pocket.get_subscribed_podcasts()
File "...\pocket-casts\pocketcasts\api.py", line 263, in get_subscribed_podcasts
attempt = self._make_req('https://play.pocketcasts.com/web/podcasts/all.json', method='POST').json()
File "...\pocket-casts\pocketcasts\api.py", line 55, in _make_req
raise Exception(f"Request Error: {response.status_code} - {response.reason}")
Exception: Request Error: 405 - Method Not Allowed
======================================================================
ERROR: test_invalid_played_position (__main__.PocketcastTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File ".../Pocket-Casts/tests/test_api.py", line 78, in test_invalid_played_position
pod = self.pocket.get_podcast("12012c20-0423-012e-f9a0-00163e1b201c")
File "...\pocket-casts\pocketcasts\api.py", line 184, in get_podcast
attempt = self._make_req('https://play.pocketcasts.com/web/podcasts/podcast.json', data=data).json()['podcast']
File "...\pocket-casts\pocketcasts\api.py", line 55, in _make_req
raise Exception(f"Request Error: {response.status_code} - {response.reason}")
Exception: Request Error: 405 - Method Not Allowed
======================================================================
ERROR: test_invalid_update_playing_status (__main__.PocketcastTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File ".../Pocket-Casts/tests/test_api.py", line 66, in test_invalid_update_playing_status
pod = self.pocket.get_podcast("12012c20-0423-012e-f9a0-00163e1b201c")
File "...\pocket-casts\pocketcasts\api.py", line 184, in get_podcast
attempt = self._make_req('https://play.pocketcasts.com/web/podcasts/podcast.json', data=data).json()['podcast']
File "...\pocket-casts\pocketcasts\api.py", line 55, in _make_req
raise Exception(f"Request Error: {response.status_code} - {response.reason}")
Exception: Request Error: 405 - Method Not Allowed
======================================================================
ERROR: test_search_podcasts (__main__.PocketcastTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File ".../Pocket-Casts/tests/test_api.py", line 41, in test_search_podcasts
self.pocket.search_podcasts('test')
File "...\pocket-casts\pocketcasts\api.py", line 419, in search_podcasts
attempt = self._make_req("https://play.pocketcasts.com/web/podcasts/search.json", data=data)
File "...\pocket-casts\pocketcasts\api.py", line 55, in _make_req
raise Exception(f"Request Error: {response.status_code} - {response.reason}")
Exception: Request Error: 405 - Method Not Allowed
======================================================================
ERROR: test_subscribe_functions (__main__.PocketcastTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File ".../Pocket-Casts/tests/test_api.py", line 44, in test_subscribe_functions
pod = self.pocket.get_podcast("da9bb800-e230-0132-0bd1-059c869cc4eb")
File "...\pocket-casts\pocketcasts\api.py", line 184, in get_podcast
attempt = self._make_req('https://play.pocketcasts.com/web/podcasts/podcast.json', data=data).json()['podcast']
File "...\pocket-casts\pocketcasts\api.py", line 55, in _make_req
raise Exception(f"Request Error: {response.status_code} - {response.reason}")
Exception: Request Error: 405 - Method Not Allowed
======================================================================
ERROR: test_update_played_position (__main__.PocketcastTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File ".../Pocket-Casts/tests/test_api.py", line 73, in test_update_played_position
pod = self.pocket.get_podcast("12012c20-0423-012e-f9a0-00163e1b201c")
File "...\pocket-casts\pocketcasts\api.py", line 184, in get_podcast
attempt = self._make_req('https://play.pocketcasts.com/web/podcasts/podcast.json', data=data).json()['podcast']
File "...\pocket-casts\pocketcasts\api.py", line 55, in _make_req
raise Exception(f"Request Error: {response.status_code} - {response.reason}")
Exception: Request Error: 405 - Method Not Allowed
======================================================================
ERROR: test_update_playing_status (__main__.PocketcastTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File ".../Pocket-Casts/tests/test_api.py", line 61, in test_update_playing_status
pod = self.pocket.get_podcast("12012c20-0423-012e-f9a0-00163e1b201c")
File "...\pocket-casts\pocketcasts\api.py", line 184, in get_podcast
attempt = self._make_req('https://play.pocketcasts.com/web/podcasts/podcast.json', data=data).json()['podcast']
File "...\pocket-casts\pocketcasts\api.py", line 55, in _make_req
raise Exception(f"Request Error: {response.status_code} - {response.reason}")
Exception: Request Error: 405 - Method Not Allowed
======================================================================
ERROR: test_update_starred (__main__.PocketcastTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File ".../Pocket-Casts/tests/test_api.py", line 85, in test_update_starred
pod = self.pocket.get_podcast("12012c20-0423-012e-f9a0-00163e1b201c")
File "...\pocket-casts\pocketcasts\api.py", line 184, in get_podcast
attempt = self._make_req('https://play.pocketcasts.com/web/podcasts/podcast.json', data=data).json()['podcast']
File "...\pocket-casts\pocketcasts\api.py", line 55, in _make_req
raise Exception(f"Request Error: {response.status_code} - {response.reason}")
Exception: Request Error: 405 - Method Not Allowed
======================================================================
FAIL: test_invalid_login (__main__.PocketcastTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File ".../Pocket-Casts/tests/test_api.py", line 16, in test_invalid_login
self.assertRaises(Exception, pocketcasts.Pocketcasts, 'test', 'INVALID')
AssertionError: Exception not raised by Pocketcasts
----------------------------------------------------------------------
Ran 20 tests in 2.421s
FAILED (failures=1, errors=15)
Seems PocketCasts has changed their API since this project was abandoned. I am finishing up a new version of a PocketCasts API library. Will release on PyPi in the next day or so: https://github.com/nwithan8/PycketCasts