furgoose / pocket-casts Goto Github PK
View Code? Open in Web Editor NEWUnofficial API for pocket casts built in python 3
License: MIT License
Unofficial API for pocket casts built in python 3
License: MIT License
Please add a timeout to all requests.
Thanks
in _make_req, responses are not checked to be valid. The primary missing check is to see if the response is "OK" and the second check is whether the response content-type is JSON or HTML.
Assumption: None of methods expect HTML.
I made some mods... let me know what you think and I'll submit a PR if there's interest.
def _make_req(self, url, method='GET', data=None):
"""Makes a HTTP GET/POST request
Args:
url (str): The URL to make the request to
method (str, optional): The method to use. Defaults to 'GET'
data (dict): data to send with a POST request. Defaults to None.
Returns:
requests.response.models.Response: A response object
"""
if method == 'JSON':
req = requests.Request('POST', url, json=data, cookies=self._session.cookies)
elif method == 'POST' or data:
req = requests.Request('POST', url, data=data, cookies=self._session.cookies)
elif method == 'GET':
req = requests.Request('GET', url, cookies=self._session.cookies)
else:
raise Exception("Invalid method")
prepped = req.prepare()
response = self._session.send(prepped)
if response.status_code == requests.codes.ok:
print(f"{response.status_code} - {response.reason}")
if response.headers["content-type"] == "application/json":
return response
else:
raise Exception(f"Content-Type Error: {response.headers['Content-Type']}")
else:
raise Exception(f"Request Error: {response.status_code} - {response.reason}")
Hey up,
Just checking whether this api works with their beta version. I assume the api is the same, but I wanted to check if anyone tested it already.
https://playbeta.pocketcasts.com
๐
I'm seeing a PlayingStatus of 1 showing up sometime shortly after 2017-12-29. Before that it worked fine for months and months. Anyone else seeing something similar?
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
Hi,
Any idea what I am doing wrong here?
pocket.get_new_releases()
Traceback (most recent call last):
File "/Users/user/miniconda3/lib/python3.10/site-packages/requests/models.py", line 971, in json
return complexjson.loads(self.text, **kwargs)
File "/Users/user/miniconda3/lib/python3.10/json/init.py", line 346, in loads
return _default_decoder.decode(s)
File "/Users/user/miniconda3/lib/python3.10/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/Users/user/miniconda3/lib/python3.10/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)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "", line 1, in
File "/Users/user/miniconda3/lib/python3.10/site-packages/pocketcasts/api.py", line 234, in get_new_releases
for episode in attempt.json()['episodes']:
File "/Users/user/miniconda3/lib/python3.10/site-packages/requests/models.py", line 975, in json
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Hey, im getting tons of errors. Did i get the latest version?
Thanks for the great work by the way ;)
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.