def getShortTV(title): try: tvdbid = getShowId() if tvdbid: log(__name__, 'found show from tvdb: %s' % (tvdbid)) # get tvshow's url from TVDB's id searchurl = 'http://' + apiurl + '/shows/display/' + tvdbid + '.xml?key=' + apikey log(__name__, " BetaSeries query : %s" % (searchurl)) dom = minidom.parse(urllib.urlopen(searchurl)) if len(dom.getElementsByTagName('url')): url = dom.getElementsByTagName('url')[0].childNodes[0] url = url.nodeValue return [url] else: log( __name__, 'show not found from tvdb, try to find from betaseries search') searchurl = 'http://' + apiurl + '/shows/search.xml?title=' + urllib.quote( title) + '&key=' + apikey log(__name__, "search %s on betaseries" % (searchurl)) dom = minidom.parse(urllib.urlopen(searchurl)) log(__name__, " found %s shows" % (dom.getElementsByTagName('url').length)) return [ e.childNodes[0].nodeValue for e in dom.getElementsByTagName('url') ] except Exception as inst: log(__name__, "Error: %s" % (inst))
def getShortTV(title): try: tvdbid = getShowId() if tvdbid: log( __name__ , 'found show from tvdb: %s' % (tvdbid)) # get tvshow's url from TVDB's id searchurl = 'http://' + apiurl + '/shows/display/' + tvdbid + '.xml?key=' + apikey log( __name__ , " BetaSeries query : %s" % (searchurl)) dom = minidom.parse(urllib.urlopen(searchurl)) if len(dom.getElementsByTagName('url')): url = dom.getElementsByTagName('url')[0].childNodes[0] url = url.nodeValue return [url] else: log( __name__ , 'show not found from tvdb, try to find from betaseries search') searchurl = 'http://' + apiurl + '/shows/search.xml?title=' + urllib.quote(title) + '&key=' + apikey log( __name__ , "search %s on betaseries" % (searchurl)) dom = minidom.parse(urllib.urlopen(searchurl)) log( __name__ , " found %s shows" % (dom.getElementsByTagName('url').length) ) return [ e.childNodes[0].nodeValue for e in dom.getElementsByTagName('url') ] except Exception as inst: log( __name__, "Error: %s" % (inst))
def XBMC_OriginalTitle(OriginalTitle): MovieName = xbmc.getInfoLabel("VideoPlayer.OriginalTitle") if MovieName: OriginalTitle = MovieName else: ShowID = getShowId() if ShowID: HTTPResponse = urllib2.urlopen("http://www.thetvdb.com//data/series/%s/" % str(ShowID)).read() if re.findall("<SeriesName>(.*?)</SeriesName>", HTTPResponse, re.IGNORECASE | re.DOTALL): OriginalTitle = re.findall("<SeriesName>(.*?)</SeriesName>", HTTPResponse, re.IGNORECASE | re.DOTALL)[0] return OriginalTitle.encode('ascii', 'replace')
def XBMC_OriginalTitle(OriginalTitle): MovieName = xbmc.getInfoLabel("VideoPlayer.OriginalTitle") if MovieName: OriginalTitle = MovieName else: ShowID = getShowId() if ShowID: HTTPResponse = urllib2.urlopen( "http://www.thetvdb.com//data/series/%s/" % str(ShowID)).read() if re.findall("<SeriesName>(.*?)</SeriesName>", HTTPResponse, re.IGNORECASE | re.DOTALL): OriginalTitle = re.findall("<SeriesName>(.*?)</SeriesName>", HTTPResponse, re.IGNORECASE | re.DOTALL)[0] return OriginalTitle.encode('ascii', 'replace')
def getshowid(showname): showid = None showids = {} if os.path.isfile(showids_filename): showids_filedata = file(showids_filename, 'r').read() showids = eval(showids_filedata) if showname in showids: log( __name__, " show id for '%s' is '%s' (from cachefile '%s')" % (showname, showids[showname], showids_filename)) return showids[showname] if showid is None: tvdbid = getShowId() if tvdbid: if not overloaded: response = apicall("GetShowByTVDBID", [tvdbid]) if overloaded: return None if response is not None: showid = gettextelements(response, "response/showid") if len(showid) == 1: log( __name__, " show id for '%s' is '%s' (found by TVDBid %s)" % (showname, str(showid[0]), tvdbid)) showids[showname] = str(showid[0]) file(showids_filename, 'w').write(repr(showids)) return str(showid[0]) if not overloaded: response = apicall("GetShowByName", [showname]) if overloaded: return None if response is not None: showid = gettextelements(response, "response/showid") if len(showid) == 1: log(__name__, " show id for '%s' is '%s'" % (showname, str(showid[0]))) showids[showname] = str(showid[0]) file(showids_filename, 'w').write(repr(showids)) return str(showid[0]) if (showid is None) and ("'" in showname): if not overloaded: response = apicall("GetShowByName", [string.replace(showname, "'", "''")]) if overloaded: return None if response is not None: showid = gettextelements(response, "response/showid") if len(showid) == 1: log( __name__, " show id for '%s' is '%s' (replaced ' with '')" % (string.replace(showname, "'", "''"), str(showid[0]))) showids[showname] = str(showid[0]) file(showids_filename, 'w').write(repr(showids)) return str(showid[0]) okdialog = xbmcgui.Dialog() ok = okdialog.ok("Error", "Failed to get a show id from Bierdopje for " + showname) log(__name__, " failed to get a show id for '%s'" % showname) return None