Projects
Multimedia
python-tvdb_api
Sign Up
Log In
Username
Password
Sorry, you are not authorized to perform this action.
×
We truncated the diff of some files because they were too big. If you want to see the full diff for every file,
click here
.
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 2
View file
python-tvdb_api.changes
Changed
@@ -1,4 +1,10 @@ ------------------------------------------------------------------- +Fri Apr 21 12:40:16 UTC 2017 - aloisio@gmx.com + +- Update to version 1.10 +- Spec cleanup + +------------------------------------------------------------------- Mon Feb 4 14:26:00 UTC 2013 - hvogel@opensuse.org - Update to version 1.8.2
View file
python-tvdb_api.spec
Changed
@@ -1,32 +1,57 @@ +# +# spec file for package python-tvdb_api +# +# Copyright (c) 2017 Packman Team <packman@links2linux.de> +# +# All modifications and additions to the file contributed by third parties +# remain the property of their copyright owners, unless otherwise agreed +# upon. The license for this file, and modifications and additions to the +# file, is the same license as for the pristine package itself (unless the +# license for the pristine package is not an Open Source License, in which +# case the license is the MIT License). An "Open Source License" is a +# license that conforms to the Open Source Definition (Version 1.9) +# published by the Open Source Initiative. + +# Please submit bugfixes or comments via http://bugs.links2linux.org/ +# + + %define modname tvdb_api -Name: python-tvdb_api -Summary: Python module to access the API from thetvdb.com -License: GPL -Url: http://pypi.python.org/pypi/tvdb_api -Group: Productivity/Multimedia/Other -Version: 1.8.2 -Release: 1 -Source0: tvdb_api-%version.tar.bz2 -BuildRoot: %{_tmppath}/%{name}-buildroot -BuildRequires: python-devel python-setuptools +Name: python-tvdb_api +Version: 1.10 +Release: 0 +Summary: Python module to access the API from thetvdb.com +# The UnLicense (https://unlicense.org) +License: SUSE-Permissive +Group: Productivity/Multimedia/Other +Url: https://github.com/dbr/tvdb_api/tree/master +Source0: https://files.pythonhosted.org/packages/source/t/%{modname}/%{modname}-%{version}.tar.gz +BuildRequires: python-devel +BuildRequires: python-setuptools +BuildRoot: %{_tmppath}/%{name}-%{version}-build +BuildArch: noarch %py_requires %description -tvdb_api is an easy to use interface to thetvdb.com +tvdb_api is an easy to use interface to thetvdb.com via python %prep -%setup -q -n %modname-%version +%setup -q -n %{modname}-%{version} +for file in {tvdb_cache,tvdb_api,tvdb_ui,tvdb_exceptions} +do + sed -i "1d" $file.py +done %build +python setup.py build %install -python setup.py install --root=$RPM_BUILD_ROOT --prefix=%_prefix \ - --record-rpm=INSTALLED_FILES - -%clean -rm -rf $RPM_BUILD_ROOT +python setup.py install --root=%{buildroot} --prefix=%{_prefix} -%files -f INSTALLED_FILES +%files %defattr(-,root,root) +%doc UNLICENSE readme.md +%{python_sitelib}/tvdb_*.py* +%{python_sitelib}/%{modname}-%{version}-py%{python_version}.egg-info %changelog
View file
tvdb_api-1.8.2.tar.bz2/PKG-INFO -> tvdb_api-1.10.tar.gz/PKG-INFO
Changed
@@ -1,6 +1,6 @@ -Metadata-Version: 1.0 +Metadata-Version: 1.1 Name: tvdb_api -Version: 1.8.2 +Version: 1.10 Summary: Interface to thetvdb.com Home-page: http://github.com/dbr/tvdb_api/tree/master Author: dbr/Ben @@ -22,6 +22,11 @@ Classifier: Natural Language :: English Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python +Classifier: Programming Language :: Python :: 2 +Classifier: Programming Language :: Python :: 2.6 +Classifier: Programming Language :: Python :: 2.7 +Classifier: Programming Language :: Python :: 3.3 +Classifier: Programming Language :: Python :: 3.4 Classifier: Topic :: Multimedia Classifier: Topic :: Utilities Classifier: Topic :: Software Development :: Libraries :: Python Modules
View file
tvdb_api-1.8.2.tar.bz2/Rakefile -> tvdb_api-1.10.tar.gz/Rakefile
Changed
@@ -47,10 +47,10 @@ end desc "Upload current version to PyPi" -task :topypi => :test do +task :topypi do cur_file = File.open("tvdb_api.py").read() tvdb_api_version = cur_file.scan(/__version__ = "(.*)"/) - tvdb_api_version = tvdb_api_version00.to_f + tvdb_api_version = tvdb_api_version00 puts "Build sdist and send tvdb_api v#{tvdb_api_version} to PyPi?" if $stdin.gets.chomp == "y"
View file
tvdb_api-1.8.2.tar.bz2/readme.md -> tvdb_api-1.10.tar.gz/readme.md
Changed
@@ -2,6 +2,8 @@ `tvdb_api` is an easy to use interface to thetvdb.comtvdb +It supports Python 2.6, 2.7, 3.3 and 3.4 + `tvnamer` has moved to a separate repository: github.com/dbr/tvnamertvnamer - it is a utility which uses `tvdb_api` to rename files from `some.show.s01e03.blah.abc.avi` to `Some Show - 01x03 - The Episode Name.avi` (which works by getting the episode name from `tvdb_api`) !Build Status(https://secure.travis-ci.org/dbr/tvdb_api.png?branch=master)(http://travis-ci.org/dbr/tvdb_api) @@ -38,7 +40,7 @@ There are several exceptions you may catch, these can be imported from `tvdb_api`: -- `tvdb_error` - this is raised when there is an error communicating with www.thetvdb.comtvdb (a network error most commonly) +- `tvdb_error` - this is raised when there is an error communicating with thetvdb.comtvdb (a network error most commonly) - `tvdb_userabort` - raised when a user aborts the Select Series dialog (by `ctrl+c`, or entering `q`) - `tvdb_shownotfound` - raised when `t'show name'` cannot find anything - `tvdb_seasonnotfound` - raised when the requested series (`t'show name99`) does not exist @@ -63,7 +65,7 @@ The data is stored in an attribute named `data`, within the Show instance: >>> t'scrubs'.data.keys() - 'networkid', 'rating', 'airs_dayofweek', 'contentrating', 'seriesname', 'id', 'airs_time', 'network', 'fanart', 'lastupdated', 'actors', 'ratingcount', 'status', 'added', 'poster', 'imdb_id', 'genre', 'banner', 'seriesid', 'language', 'zap2it_id', 'addedby', 'firstaired', 'runtime', 'overview' + 'networkid', 'rating', 'airs_dayofweek', 'contentrating', 'seriesname', 'id', 'airs_time', 'network', 'fanart', 'lastupdated', 'actors', 'ratingcount', 'status', 'added', 'poster', 'imdb_id', 'genre', 'banner', 'seriesid', 'language', 'zap2it_id', 'addedby', 'tms_wanted', 'firstaired', 'runtime', 'overview' Although each element is also accessible via `t'scrubs'` for ease-of-use: @@ -105,5 +107,5 @@ >>> t'scrubs''actors' u'|Zach Braff|Donald Faison|Sarah Chalke|Christa Miller|Aloma Wright|Robert Maschio|Sam Lloyd|Neil Flynn|Ken Jenkins|Judy Reyes|John C. McGinley|Travis Schuldt|Johnny Kastl|Heather Graham|Michael Mosley|Kerry Bish\xe9|Dave Franco|Eliza Coupe|' -tvdb: http://www.thetvdb.com +tvdb: http://thetvdb.com tvnamer: http://github.com/dbr/tvnamer
View file
tvdb_api-1.8.2.tar.bz2/setup.py -> tvdb_api-1.10.tar.gz/setup.py
Changed
@@ -1,7 +1,25 @@ +import sys from setuptools import setup + +IS_PY2 = sys.version_info0 == 2 + +_requirements = +if not IS_PY2: + _requirements.append('requests_cache') + + # 'requests' is installed as requirement by requests-cache, + # commented out because it triggers a bug in setuptool: + # https://bitbucket.org/pypa/setuptools/issue/196/tests_require-pytest-pytest-cov-breaks + + +_modules = 'tvdb_api', 'tvdb_ui', 'tvdb_exceptions' +if IS_PY2: + _modules.append('tvdb_cache') + + setup( name = 'tvdb_api', -version='1.8.2', +version='1.10', author='dbr/Ben', description='Interface to thetvdb.com', @@ -21,13 +39,19 @@ u'Stole a Badge' """, -py_modules = 'tvdb_api', 'tvdb_ui', 'tvdb_exceptions', 'tvdb_cache', +py_modules = _modules, +install_requires = _requirements, classifiers= "Intended Audience :: Developers", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", + "Programming Language :: Python :: 2", + "Programming Language :: Python :: 2.6", + "Programming Language :: Python :: 2.7", + "Programming Language :: Python :: 3.3", + "Programming Language :: Python :: 3.4", "Topic :: Multimedia", "Topic :: Utilities", "Topic :: Software Development :: Libraries :: Python Modules",
View file
tvdb_api-1.8.2.tar.bz2/tests/test_tvdb_api.py -> tvdb_api-1.10.tar.gz/tests/test_tvdb_api.py
Changed
@@ -21,6 +21,10 @@ from tvdb_api import (tvdb_shownotfound, tvdb_seasonnotfound, tvdb_episodenotfound, tvdb_attributenotfound) + +IS_PY2 = sys.version_info0 == 2 + + class test_tvdb_basic(unittest.TestCase): # Used to store the cached instance of Tvdb() t = None @@ -99,6 +103,10 @@ show ) + def test_no_season(self): + show = self.t'Katekyo Hitman Reborn' + print(tvdb_api) + print(show11) class test_tvdb_errors(unittest.TestCase): # Used to store the cached instance of Tvdb() @@ -229,7 +237,7 @@ """Check valid_languages is up-to-date (compared to languages.xml) """ et = self.t._getetsrc( - "http://www.thetvdb.com/api/%s/languages.xml" % ( + "http://thetvdb.com/api/%s/languages.xml" % ( self.t.config'apikey' ) ) @@ -452,13 +460,16 @@ self.fail("Expected ValueError from setting cache to float") def test_custom_urlopener(self): + if not IS_PY2: + raise unittest.SkipTest("cannot supply custom opener in Python 3 because requests is used") + class UsedCustomOpener(Exception): pass import urllib2 class TestOpener(urllib2.BaseHandler): def default_open(self, request): - print request.get_method() + print(request.get_method()) raise UsedCustomOpener("Something") custom_opener = urllib2.build_opener(TestOpener()) @@ -470,6 +481,26 @@ else: self.fail("Did not use custom opener") + def test_custom_request_session(self): + if IS_PY2: + return + from requests import Session as OriginalSession + class Used(Exception): + pass + class CustomCacheForTest(OriginalSession): + call_count = 0 + def request(self, *args, **kwargs): + raise Used("Hurray") + c = CustomCacheForTest() + t = tvdb_api.Tvdb(cache = c) + try: + t'scrubs' + except Used: + pass + else: + self.fail("Did not use custom session") + + class test_tvdb_by_id(unittest.TestCase): t = None def setUp(self): @@ -505,6 +536,59 @@ self.assertEquals(self.t'My Name Is Earl'14'episodename', 'Faked His Own Death') +class test_tvdb_show_ordering(unittest.TestCase): + # Used to store the cached instance of Tvdb() + t_dvd = None + t_air = None + + def setUp(self): + if self.t_dvd is None: + self.t_dvd = tvdb_api.Tvdb(cache = True, useZip = True, dvdorder=True) + + if self.t_air is None: + self.t_air = tvdb_api.Tvdb(cache = True, useZip = True) + + def test_ordering(self): + """Test Tvdb.search method + """ + self.assertEquals(u'The Train Job', self.t_air'Firefly'11'episodename') + self.assertEquals(u'Serenity', self.t_dvd'Firefly'11'episodename') + + self.assertEquals(u'The Cat & the Claw (Part 1)', self.t_air'Batman The Animated Series'11'episodename') + self.assertEquals(u'On Leather Wings', self.t_dvd'Batman The Animated Series'11'episodename') + +class test_tvdb_show_search(unittest.TestCase): + # Used to store the cached instance of Tvdb() + t = None + + def setUp(self): + if self.t is None: + self.__class__.t = tvdb_api.Tvdb(cache = True, useZip = True) + + def test_search(self): + """Test Tvdb.search method + """ + results = self.t.search("my name is earl") + all_ids = x'seriesid' for x in results + self.assertTrue('75397' in all_ids) + + +class test_tvdb_alt_names(unittest.TestCase): + t = None + def setUp(self): + if self.t is None: + self.__class__.t = tvdb_api.Tvdb(cache = True, actors = True) + + def test_1(self): + """Tests basic access of series name alias + """ + results = self.t.search("Don't Trust the B---- in Apartment 23") + series = results0 + self.assertTrue( + 'Apartment 23' in series'aliasnames' + ) + + if __name__ == '__main__': runner = unittest.TextTestRunner(verbosity = 2) unittest.main(testRunner = runner)
View file
tvdb_api-1.8.2.tar.bz2/tvdb_api.egg-info/PKG-INFO -> tvdb_api-1.10.tar.gz/tvdb_api.egg-info/PKG-INFO
Changed
@@ -1,6 +1,6 @@ -Metadata-Version: 1.0 +Metadata-Version: 1.1 Name: tvdb-api -Version: 1.8.2 +Version: 1.10 Summary: Interface to thetvdb.com Home-page: http://github.com/dbr/tvdb_api/tree/master Author: dbr/Ben @@ -22,6 +22,11 @@ Classifier: Natural Language :: English Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python +Classifier: Programming Language :: Python :: 2 +Classifier: Programming Language :: Python :: 2.6 +Classifier: Programming Language :: Python :: 2.7 +Classifier: Programming Language :: Python :: 3.3 +Classifier: Programming Language :: Python :: 3.4 Classifier: Topic :: Multimedia Classifier: Topic :: Utilities Classifier: Topic :: Software Development :: Libraries :: Python Modules
View file
tvdb_api-1.8.2.tar.bz2/tvdb_api.py -> tvdb_api-1.10.tar.gz/tvdb_api.py
Changed
@@ -5,7 +5,7 @@ #repository:http://github.com/dbr/tvdb_api #license:unlicense (http://unlicense.org/) -"""Simple-to-use Python interface to The TVDB's API (www.thetvdb.com) +"""Simple-to-use Python interface to The TVDB's API (thetvdb.com) Example usage: @@ -15,14 +15,23 @@ u'Cabin Fever' """ __author__ = "dbr/Ben" -__version__ = "1.8.2" +__version__ = "1.10" + +import sys + +IS_PY2 = sys.version_info0 == 2 import os import time -import urllib -import urllib2 +if IS_PY2: + import urllib + import urllib2 + from tvdb_cache import CacheHandler + from urllib import quote as url_quote +else: + import requests + from urllib.parse import quote as url_quote import getpass -import StringIO import tempfile import warnings import logging @@ -40,7 +49,13 @@ gzip = None -from tvdb_cache import CacheHandler +if IS_PY2: + int_types = (int, long) + text_type = unicode +else: + int_types = int + text_type = str + from tvdb_ui import BaseUI, ConsoleUI from tvdb_exceptions import (tvdb_error, tvdb_userabort, tvdb_shownotfound, @@ -65,16 +80,12 @@ #keep only the 100th latest results if time.time() - self._lastgc > 20: - tbd = self._stack:-100 - i = 0 - for o in tbd: + for o in self._stack:-100: del selfo - del self._stacki - i += 1 + self._stack = self._stack-100: + + self._lastgc = time.time() - _lastgc = time.time() - del tbd - super(ShowContainer, self).__setitem__(key, value) @@ -171,7 +182,7 @@ searchresult = cur_season.search(term = term, key = key) if len(searchresult) != 0: results.extend(searchresult) - #end for cur_season + return results @@ -259,16 +270,14 @@ if term == None: raise TypeError("must supply string to search for (contents)") - term = unicode(term).lower() + term = text_type(term).lower() for cur_key, cur_value in self.items(): - cur_key, cur_value = unicode(cur_key).lower(), unicode(cur_value).lower() + cur_key, cur_value = text_type(cur_key).lower(), text_type(cur_value).lower() if key is not None and cur_key != key: # Do not search this key continue - if cur_value.find( unicode(term).lower() ) > -1: + if cur_value.find( text_type(term).lower() ) > -1: return self - #end if cur_value.find() - #end for cur_key, cur_value class Actors(list): @@ -308,7 +317,8 @@ search_all_languages = False, apikey = None, forceConnect=False, - useZip=False): + useZip=False, + dvdorder=False): """interactive (True/False): When True, uses built-in console UI is used to select the correct show. @@ -333,6 +343,12 @@ an arbitrary Python object, which is used as a urllib2 opener, which should be created by urllib2.build_opener + In Python 3, True/False enable or disable default + caching. Passing string specified directory where to store + the "tvdb.sqlite3" cache file. Also a custom + requests.Session instance can be passed (e.g maybe a + customised instance of requests_cache.CachedSession) + banners (True/False): Retrieves the banners for a show. These are accessed via the _banners key of a Show(), for example: @@ -382,6 +398,7 @@ And only the main language xml is used, the actor and banner xml are lost. """ + global lastTimeout # if we're given a lastTimeout that is less than 1 min just give up @@ -410,33 +427,61 @@ self.config'useZip' = useZip + self.config'dvdorder' = dvdorder - if cache is True: - self.config'cache_enabled' = True - self.config'cache_location' = self._getTempDir() - self.urlopener = urllib2.build_opener( - CacheHandler(self.config'cache_location') - ) + if not IS_PY2: # FIXME: Allow using requests in Python 2? + import requests_cache + if cache is True: + self.session = requests_cache.CachedSession( + expire_after=21600, # 6 hours + backend='sqlite', + cache_name=self._getTempDir(), + ) + self.config'cache_enabled' = True + elif cache is False: + self.session = requests.Session() + self.config'cache_enabled' = False + elif isinstance(cache, text_type): + # Specified cache path + self.session = requests_cache.CachedSession( + expire_after=21600, # 6 hours + backend='sqlite', + cache_name=os.path.join(cache, "tvdb_api"), + ) + else: + self.session = cache + try: + self.session.get + except AttributeError: + raise ValueError("cache argument must be True/False, string as cache path or requests.Session-type object (e.g from requests_cache.CachedSession)") + else: + # For backwards compatibility in Python 2.x + if cache is True: + self.config'cache_enabled' = True + self.config'cache_location' = self._getTempDir() + self.urlopener = urllib2.build_opener( + CacheHandler(self.config'cache_location') + ) - elif cache is False: - self.config'cache_enabled' = False - self.urlopener = urllib2.build_opener() # default opener with no caching + elif cache is False: + self.config'cache_enabled' = False + self.urlopener = urllib2.build_opener() # default opener with no caching - elif isinstance(cache, basestring): - self.config'cache_enabled' = True - self.config'cache_location' = cache - self.urlopener = urllib2.build_opener( - CacheHandler(self.config'cache_location') - ) + elif isinstance(cache, basestring): + self.config'cache_enabled' = True + self.config'cache_location' = cache + self.urlopener = urllib2.build_opener( + CacheHandler(self.config'cache_location') + ) - elif isinstance(cache, urllib2.OpenerDirector):
View file
tvdb_api-1.8.2.tar.bz2/tvdb_cache.py -> tvdb_api-1.10.tar.gz/tvdb_cache.py
Changed
@@ -12,7 +12,7 @@ from __future__ import with_statement __author__ = "dbr/Ben" -__version__ = "1.8.2" +__version__ = "1.10" import os import time @@ -159,7 +159,6 @@ ) else: set_cache_header = True - #end if x-cache in response return CachedResponse( self.cache_location,
View file
tvdb_api-1.8.2.tar.bz2/tvdb_exceptions.py -> tvdb_api-1.10.tar.gz/tvdb_exceptions.py
Changed
@@ -9,7 +9,7 @@ """ __author__ = "dbr/Ben" -__version__ = "1.8.2" +__version__ = "1.10" __all__ = "tvdb_error", "tvdb_userabort", "tvdb_shownotfound", "tvdb_seasonnotfound", "tvdb_episodenotfound", "tvdb_attributenotfound" @@ -20,7 +20,7 @@ pass class tvdb_error(tvdb_exception): - """An error with www.thetvdb.com (Cannot connect, for example) + """An error with thetvdb.com (Cannot connect, for example) """ pass @@ -31,17 +31,17 @@ pass class tvdb_shownotfound(tvdb_exception): - """Show cannot be found on www.thetvdb.com (non-existant show) + """Show cannot be found on thetvdb.com (non-existant show) """ pass class tvdb_seasonnotfound(tvdb_exception): - """Season cannot be found on www.thetvdb.com + """Season cannot be found on thetvdb.com """ pass class tvdb_episodenotfound(tvdb_exception): - """Episode cannot be found on www.thetvdb.com + """Episode cannot be found on thetvdb.com """ pass
View file
tvdb_api-1.8.2.tar.bz2/tvdb_ui.py -> tvdb_api-1.10.tar.gz/tvdb_ui.py
Changed
@@ -43,13 +43,23 @@ """ __author__ = "dbr/Ben" -__version__ = "1.8.2" +__version__ = "1.10" +import sys import logging import warnings from tvdb_exceptions import tvdb_userabort + +IS_PY2 = sys.version_info0 == 2 + +if IS_PY2: + user_input = raw_input +else: + user_input = input + + def log(): return logging.getLogger(__name__) @@ -80,7 +90,7 @@ else: toshow = allSeries - print "TVDB Search Results:" + print("TVDB Search Results:") for i, cshow in enumerate(toshow): i_show = i + 1 # Start at more human readable number 1 (not 0) log().debug('Showing allSeries%s, series %s)' % (i_show, allSeriesi'seriesname')) @@ -89,31 +99,35 @@ else: extra = "" - print "%s -> %s %s # http://thetvdb.com/?tab=series&id=%s&lid=%s%s" % ( + output = "%s -> %s %s # http://thetvdb.com/?tab=series&id=%s&lid=%s%s" % ( i_show, - cshow'seriesname'.encode("UTF-8", "ignore"), - cshow'language'.encode("UTF-8", "ignore"), + cshow'seriesname', + cshow'language', str(cshow'id'), cshow'lid', extra ) + if IS_PY2: + print(output.encode("UTF-8", "ignore")) + else: + print(output) def selectSeries(self, allSeries): self._displaySeries(allSeries) if len(allSeries) == 1: # Single result, return it! - print "Automatically selecting only result" + print("Automatically selecting only result") return allSeries0 if self.config'select_first' is True: - print "Automatically returning first search result" + print("Automatically returning first search result") return allSeries0 while True: # return breaks this loop try: - print "Enter choice (first number, return for default, 'all', ? for help):" - ans = raw_input() + print("Enter choice (first number, return for default, 'all', ? for help):") + ans = user_input() except KeyboardInterrupt: raise tvdb_userabort("User aborted (^c keyboard interupt)") except EOFError: @@ -131,13 +145,13 @@ log().debug('Got quit command (q)') raise tvdb_userabort("User aborted ('q' quit command)") elif ans == "?": - print "## Help" - print "# Enter the number that corresponds to the correct show." - print "# a - display all results" - print "# all - display all results" - print "# ? - this help" - print "# q - abort tvnamer" - print "# Press return with no input to select first result" + print("## Help") + print("# Enter the number that corresponds to the correct show.") + print("# a - display all results") + print("# all - display all results") + print("# ? - this help") + print("# q - abort tvnamer") + print("# Press return with no input to select first result") elif ans.lower() in "a", "all": self._displaySeries(allSeries, limit = None) else: @@ -148,8 +162,6 @@ return allSeriesselected_id except IndexError: log().debug('Invalid show number entered!') - print "Invalid number (%s) selected!" + print("Invalid number (%s) selected!") self._displaySeries(allSeries) - #end try - #end while not valid_input
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.