def Fanart_Download(self, type, arttype, id, FilePath): try: if type == 'tvshow': arttype = arttype.replace('graphical', 'banner').replace( 'folder', 'poster').replace('fanart', 'landscape') fan = str(fanarttv.get_image_list_TV(id)) file_detail = re.compile("{(.*?)}", re.DOTALL).findall(fan) pref_language = fanarttv.get_abbrev( REAL_SETTINGS.getSetting('limit_preferred_language')) for f in file_detail: languages = re.search("'language' *: *(.*?),", f) art_types = re.search("'art_type' *: *(.*?),", f) fanPaths = re.search("'url' *: *(.*?),", f) if languages and len(languages.group(1)) > 0: language = (languages.group(1)).replace("u'", '').replace( "'", '') if language == pref_language: if art_types and len(art_types.group(1)) > 0: art_type = art_types.group(1).replace( "u'", '').replace("'", '').replace( "[", '').replace("]", '') if art_type.lower() == arttype.lower(): if fanPaths and len(fanPaths.group(1)) > 0: fanPath = fanPaths.group(1).replace( "u'", '').replace("'", '') if fanPath.startswith('http'): requestDownload(fanPath, FilePath) break except: pass
"url: u", "").replace("url: ", "") if tmdbPath.startswith('http'): requestDownload(tmdbPath, MovieFilePath) FanMovieDownload = False except Exception, e: self.logDebug('DownloadArt, tmdbAPI Failed!') pass if FanMovieDownload == True: self.logDebug('DownloadArt, Fanart.TV') try: arttype = arttype.replace('graphical', 'banner').replace( 'folder', 'poster').replace('fanart', 'landscape') fan = str(fanarttv.get_image_list_Movie(id)) file_detail = re.compile("{(.*?)}", re.DOTALL).findall(fan) pref_language = fanarttv.get_abbrev( REAL_SETTINGS.getSetting('limit_preferred_language')) for f in file_detail: languages = re.search("'language' *: *(.*?),", f) art_types = re.search("'art_type' *: *(.*?),", f) fanPaths = re.search("'url' *: *(.*?),", f) if languages and len(languages.group(1)) > 0: language = (languages.group(1)).replace( "u'", '').replace("'", '') if language == pref_language: if art_types and len(art_types.group(1)) > 0: art_type = art_types.group(1).replace( "u'", '').replace("'", '').replace( "[", '').replace("]", '') if art_type.lower() == arttype.lower():
def DownloadArt(self, type, id, arttype, cachefile): self.log('DownloadArt') setImage = '' tvdbAPI = TVDB(TVDB_API_KEY) tmdbAPI = TMDB(TMDB_API_KEY) drive, Dpath = os.path.splitdrive(cachefile) path, filename = os.path.split(Dpath) if not FileAccess.exists(os.path.join(drive, path)): FileAccess.makedirs(os.path.join(drive, path)) if type == 'tvshow': self.logDebug('DownloadArt, tvshow') FanTVDownload = True TVFilePath = cachefile tvdb_Types = ['banner', 'fanart', 'folder', 'poster'] try: if arttype in tvdb_Types: self.logDebug('DownloadArt, TVDB') arttype = arttype.replace('banner', 'graphical').replace( 'folder', 'poster') tvdb = str(tvdbAPI.getBannerByID(id, arttype)) tvdbPath = tvdb.split(', ')[0].replace("[('", "").replace( "'", "") if tvdbPath.startswith('http'): requestDownload(tvdbPath, TVFilePath) FanTVDownload = False except Exception, e: self.log('DownloadArt, tvdbAPI Failed!') pass if FanTVDownload == True: self.logDebug('DownloadArt, Fanart.TV') try: arttype = arttype.replace('graphical', 'banner').replace( 'folder', 'poster').replace('fanart', 'landscape') fan = str(fanarttv.get_image_list_TV(id)) file_detail = re.compile("{(.*?)}", re.DOTALL).findall(fan) pref_language = fanarttv.get_abbrev( REAL_SETTINGS.getSetting('limit_preferred_language')) for f in file_detail: languages = re.search("'language' *: *(.*?),", f) art_types = re.search("'art_type' *: *(.*?),", f) fanPaths = re.search("'url' *: *(.*?),", f) if languages and len(languages.group(1)) > 0: language = (languages.group(1)).replace( "u'", '').replace("'", '') if language == pref_language: if art_types and len(art_types.group(1)) > 0: art_type = art_types.group(1).replace( "u'", '').replace("'", '').replace( "[", '').replace("]", '') if art_type.lower() == arttype.lower(): if fanPaths and len( fanPaths.group(1)) > 0: fanPath = fanPaths.group( 1).replace("u'", '').replace( "'", '') if fanPath.startswith('http'): requestDownload( fanPath, TVFilePath) break except: pass # self.DownloadThread = threading.Timer(5.0, requestDownload,(url,TVFilePath)) # self.DownloadThread.name = "DownloadThread" # if self.DownloadThread.isAlive(): # self.DownloadThread.join() # else: # self.DownloadThread.start() return TVFilePath
def DownloadArt(self, type, id, fle, typeEXT, ART_LOC): self.log('DownloadArt') tvdbAPI = TVDB(TVDB_API_KEY) tmdbAPI = TMDB(TMDB_API_KEY) if not FileAccess.exists(ART_LOC): FileAccess.makedirs(ART_LOC) ArtType = typeEXT.split('.')[0] setImage = '' if type.lower() == 'tvshow': self.log('DownloadArt, tvshow') FanTVDownload = False TVFilePath = os.path.join(ART_LOC, fle) tvdb_Types = ['banner', 'fanart', 'folder', 'poster'] if ArtType in tvdb_Types: self.log('DownloadArt, TVDB') ArtType = ArtType.replace('banner', 'graphical').replace( 'folder', 'poster') tvdb = str(tvdbAPI.getBannerByID(id, ArtType)) try: tvdbPath = tvdb.split(', ')[0].replace("[('", "").replace( "'", "") resource = urllib.urlopen(tvdbPath) output = FileAccess.open(TVFilePath, 'w') output.write(resource.read()) output.close() return TVFilePath except Exception, e: FanTVDownload = True print('tvdbAPI Failed!') pass else: FanTVDownload = True if FanTVDownload == True: self.log('DownloadArt, Fanart.TV') TVFilePath = '' ArtType = ArtType.replace('graphical', 'banner').replace( 'folder', 'poster').replace('fanart', 'landscape') fan = str(fanarttv.get_image_list_TV(id)) file_detail = re.compile("{(.*?)}", re.DOTALL).findall(fan) pref_language = fanarttv.get_abbrev( REAL_SETTINGS.getSetting('limit_preferred_language')) for f in file_detail: languages = re.search("'language' *: *(.*?),", f) art_types = re.search("'art_type' *: *(.*?),", f) fanPaths = re.search("'url' *: *(.*?),", f) if languages and len(languages.group(1)) > 0: language = (languages.group(1)).replace("u'", '').replace( "'", '') if language == pref_language: print language if art_types and len(art_types.group(1)) > 0: art_type = art_types.group(1).replace( "u'", '').replace("'", '').replace( "[", '').replace("]", '') if art_type.lower() == ArtType.lower(): print art_type if fanPaths and len(fanPaths.group(1)) > 0: fanPath = fanPaths.group(1).replace( "u'", '').replace("'", '') print fanPath if fanPath.startswith('http'): resource = urllib.urlopen(fanPath) output = FileAccess.open( TVFilePath, 'w') output.write(resource.read()) output.close() break return TVFilePath