Ejemplo n.º 1
0
    def DownloadArt_Thread(self, data):
        self.log('DownloadArt_Thread')
        type = data[0]
        id = data[1]
        arttype = data[2]
        arttype_fallback = data[3]
        cachefile = data[4]
        print cachefile
        drive, Dpath = os.path.splitdrive(cachefile)
        path, filename = os.path.split(Dpath)
        print drive, Dpath, path, filename

        if not FileAccess.exists(os.path.join(drive,path)):
            FileAccess.makedirs(os.path.join(drive,path))   
                
        if type == 'tvshow':
            self.logDebug('DownloadArt_Thread, tvshow')
            FanTVDownload = True
            TVFilePath = cachefile
            tvdb_Types = ['banner', 'fanart', 'folder', 'poster']
                
            try:
                if arttype in tvdb_Types:
                    self.logDebug('DownloadArt_Thread, TVDB')
                    arttype = arttype.replace('banner', 'graphical').replace('folder', 'poster')
                    tvdb = str(self.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_Thread, self.tvdbAPI Failed!')
                pass
                
            if FanTVDownload == True:
                self.logDebug('DownloadArt_Thread, Fanart.TV')
                try:
                    arttype = arttype.replace('graphical', 'banner').replace('folder', 'poster').replace('fanart', 'landscape')
                    fan = str(self.fanarttv.get_image_list_TV(id))
                    file_detail = re.compile( "{(.*?)}", re.DOTALL ).findall(fan)
                    pref_language = self.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
Ejemplo n.º 2
0
 def findTVDBArt(self, type, id, arttype, arttypeEXT):
     self.log('findTVDBArt')
     url = ''
     tvdb = str(self.tvdbAPI.getBannerByID(id, arttype))
     tvdbPath = tvdb.split(', ')[0].replace("[('", "").replace("'", "") 
     if tvdbPath.startswith('http'):
         return tvdbPath
     return url
Ejemplo n.º 3
0
 def findTVDBArt(self, type, id, arttype, arttypeEXT):
     self.log('findTVDBArt')
     url = ''
     tvdb = str(self.tvdbAPI.getBannerByID(id, arttype))
     tvdbPath = tvdb.split(', ')[0].replace("[('", "").replace("'", "")
     if tvdbPath.startswith('http'):
         url = tvdbPath
     return url
Ejemplo n.º 4
0
    def DownloadArt_Thread(self, type, id, arttype, cachefile, chname, mpath, arttypeEXT):
        self.log('DownloadArt_Thread')
        try:
            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.log('DownloadArt, tvshow')
                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(self.tvdbAPI.getBannerByID(id, arttype))
                    tvdbPath = tvdb.split(', ')[0].replace("[('", "").replace("'", "") 
                    if tvdbPath.startswith('http'):
                        self.log('DownloadArt, return TV TVDB')
                        return download_silent(tvdbPath,cachefile)
                
                self.log('DownloadArt, Fanart.TV')
                arttype = arttype.replace('graphical', 'banner').replace('folder', 'poster')
                fan = str(self.fanarttv.get_image_list_TV(id))
                file_detail = re.compile( "{(.*?)}", re.DOTALL ).findall(fan)
                pref_language = get_abbrev(REAL_SETTINGS.getSetting('limit_preferred_language'))
                print file_detail
                for f in file_detail:
                    try:
                        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.lower() == pref_language.lower():
                                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'):
                                                self.log('DownloadArt, return TV Fanart.tv')
                                                return download_silent(fanPath,cachefile)
                    except:
                        pass

            elif type == 'movie':
                self.log('DownloadArt, movie')
                tmdb_Types = ['banner', 'fanart', 'folder', 'poster']

                if arttype in tmdb_Types:
                    self.log('DownloadArt, TMDB')
                    arttype = arttype.replace('folder', 'poster')
                    tmdb = self.tmdbAPI.get_image_list(id)
                    data = str(tmdb).replace("[", "").replace("]", "").replace("'", "")
                    data = data.split('}, {')
                    tmdbPath = str([s for s in data if arttype in s]).split("', 'width: ")[0]
                    match = re.search('url *: *(.*?),', tmdbPath)
                    if match:
                        tmdbPath = match.group().replace(",", "").replace("url: u", "").replace("url: ", "")
                        if tmdbPath.startswith('http'):
                            FanMovieDownload = False 
                            self.log('DownloadArt, return Movie TMDB')
                            return download_silent(tmdbPath,cachefile)

                self.log('DownloadArt, Fanart.TV')
                arttype = arttype.replace('folder', 'poster')
                fan = str(self.fanarttv.get_image_list_Movie(id))
                file_detail = re.compile( "{(.*?)}", re.DOTALL ).findall(fan)
                # print file_detail
                pref_language = get_abbrev(REAL_SETTINGS.getSetting('limit_preferred_language'))
                
                for f in file_detail:
                    try:
                        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.lower() == pref_language.lower():
                                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'):
                                                self.log('DownloadArt, return Movie Fanart.tv')
                                                return download_silent(fanPath,cachefile)
                    except:
                        pass
            self.log('DownloadArt, Trying Fallback Download')
            self.DownloadArt(type, id, self.getFallback_Arttype(arttype), cachefile, chname, mpath, self.getFallback_Arttype(arttype))                
        except Exception,e:  
            self.log("DownloadArt, Failed!" + str(e), xbmc.LOGERROR)
            self.log(traceback.format_exc(), xbmc.LOGERROR)
Ejemplo n.º 5
0
    def DownloadArt(self, type, id, arttype, cachefile):
        self.log('DownloadArt')
        setImage = ''
        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(self.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, self.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(self.fanarttv.get_image_list_TV(id))
                    file_detail = re.compile("{(.*?)}", re.DOTALL).findall(fan)
                    pref_language = self.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
Ejemplo n.º 6
0
    def DownloadArt_Thread(self, data):
        self.logDebug('DownloadArt_Thread, data = ' + str(data))
        type = data[0]
        id = data[1]
        arttype = data[2]
        cachefile = data[3]
        chname = data[4]
        mpath = data[5]
        arttypeEXT = data[6]
        try:
            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_Thread, tvshow')
                tvdb_Types = ['banner', 'fanart', 'folder', 'poster']

                if arttype in tvdb_Types:
                    self.logDebug('DownloadArt_Thread, TVDB')
                    arttype = arttype.replace('banner', 'graphical').replace(
                        'folder', 'poster')
                    tvdb = str(self.tvdbAPI.getBannerByID(id, arttype))
                    tvdbPath = tvdb.split(', ')[0].replace("[('", "").replace(
                        "'", "")
                    if tvdbPath.startswith('http'):
                        self.logDebug('DownloadArt_Thread, return TV TVDB')
                        return download_silent(tvdbPath, cachefile)

                self.logDebug('DownloadArt_Thread, Fanart.TV')
                arttype = arttype.replace('graphical', 'banner').replace(
                    'folder', 'poster')
                fan = str(self.fanarttv.get_image_list_TV(id))
                file_detail = re.compile("{(.*?)}", re.DOTALL).findall(fan)
                pref_language = get_abbrev(
                    REAL_SETTINGS.getSetting('limit_preferred_language'))

                for f in file_detail:
                    try:
                        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.lower() == pref_language.lower():
                                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'):
                                                self.logDebug(
                                                    'DownloadArt_Thread, return TV Fanart.tv'
                                                )
                                                return download_silent(
                                                    fanPath, cachefile)
                    except:
                        pass

            elif type == 'movie':
                self.logDebug('DownloadArt_Thread, movie')
                tmdb_Types = ['banner', 'fanart', 'folder', 'poster']

                if arttype in tmdb_Types:
                    self.logDebug('DownloadArt_Thread, TMDB')
                    arttype = arttype.replace('folder', 'poster')
                    tmdb = self.tmdbAPI.get_image_list(id)
                    data = str(tmdb).replace("[",
                                             "").replace("]",
                                                         "").replace("'", "")
                    data = data.split('}, {')
                    tmdbPath = str([s for s in data
                                    if arttype in s]).split("', 'width: ")[0]
                    match = re.search('url *: *(.*?),', tmdbPath)
                    if match:
                        tmdbPath = match.group().replace(",", "").replace(
                            "url: u", "").replace("url: ", "")
                        if tmdbPath.startswith('http'):
                            FanMovieDownload = False
                            self.logDebug(
                                'DownloadArt_Thread, return Movie TMDB')
                            return download_silent(tmdbPath, cachefile)

                self.logDebug('DownloadArt_Thread, Fanart.TV')
                arttype = arttype.replace('folder', 'poster')
                fan = str(self.fanarttv.get_image_list_Movie(id))
                file_detail = re.compile("{(.*?)}", re.DOTALL).findall(fan)
                # print file_detail
                pref_language = get_abbrev(
                    REAL_SETTINGS.getSetting('limit_preferred_language'))

                for f in file_detail:
                    try:
                        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.lower() == pref_language.lower():
                                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'):
                                                self.logDebug(
                                                    'DownloadArt_Thread, return Movie Fanart.tv'
                                                )
                                                return download_silent(
                                                    fanPath, cachefile)
                    except:
                        pass
            self.logDebug('DownloadArt_Thread, Trying Fallback Download')
            self.DownloadArt(type, id, self.getFallback_Arttype(arttype),
                             cachefile, chname, mpath,
                             self.getFallback_Arttype(arttype))
        except Exception, e:
            self.log("DownloadArt_Thread, Failed!" + str(e), xbmc.LOGERROR)
Ejemplo n.º 7
0
    def DownloadArt_Thread(self, data):
        self.log('DownloadArt_Thread')
        try:
            if getProperty("PseudoTVRunning") == "True":   
                type = data[0]
                id = data[1]
                arttype = data[2]
                arttype_fallback = data[3]
                cachefile = data[4]
                chname = data[5]
                mpath = data[6]
                arttypeEXT = data[7]
                
                # print cachefile
                drive, Dpath = os.path.splitdrive(cachefile)
                path, filename = os.path.split(Dpath)
                # print drive, Dpath, path, filename

                if not FileAccess.exists(os.path.join(drive,path)):
                    FileAccess.makedirs(os.path.join(drive,path))   
                        
                if type == 'tvshow':
                    self.logDebug('DownloadArt_Thread, tvshow')
                    FanTVDownload = True
                    TVFilePath = cachefile
                    tvdb_Types = ['banner', 'fanart', 'folder', 'poster']
                        
                    try:
                        if arttype in tvdb_Types:
                            self.logDebug('DownloadArt_Thread, TVDB')
                            arttype = arttype.replace('banner', 'graphical').replace('folder', 'poster')
                            tvdb = str(self.tvdbAPI.getBannerByID(id, arttype))
                            tvdbPath = tvdb.split(', ')[0].replace("[('", "").replace("'", "") 
                            if tvdbPath.startswith('http'):
                                download_silent(tvdbPath,TVFilePath)
                                FanTVDownload = False
                    except Exception,e:
                        self.log("script.pseudotv.live-Artdownloader: DownloadArt_Thread, TVDB Failed" + str(e), xbmc.LOGERROR)
                        buggalo.onExceptionRaised() 
                        
                    if FanTVDownload == True:
                        self.logDebug('DownloadArt_Thread, Fanart.TV')
                        try:
                            arttype = arttype.replace('graphical', 'banner').replace('folder', 'poster').replace('fanart', 'landscape')
                            fan = str(self.fanarttv.get_image_list_TV(id))
                            file_detail = re.compile( "{(.*?)}", re.DOTALL ).findall(fan)
                            pref_language = self.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'):
                                                        download_silent(fanPath,TVFilePath)
                                                        break 
                        except Exception,e:  
                            self.log("script.pseudotv.live-Artdownloader: DownloadArt_Thread, Fanart.TV Failed" + str(e), xbmc.LOGERROR)
                            buggalo.onExceptionRaised() 
                        
                elif type == 'movie':
                    self.logDebug('DownloadArt_Thread, movie')
                    FanMovieDownload = True
                    MovieFilePath = cachefile
                    tmdb_Types = ['fanart', 'folder', 'poster']
                    
                    try:
                        if arttype in tmdb_Types:
                            self.logDebug('DownloadArt_Thread, TMDB')
                            arttype = arttype.replace('folder', 'poster')
                            tmdb = self.tmdbAPI.get_image_list(id)
                            data = str(tmdb).replace("[", "").replace("]", "").replace("'", "")
                            data = data.split('}, {')
                            tmdbPath = str([s for s in data if arttype in s]).split("', 'width: ")[0]
                            match = re.search('url *: *(.*?),', tmdbPath)
                            if match:
                                tmdbPath = match.group().replace(",", "").replace("url: u", "").replace("url: ", "")
                                if tmdbPath.startswith('http'):
                                    download_silent(tmdbPath,MovieFilePath)
                                    FanMovieDownload = False
                    except Exception,e:  
                        self.log("script.pseudotv.live-Artdownloader: DownloadArt_Thread, movie Failed" + str(e), xbmc.LOGERROR)
                        buggalo.onExceptionRaised()