mirror of
https://github.com/moparisthebest/SickRage
synced 2024-12-12 11:02:21 -05:00
Improved the API Handlers and modulaized it.
This commit is contained in:
parent
f1e8a53856
commit
047568ec76
@ -29,9 +29,8 @@ import urllib
|
|||||||
from threading import Lock
|
from threading import Lock
|
||||||
|
|
||||||
# apparently py2exe won't build these unless they're imported somewhere
|
# apparently py2exe won't build these unless they're imported somewhere
|
||||||
from sickbeard import indexers
|
from sickbeard import providers, metadata, indexers
|
||||||
from indexers import indexer_api, indexer_exceptions, indexer_config
|
from indexers import indexer_api, indexer_exceptions
|
||||||
from sickbeard import providers, metadata
|
|
||||||
from providers import ezrss, tvtorrents, btn, newznab, womble, thepiratebay, torrentleech, kat, publichd, iptorrents, omgwtfnzbs, scc, hdtorrents, torrentday, hdbits, nextgen
|
from providers import ezrss, tvtorrents, btn, newznab, womble, thepiratebay, torrentleech, kat, publichd, iptorrents, omgwtfnzbs, scc, hdtorrents, torrentday, hdbits, nextgen
|
||||||
from sickbeard.config import CheckSection, check_setting_int, check_setting_str, ConfigMigrator
|
from sickbeard.config import CheckSection, check_setting_int, check_setting_str, ConfigMigrator
|
||||||
from sickbeard import searchCurrent, searchBacklog, showUpdater, versionChecker, properFinder, autoPostProcesser, subtitles, traktWatchListChecker
|
from sickbeard import searchCurrent, searchBacklog, showUpdater, versionChecker, properFinder, autoPostProcesser, subtitles, traktWatchListChecker
|
||||||
|
@ -16,4 +16,20 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with Sick Beard. If not, see <http://www.gnu.org/licenses/>.
|
# along with Sick Beard. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
__all__ = ["indexer_api", "indexer_exceptions", "indexer_config"]
|
__all__ = ["generic","indexer_api","indexer_exceptions"]
|
||||||
|
|
||||||
|
import indexer_api, indexer_exceptions
|
||||||
|
|
||||||
|
def getClientModule(name):
|
||||||
|
|
||||||
|
name = name.lower()
|
||||||
|
prefix = "sickbeard.indexers."
|
||||||
|
|
||||||
|
return __import__(prefix+name, fromlist=__all__)
|
||||||
|
|
||||||
|
def getClientIstance(name):
|
||||||
|
|
||||||
|
module = getClientModule(name)
|
||||||
|
className = module.__class__.__name__
|
||||||
|
|
||||||
|
return getattr(module, className)
|
61
sickbeard/indexers/generic.py
Normal file
61
sickbeard/indexers/generic.py
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
# Author: Nic Wolfe <nic@wolfeden.ca>
|
||||||
|
# URL: http://code.google.com/p/sickbeard/
|
||||||
|
#
|
||||||
|
# This file is part of Sick Beard.
|
||||||
|
#
|
||||||
|
# Sick Beard is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# Sick Beard is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with Sick Beard. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
class GenericIndexer(object):
|
||||||
|
def __init__(self, indexer):
|
||||||
|
|
||||||
|
INDEXER_NONE = None
|
||||||
|
INDEXER_TVDB = 'Tvdb'
|
||||||
|
INDEXER_TVRAGE = 'TVRage'
|
||||||
|
|
||||||
|
INDEXER_NAME = {}
|
||||||
|
INDEXER_NAME[INDEXER_NONE] = ''
|
||||||
|
INDEXER_NAME[INDEXER_TVDB] = 'theTVDB'
|
||||||
|
INDEXER_NAME[INDEXER_TVRAGE] = 'TVRage'
|
||||||
|
|
||||||
|
INDEXER_API_KEY = {}
|
||||||
|
INDEXER_API_KEY[INDEXER_NONE] = ''
|
||||||
|
INDEXER_API_KEY[INDEXER_TVDB] = '9DAF49C96CBF8DAC'
|
||||||
|
INDEXER_API_KEY[INDEXER_TVRAGE] = 'Uhewg1Rr0o62fvZvUIZt'
|
||||||
|
|
||||||
|
INDEXER_BASEURL = {}
|
||||||
|
INDEXER_BASEURL[INDEXER_NONE] = ''
|
||||||
|
INDEXER_BASEURL[INDEXER_TVDB] = 'http://thetvdb.com/api/' + INDEXER_API_KEY[INDEXER_TVDB]
|
||||||
|
INDEXER_BASEURL[INDEXER_TVRAGE] = 'http://tvrage.com/showinfo?key=' + INDEXER_API_KEY[INDEXER_TVRAGE] + 'sid='
|
||||||
|
|
||||||
|
INDEXER_API_PARMS = {}
|
||||||
|
INDEXER_API_PARMS[INDEXER_NONE] = ''
|
||||||
|
INDEXER_API_PARMS[INDEXER_TVDB] = {'apikey': INDEXER_API_KEY[INDEXER_TVDB],
|
||||||
|
'language': 'en',
|
||||||
|
'useZip': True}
|
||||||
|
|
||||||
|
INDEXER_API_PARMS[INDEXER_TVRAGE] = {'apikey': INDEXER_API_KEY[INDEXER_TVRAGE],
|
||||||
|
'language': 'en'}
|
||||||
|
|
||||||
|
config = {}
|
||||||
|
config['valid_languages'] = [
|
||||||
|
"da", "fi", "nl", "de", "it", "es", "fr","pl", "hu","el","tr",
|
||||||
|
"ru","he","ja","pt","zh","cs","sl", "hr","ko","en","sv","no"]
|
||||||
|
|
||||||
|
config['langabbv_to_id'] = {'el': 20, 'en': 7, 'zh': 27,
|
||||||
|
'it': 15, 'cs': 28, 'es': 16, 'ru': 22, 'nl': 13, 'pt': 26, 'no': 9,
|
||||||
|
'tr': 21, 'pl': 18, 'fr': 17, 'hr': 31, 'de': 14, 'da': 10, 'fi': 11,
|
||||||
|
'hu': 19, 'ja': 25, 'he': 24, 'ko': 32, 'sv': 8, 'sl': 30}
|
||||||
|
|
||||||
|
self.api_parms = config['api_parms'] = INDEXER_API_PARMS[indexer]
|
||||||
|
self.name = config['name'] = INDEXER_NAME[indexer]
|
@ -18,30 +18,23 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
import sickbeard
|
import sickbeard
|
||||||
|
import generic
|
||||||
|
|
||||||
from indexer_config import *
|
|
||||||
from lib.tvdb_api.tvdb_api import Tvdb
|
from lib.tvdb_api.tvdb_api import Tvdb
|
||||||
from lib.tvrage_api.tvrage_api import TVRage
|
from lib.tvrage_api.tvrage_api import TVRage
|
||||||
|
|
||||||
class indexerApi:
|
class indexerApi(generic.GenericIndexer):
|
||||||
def __new__(self, indexer):
|
def __init__(self, indexer=None, *args, **kwargs):
|
||||||
cls = type(indexer)
|
super(indexerApi, self).__init__(indexer)
|
||||||
new_type = type(cls.__name__ + '_wrapped', (indexerApi, cls), {})
|
|
||||||
return object.__new__(new_type)
|
|
||||||
|
|
||||||
def __init__(self, indexer=None, language=None, *args, **kwargs):
|
if indexer:
|
||||||
self.name = indexer
|
self.api_parms.update(**kwargs)
|
||||||
self.config = INDEXER_CONFIG.copy()
|
|
||||||
|
|
||||||
# wrap the indexer API object and return it back
|
|
||||||
if indexer is not None:
|
|
||||||
if sickbeard.CACHE_DIR:
|
if sickbeard.CACHE_DIR:
|
||||||
INDEXER_API_PARMS[indexer]['cache'] = os.path.join(sickbeard.CACHE_DIR, indexer)
|
self.api_parms['cache'] = os.path.join(sickbeard.CACHE_DIR, indexer)
|
||||||
|
|
||||||
lINDEXER_API_PARMS = INDEXER_API_PARMS[indexer].copy()
|
# wrap the indexer API object and return it back
|
||||||
lINDEXER_API_PARMS.update(**kwargs)
|
self._wrapped = eval(indexer)(*args, **self.api_parms)
|
||||||
|
|
||||||
self._wrapped = eval(indexer)(*args, **lINDEXER_API_PARMS)
|
|
||||||
|
|
||||||
def __getattr__(self, attr):
|
def __getattr__(self, attr):
|
||||||
return getattr(self._wrapped, attr)
|
return getattr(self._wrapped, attr)
|
||||||
|
@ -32,7 +32,6 @@ from sickbeard import logger
|
|||||||
from sickbeard import encodingKludge as ek
|
from sickbeard import encodingKludge as ek
|
||||||
from sickbeard.exceptions import ex
|
from sickbeard.exceptions import ex
|
||||||
|
|
||||||
|
|
||||||
from sickbeard.indexers import indexer_api, indexer_exceptions
|
from sickbeard.indexers import indexer_api, indexer_exceptions
|
||||||
|
|
||||||
class GenericMetadata():
|
class GenericMetadata():
|
||||||
|
@ -21,7 +21,6 @@ import datetime
|
|||||||
import sickbeard
|
import sickbeard
|
||||||
|
|
||||||
from sickbeard.indexers import indexer_api, indexer_exceptions
|
from sickbeard.indexers import indexer_api, indexer_exceptions
|
||||||
from sickbeard.indexers.indexer_config import INDEXER_BASEURL
|
|
||||||
|
|
||||||
from sickbeard import logger, exceptions, helpers
|
from sickbeard import logger, exceptions, helpers
|
||||||
from sickbeard.exceptions import ex
|
from sickbeard.exceptions import ex
|
||||||
@ -154,7 +153,7 @@ class XBMC_12PlusMetadata(generic.GenericMetadata):
|
|||||||
episodeguideurl = etree.SubElement(episodeguide, "url")
|
episodeguideurl = etree.SubElement(episodeguide, "url")
|
||||||
episodeguideurl2 = etree.SubElement(tv_node, "episodeguideurl")
|
episodeguideurl2 = etree.SubElement(tv_node, "episodeguideurl")
|
||||||
if getattr(myShow, 'id', None) is not None:
|
if getattr(myShow, 'id', None) is not None:
|
||||||
showurl = INDEXER_BASEURL[show_obj.indexer] + '/series/' + myShow["id"] + '/all/en.zip'
|
showurl = indexer_api.indexerApi(show_obj.indexer) + '/series/' + myShow["id"] + '/all/en.zip'
|
||||||
episodeguideurl.text = showurl
|
episodeguideurl.text = showurl
|
||||||
episodeguideurl2.text = showurl
|
episodeguideurl2.text = showurl
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user