def getSeasonArtByTheTvDbId(self, info): url = self.apiSeriesByID url = re.sub("<seriesid>", info.TheTvDbId, url) url = re.sub("<lang>", u"banners", url) xml = WebGrabber.getXml(url, cache=False) if xml is None: WebGrabber.removeFromCache(url) printl(" <- None (xml is None)", self) return None movieList = xml.getElementsByTagName("Banners") seasonsFound = [] info.SeasonPoster.clear() for eMovie in movieList: for p in eMovie.getElementsByTagName("Banner"): bannerType = p.getElementsByTagName( "BannerType")[0].childNodes[0].data bannerType2 = p.getElementsByTagName( "BannerType2")[0].childNodes[0].data bannerPath = p.getElementsByTagName( "BannerPath")[0].childNodes[0].data if bannerType == "season" and bannerType2 == "season": season = p.getElementsByTagName( "Season")[0].childNodes[0].data if season not in seasonsFound: seasonsFound.append(season) info.SeasonPoster[str( season)] = self.apiArt + bannerPath if len(info.SeasonPoster.values()) > 0: return info return None
def getSeasonArtByTheTvDbId(self, info): url = self.apiSeriesByID; url = re.sub("<seriesid>", info.TheTvDbId, url) url = re.sub("<lang>", u"banners", url) xml = WebGrabber.getXml(url, cache=False); if xml is None: WebGrabber.removeFromCache(url) printl(" <- None (xml is None)", self) return None movieList = xml.getElementsByTagName("Banners") seasonsFound = [] info.SeasonPoster.clear() for eMovie in movieList: for p in eMovie.getElementsByTagName("Banner"): bannerType = p.getElementsByTagName("BannerType")[0].childNodes[0].data bannerType2 = p.getElementsByTagName("BannerType2")[0].childNodes[0].data bannerPath = p.getElementsByTagName("BannerPath")[0].childNodes[0].data if bannerType == "season" and bannerType2 == "season": season = p.getElementsByTagName("Season")[0].childNodes[0].data if season not in seasonsFound: seasonsFound.append(season) info.SeasonPoster[str(season)] = self.apiArt + bannerPath if len(info.SeasonPoster.values()) > 0: return info return None
def getSerie(self, info, lang): if info.TheTvDbId == info.TheTvDbIdNull: printl(" <- None (info.TheTvDbId == info.TheTvDbIdNull)", self) return None lang = lang.lower() #if lang == u"en": # return info #en already parsed using getSerieByImdbID() url = self.apiSeriesByID url = re.sub("<seriesid>", info.TheTvDbId, url) url = re.sub("<lang>", lang, url) xml = WebGrabber.getXml(url) if xml is None: WebGrabber.removeFromCache(url) printl(" <- None (xml is None)", self) return None movieList = xml.getElementsByTagName("Series") for eMovie in movieList: entryLang = self.getLanguage(eMovie).lower() if entryLang != lang: continue #tmp = self.getTvdbId(info, eMovie) #if tmp is not None: # info = tmp #tmp = self.getImdbId(info, eMovie) #if tmp is not None: # info = tmp tmp = self.getSeriesName(info, eMovie) if tmp is not None: info = tmp tmp = self.getOverview(info, eMovie) if tmp is not None: info = tmp tmp = self.getFirstAired(info, eMovie) if tmp is not None: info = tmp tmp = self.getRuntime(info, eMovie) if tmp is not None: info = tmp tmp = self.getRating(info, eMovie) if tmp is not None: info = tmp tmp = self.getGenre(info, eMovie) if tmp is not None: info = tmp return info WebGrabber.removeFromCache(url) printl(" <- None (eof)", self) return None
def getMovie(self, info, lang): if info.TmDbId == info.TmDbIdNull: printl(" <- None (info.TmDbId == info.TmDbIdNull)", self) return None lang = lang.lower() if lang == u"en": return info #en already parsed using getSerieByImdbID() url = self.apiImdbLookup url = re.sub("<imdbid>", info.ImdbId, url) url = re.sub("<lang>", lang, url) xml = WebGrabber.getXml(url) if xml is None: printl(" <- None (xml is None)", self) return None movieList = xml.getElementsByTagName("movie") for eMovie in movieList: if self.getTranslated(eMovie) is False: continue #tmp = self.getTmdbId(info, eMovie) #if tmp is not None: # info = tmp #tmp = self.getImdbId(info, eMovie) #if tmp is not None: # info = tmp tmp = self.getName(info, eMovie) if tmp is not None: info = tmp tmp = self.getOverview(info, eMovie) if tmp is not None: info = tmp tmp = self.getReleased(info, eMovie) if tmp is not None: info = tmp tmp = self.getRating(info, eMovie) if tmp is not None: info = tmp tmp = self.getRuntime(info, eMovie) if tmp is not None: info = tmp tmp = self.getGenre(info, eMovie) if tmp is not None: info = tmp return info printl(" <- None (eof)", self) return None
def getSerieByImdbID(self, info): if info.ImdbId == info.ImdbIdNull: printl(" <- None (info.ImdbId == info.ImdbIdNull)", self) return None url = self.apiSeriesByImdbID + info.ImdbId xml = WebGrabber.getXml(url) if xml is None: WebGrabber.removeFromCache(url) printl(" <- None (xml is None)", self) return None movieList = xml.getElementsByTagName("Series") for eMovie in movieList: tmp = self.getTvdbId(info, eMovie) if tmp is not None: info = tmp #tmp = self.getImdbId(info, eMovie) #if tmp is not None: # info = tmp tmp = self.getSeriesName(info, eMovie) if tmp is not None: info = tmp tmp = self.getOverview(info, eMovie) if tmp is not None: info = tmp tmp = self.getFirstAired(info, eMovie) if tmp is not None: info = tmp #tmp = self.getRuntime(info, eMovie) #if tmp is not None: # info = tmp tmp = self.getRating(info, eMovie) if tmp is not None: info = tmp tmp = self.getGenre(info, eMovie) if tmp is not None: info = tmp return info WebGrabber.removeFromCache(url) printl(" <- None (eof)", self) return None
def getMovieByImdbID(self, info): if info.ImdbId == info.ImdbIdNull: printl(" <- None (info.ImdbId == info.ImdbIdNull)", self) return None url = self.apiImdbLookup url = re.sub("<imdbid>", info.ImdbId, url) url = re.sub("<lang>", u"en", url) xml = WebGrabber.getXml(url) if xml is None: printl(" <- None (xml is None)", self) return None movieList = xml.getElementsByTagName("movie") for eMovie in movieList: tmp = self.getTmdbId(info, eMovie) if tmp is not None: info = tmp #tmp = self.getImdbId(info, eMovie) #if tmp is not None: # info = tmp tmp = self.getName(info, eMovie) if tmp is not None: info = tmp tmp = self.getOverview(info, eMovie) if tmp is not None: info = tmp tmp = self.getReleased(info, eMovie) if tmp is not None: info = tmp tmp = self.getRating(info, eMovie) if tmp is not None: info = tmp tmp = self.getRuntime(info, eMovie) if tmp is not None: info = tmp tmp = self.getGenre(info, eMovie) if tmp is not None: info = tmp return info printl(" <- None (eof)", self) return None
def getArtByTheTvDbId(self, info): if info.TheTvDbId == info.TheTvDbIdNull: printl(" <- None (info.TheTvDbId == info.TheTvDbIdNull)", self) return None url = self.apiSeriesByID; url = re.sub("<seriesid>", info.TheTvDbId, url) url = re.sub("<lang>", u"en", url) xml = WebGrabber.getXml(url); if xml is None: WebGrabber.removeFromCache(url) printl(" <- None (xml is None)", self) return None movieList = xml.getElementsByTagName("Series") for eMovie in movieList: for p in eMovie.getElementsByTagName("poster"): if len(p.childNodes) > 0: info.Poster = self.apiArt + p.childNodes[0].data break for p in eMovie.getElementsByTagName("fanart"): if len(p.childNodes) > 0: info.Backdrop = self.apiArt + p.childNodes[0].data break if info.isTypeSerie(): tmp = self.getSeasonArtByTheTvDbId(info) if tmp is not None and len(tmp.SeasonPoster.values()) > 0: info = tmp else: info.SeasonPoster.clear() if len(info.Poster) > 0 or len(info.Backdrop) > 0: return info WebGrabber.removeFromCache(url) printl(" <- None (eof)", self) return None
def getArtByTheTvDbId(self, info): if info.TheTvDbId == info.TheTvDbIdNull: printl(" <- None (info.TheTvDbId == info.TheTvDbIdNull)", self) return None url = self.apiSeriesByID url = re.sub("<seriesid>", info.TheTvDbId, url) url = re.sub("<lang>", u"en", url) xml = WebGrabber.getXml(url) if xml is None: WebGrabber.removeFromCache(url) printl(" <- None (xml is None)", self) return None movieList = xml.getElementsByTagName("Series") for eMovie in movieList: for p in eMovie.getElementsByTagName("poster"): if len(p.childNodes) > 0: info.Poster = self.apiArt + p.childNodes[0].data break for p in eMovie.getElementsByTagName("fanart"): if len(p.childNodes) > 0: info.Backdrop = self.apiArt + p.childNodes[0].data break if info.isTypeSerie(): tmp = self.getSeasonArtByTheTvDbId(info) if tmp is not None and len(tmp.SeasonPoster.values()) > 0: info = tmp else: info.SeasonPoster.clear() if len(info.Poster) > 0 or len(info.Backdrop) > 0: return info WebGrabber.removeFromCache(url) printl(" <- None (eof)", self) return None
def getArtByImdbId(self, info): if info.ImdbId == info.ImdbIdNull: printl(" <- None (info.ImdbId == info.ImdbIdNull)", self) return None url = self.apiImdbLookup url = re.sub("<imdbid>", info.ImdbId, url) url = re.sub("<lang>", u"en", url) xml = WebGrabber.getXml(url) if xml is None: printl(" <- None (xml is None)", self) return None movieList = xml.getElementsByTagName("movie") # The best picture is always the first, we may need to check addidonal languages for eMovie in movieList: for p in eMovie.getElementsByTagName("image"): if p.getAttribute("type") == "poster" and p.getAttribute("size") == "original": info.Poster = p.getAttribute("url") if len(info.Poster) > 0: break for eMovie in movieList: for p in eMovie.getElementsByTagName("image"): if p.getAttribute("type") == "backdrop" and p.getAttribute("size") == "original": info.Backdrop = p.getAttribute("url") if len(info.Backdrop) > 0: break if len(info.Poster) > 0 or len(info.Backdrop) > 0: return info printl(" <- None (eof)", self) return None
def getEpisode(self, info, lang): if info.TheTvDbId == info.TheTvDbIdNull or info.Episode == -1 or info.Season == -1: printl(" <- None (info.TheTvDbId == info.TheTvDbIdNull or info.Episode == -1 or info.Season == -1)", self) return None lang = lang.lower() url = self.apiSearchEpisode # self.apiSearchAllEpisodes url = re.sub("<seriesid>", info.TheTvDbId, url) url = re.sub("<lang>", lang, url) url = re.sub("<season>", unicode(info.Season), url) url = re.sub("<episode>", unicode(info.Episode), url) xml = WebGrabber.getXml(url) if xml is None: WebGrabber.removeFromCache(url) printl(" <- None (xml is None)", self) return None movieList = xml.getElementsByTagName("Episode") for eMovie in movieList: entryLang = self.getLanguage(eMovie).lower() if entryLang != lang: continue episode = info.Episode season = info.Season tmp = self.getEpisodeAndSeasonNumber(info, eMovie) if tmp is None: info.Episode = episode info.Season = season continue else: info = tmp if info.Episode != episode or info.Season != season: info.Episode = episode info.Season = season continue #tmp = self.getTvdbId(info, eMovie) #if tmp is not None: # info = tmp #tmp = self.getImdbId(info, eMovie) #if tmp is not None: # info = tmp tmp = self.getEpisodeName(info, eMovie) if tmp is not None: info = tmp tmp = self.getOverview(info, eMovie) if tmp is not None: info = tmp tmp = self.getFirstAired(info, eMovie) if tmp is not None: info = tmp tmp = self.getDirector(info, eMovie) if tmp is not None: info = tmp tmp = self.getWriter(info, eMovie) if tmp is not None: info = tmp tmp = self.getRuntime(info, eMovie) if tmp is not None: info = tmp tmp = self.getRating(info, eMovie) if tmp is not None: info = tmp tmp = self.getGenre(info, eMovie) if tmp is not None: info = tmp return info WebGrabber.removeFromCache(url) printl(" <- None (eof)", self) return None
def getEpisode(self, info, lang): if info.TheTvDbId == info.TheTvDbIdNull or info.Episode == -1 or info.Season == -1: printl( " <- None (info.TheTvDbId == info.TheTvDbIdNull or info.Episode == -1 or info.Season == -1)", self) return None lang = lang.lower() url = self.apiSearchEpisode # self.apiSearchAllEpisodes url = re.sub("<seriesid>", info.TheTvDbId, url) url = re.sub("<lang>", lang, url) url = re.sub("<season>", unicode(info.Season), url) url = re.sub("<episode>", unicode(info.Episode), url) xml = WebGrabber.getXml(url) if xml is None: WebGrabber.removeFromCache(url) printl(" <- None (xml is None)", self) return None movieList = xml.getElementsByTagName("Episode") for eMovie in movieList: entryLang = self.getLanguage(eMovie).lower() if entryLang != lang: continue episode = info.Episode season = info.Season tmp = self.getEpisodeAndSeasonNumber(info, eMovie) if tmp is None: info.Episode = episode info.Season = season continue else: info = tmp if info.Episode != episode or info.Season != season: info.Episode = episode info.Season = season continue #tmp = self.getTvdbId(info, eMovie) #if tmp is not None: # info = tmp #tmp = self.getImdbId(info, eMovie) #if tmp is not None: # info = tmp tmp = self.getEpisodeName(info, eMovie) if tmp is not None: info = tmp tmp = self.getOverview(info, eMovie) if tmp is not None: info = tmp tmp = self.getFirstAired(info, eMovie) if tmp is not None: info = tmp tmp = self.getDirector(info, eMovie) if tmp is not None: info = tmp tmp = self.getWriter(info, eMovie) if tmp is not None: info = tmp tmp = self.getRuntime(info, eMovie) if tmp is not None: info = tmp tmp = self.getRating(info, eMovie) if tmp is not None: info = tmp tmp = self.getGenre(info, eMovie) if tmp is not None: info = tmp return info WebGrabber.removeFromCache(url) printl(" <- None (eof)", self) return None