Git Product home page Git Product logo

pocket-casts's People

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  avatar  avatar

pocket-casts's Issues

Response is not checked to be valid

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}")

PlayingStatus?

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?

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

Error running api

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)

working

Hey, im getting tons of errors. Did i get the latest version?
Thanks for the great work by the way ;)

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.