phate89 / tvdbsimple Goto Github PK
View Code? Open in Web Editor NEWA Python wrapper for TheTVDb Database API v2
License: GNU General Public License v3.0
A Python wrapper for TheTVDb Database API v2
License: GNU General Public License v3.0
When using the following bad data request (there is no episode 15),
showeps = tvdb.Series_Episodes(78874, airedSeason=1, airedEpisode=15)
eps = showeps.all()
I saw an exception during the exception handling
File "/home/troy/.local/lib/python3.5/site-packages/tvdbsimple/base.py", line 144, in _request
raise Exception(response.json()['error'])
KeyError: 'error'
After the first use of Series_Episodes it seems not to do anything apart from return an empty list.
In my application i have the debug http requests logged and only see a request made to the api endpoint on the first use of Series_Episodes.
Python 2.7.9
tvdbsimple==1.0.4
Example code to replicate the issue:
import tvdbsimple as tvdb
if __name__ == '__main__':
tvdb.KEYS.API_KEY = 'your_api_key'
eids = [78804, 281662, 267440]
for eid in eids:
blah = tvdb.Series_Episodes(eid).all()
print(len(blah))
281
0
0
import tvdbsimple as tvdb
if __name__ == '__main__':
tvdb.KEYS.API_KEY = 'your_api_key'
eids = [78804, 281662, 267440]
for eid in eids:
blah = tvdb.Series(eid)
bloo = blah.Episodes.all()
print(len(bloo))
281
0
0
this works fine though
import tvdbsimple as tvdb
if __name__ == '__main__':
tvdb.KEYS.API_KEY = 'your_api_key'
eids = [78804, 281662, 267440]
for eid in eids:
blah = tvdb.Series_Images(eid).summary()
print(len(blah))
5
4
5
How are banners to be downloaded or accessed / saved?
I would prefer if this library sorts the results by ratingsInfo's average field descending, as those should be the best pictures.
>>> show = tvdb.Series('355567')
>>> art = show.Images.all()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/tvdbsimple/series.py", line 470, in all
return self._get_image_type('images', language)
File "/usr/local/lib/python2.7/dist-packages/tvdbsimple/series.py", line 480, in _get_image_type
response = self._GET(path, params=filters)
File "/usr/local/lib/python2.7/dist-packages/tvdbsimple/base.py", line 149, in _GET
return self._request('GET', path, params=params, cleanJson=cleanJson)
File "/usr/local/lib/python2.7/dist-packages/tvdbsimple/base.py", line 142, in _request
return self._request(method=method, path=path, params=params, payload=payload, forceNewToken=True)
File "/usr/local/lib/python2.7/dist-packages/tvdbsimple/base.py", line 146, in _request
response.raise_for_status()
File "/usr/local/lib/python2.7/dist-packages/requests/models.py", line 940, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 405 Client Error: Method Not Allowed for url: https://api.thetvdb.com/series/355567/images/query
>>>
I see you did some changes, should there be a new release or is it waiting for something?
It looks like in the Search().series() method, the series method is overwritten by the response from the request, but the response is also returned. This does not make much sense because each Search() instance can only be used once.
Can we get a default timeout on get requests at least?
So I am attempt a simple search as per below. I keep getting Auth issues, even tho the key is fine. I couldnt find where to set username and userkey but I tried hard coding them on the init but same issue. Im using python3.7
import tvdbsimple as tvdb
tvdb.KEYS.API_KEY = 'RCNBQO6OM61NLMWX'
search = tvdb.Search()
search.series("Dragon Ball")
for item in search.series:
print(item['seriesName'])
For anyone finding this in the future, below are the issues I've found with this package...they are manageable but annoying. Not sure if the original author is responding to pull requests anymore. I can make one if so, though.
series.py
Series_Episodes:
- fixed _URLS{'queryparams'} to _URLS{'query_params'} so Series_Episodes.query_params() actually works
- converted _PAGES, _PAGES_LIST, and _FILTERS from class members to instance members so calls to Series_Episodes works more than once
Series_Images
- fixed _URLS{'queryparams'} to _URLS{'query_params'} so Series_Images.query_params() actually works
- Series_Images.all() bombs out if no filters are set
- call summary(), the other methods break since they have become integer attributes
- once one of the other methods is called, that method becomes a attribute of the response and thus uncallable
updates.py
Updates:
- fixed _URLS{'params'} init to _URLS{'update_params'} so Updates.update_params() actually works
- series can only be called once since it becomes a attribute after the first call...
search.py
Search
- fixed _URLS{'seriesparams'} to _URLS{'series_params'} so Search.series_params() actually works
- series can only be called once since it becomes an attribute after the first call
user.py
User_Ratings
- converted _PAGES, _PAGES_LIST, and _FILTERS from class members to instance members so calls to User_Ratings works more than once
base.py
TVDB
- if_requests gets a 404 back, raise Exception(response.json()['error']) blows up since 'error' isn't a valid key. should be 'Error'
- this is an awkward Exception anyway since its raised in a Try block and then a call to requests raises another exception...
Hi I love what you do and love this library!!!
I have one problem:
my code:
search = tvdb.Search()
response = search.series("doctor who")
The response is a list type.
How do I convert it into a dict or dictionary type??
>>> show = tvdb.Series('355567')
>>> show.Images.poster()
[{u'languageId': 7, u'keyType': u'poster', u'fileName': u'posters/5c5c402b075cc.jpg', u'thumbnail': u'_cache/posters/5c5c402b075cc.jpg', u'subKey': u'', u'resolution': u'680x1000', u'id': 1337843, u'ratingsInfo': {u'count': 8, u'average': 8.9}}, {u'languageId': 7, u'keyType': u'poster', u'fileName': u'posters/5d120727011cc.jpg', u'thumbnail': u'_cache/posters/5d120727011cc.jpg', u'subKey': u'', u'resolution': u'680x1000', u'id': 1370927, u'ratingsInfo': {u'count': 2, u'average': 5.5}}, {u'languageId': 7, u'keyType': u'poster', u'fileName': u'posters/5d3a89fcb94fd.jpg', u'thumbnail': u'_cache/posters/5d3a89fcb94fd.jpg', u'subKey': u'', u'resolution': u'680x1000', u'id': 1377712, u'ratingsInfo': {u'count': 2, u'average': 8}}, {u'languageId': 7, u'keyType': u'poster', u'fileName': u'posters/5d3a8a73735d3.jpg', u'thumbnail': u'_cache/posters/5d3a8a73735d3.jpg', u'subKey': u'', u'resolution': u'680x1000', u'id': 1377713, u'ratingsInfo': {u'count': 2, u'average': 5.5}}, {u'languageId': 7, u'keyType': u'poster', u'fileName': u'posters/5d3a8b23f4139.jpg', u'thumbnail': u'_cache/posters/5d3a8b23f4139.jpg', u'subKey': u'', u'resolution': u'680x1000', u'id': 1377714, u'ratingsInfo': {u'count': 1, u'average': 1}}, {u'languageId': 7, u'keyType': u'poster', u'fileName': u'posters/5d3a8bed32870.jpg', u'thumbnail': u'_cache/posters/5d3a8bed32870.jpg', u'subKey': u'', u'resolution': u'680x1000', u'id': 1377716, u'ratingsInfo': {u'count': 1, u'average': 1}}, {u'languageId': 7, u'keyType': u'poster', u'fileName': u'posters/5d3a8c2304cbf.jpg', u'thumbnail': u'_cache/posters/5d3a8c2304cbf.jpg', u'subKey': u'', u'resolution': u'680x1000', u'id': 1377717, u'ratingsInfo': {u'count': 2, u'average': 5.5}}, {u'languageId': 7, u'keyType': u'poster', u'fileName': u'posters/5d3b88da98473.jpg', u'thumbnail': u'_cache/posters/5d3b88da98473.jpg', u'subKey': u'', u'resolution': u'680x1000', u'id': 1377868, u'ratingsInfo': {u'count': 3, u'average': 4}}, {u'languageId': 7, u'keyType': u'poster', u'fileName': u'posters/5d3b892d3fe4e.jpg', u'thumbnail': u'_cache/posters/5d3b892d3fe4e.jpg', u'subKey': u'', u'resolution': u'680x1000', u'id': 1377869, u'ratingsInfo': {u'count': 3, u'average': 7}}]
>>> show.Images.poster()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'list' object is not callable
>>>
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.