def __init__(self, updateFun = None, downloadNew = True): printDBG( "IconMenager.__init__" ) self.DOWNLOADED_IMAGE_PATH_BASE = config.plugins.iptvplayer.SciezkaCache.value self.cm = common() # download queue self.queueDQ = [] self.lockDQ = threading.Lock() self.workThread = None # already available self.queueAA = {} self.lockAA = threading.Lock() #this function will be called after a new icon will be available self.updateFun = None #new icons dir for each run self.currDownloadDir = self.DOWNLOADED_IMAGE_PATH_BASE + '/' + GetNewIconsDirName() if not os_path.exists(self.currDownloadDir): mkdirs(self.currDownloadDir) #load available icon from disk #will be runned in separeted thread to speed UP start plugin AsyncMethod(self.loadHistoryFromDisk)(self.currDownloadDir) # this is called to remove icons which are stored in old version AsyncMethod(RemoveAllFilesIconsFromPath)(self.DOWNLOADED_IMAGE_PATH_BASE) self.stopThread = False self.checkSpace = 0 # if 0 the left space on disk will be checked self.downloadNew = downloadNew
def __init__(self, updateFun=None, downloadNew=True): printDBG("IconMenager.__init__") self.DOWNLOADED_IMAGE_PATH_BASE = config.plugins.iptvplayer.SciezkaCache.value self.cm = common() # download queue self.queueDQ = [] self.lockDQ = threading.Lock() self.workThread = None # already available self.queueAA = {} self.lockAA = threading.Lock() #this function will be called after a new icon will be available self.updateFun = None #new icons dir for each run self.currDownloadDir = self.DOWNLOADED_IMAGE_PATH_BASE + '/' + GetNewIconsDirName( ) if not os_path.exists(self.currDownloadDir): mkdirs(self.currDownloadDir) #load available icon from disk #will be runned in separeted thread to speed UP start plugin AsyncMethod(self.loadHistoryFromDisk)(self.currDownloadDir) # this is called to remove icons which are stored in old version AsyncMethod(RemoveAllFilesIconsFromPath)( self.DOWNLOADED_IMAGE_PATH_BASE) self.stopThread = False self.checkSpace = 0 # if 0 the left space on disk will be checked self.downloadNew = downloadNew
def askForVKLayoutDownload(self, vkLayoutId, ret=None): if ret: file = '%s.kle' % vkLayoutId path = GetE2iPlayerVKLayoutDir() mkdirs(path) self.session.openWithCallback(boundFunction(self.vkLayoutDownloadCallback, vkLayoutId), SingleFileDownloaderWidget, GetResourcesServerUri('vk/' + file), path + file) else: self.setVKLayout()
def unpackArchive(self, tmpFile, tmpDIR): printDBG( 'CBaseSubProviderClass.unpackArchive tmpFile[%s], tmpDIR[%s]' % (tmpFile, tmpDIR)) rmtree(tmpDIR, ignore_errors=True) if not mkdirs(tmpDIR): SetIPTVPlayerLastHostError( _('Failed to create directory "%s".') % tmpDIR) return False if tmpFile.endswith('.zip'): return self.unpackZipArchive(tmpFile, tmpDIR) elif tmpFile.endswith('.rar'): cmd = "unrar e -o+ -y '{0}' '{1}' 2>/dev/null".format( tmpFile, tmpDIR) printDBG("cmd[%s]" % cmd) ret = self.iptv_execute(cmd) if not ret['sts'] or 0 != ret['code']: message = _('Unrar error code[%s].') % ret['code'] if str(ret['code']) == str(127): message += '\n' + _( 'It seems that unrar utility is not installed.') elif str(ret['code']) == str(9): message += '\n' + _('Wrong format of rar archive.') SetIPTVPlayerLastHostError(message) return False return True return False
def downloadData(movieUrl, movieTitle, wgetpath, downloadPath, cacheTMDB = False ): if cacheTMDB == False: cachedDataFileName = '%s/rafalcool1.tmdb' % downloadPath else: hashAlg = MD5() fullPath= '%s/%s1444444441.144441/'.replace('//','/') % (downloadPath, GetIconDirBaseName() ) cachedDataFileName = fullPath + hexlify(hashAlg(movieUrl[7:])) + '.jpg' if not path.exists(fullPath): mkdirs(fullPath) descr = '' coverUrl = '' ClearMemory() Webmovie, movieYear =cleanFile(movieTitle) Webmovie=DecodeNationalLetters(Webmovie) Webmovie=ConvertChars(Webmovie) url = "http://api.themoviedb.org/3/search/movie?api_key=8789cfd3fbab7dccf1269c3d7d867aff&query=%s&language=pl" % Webmovie if cacheTMDB == False: system('rm -f %s;%s "%s" -O %s' % (cachedDataFileName, wgetpath, url, cachedDataFileName)) else: if not path.exists(cachedDataFileName): system('%s "%s" -O %s' % (wgetpath, url, cachedDataFileName)) if path.exists(cachedDataFileName): with open(cachedDataFileName,'r') as tmdbDATA: myData = tmdbDATA.read() list = re.findall('"poster_path":"(.*?)".*?"overview":"(.*?)".*?"release_date":"(.*?)".*?"id":(.*?),.*?"original_title":"(.*?)".*?"original_language":"(.*?)".*?"title":"(.*?)".*?"popularity":([\.0-9]*).*?"vote_average":([\.0-9]*).*?', myData, re.S) myData=None # some cleanup, just in case if list is None or len(list) == 0: remove(cachedDataFileName) # kasujemy z cache pliki nie zawierajace danych else: if movieYear != '': printDBG("filtering movies list by release year %s" % movieYear) for coverPath,overview,release_date,id,otitle,original_language,title,popularity,vote_average in list: if movieYear in release_date: coverUrl = "http://image.tmdb.org/t/p/w185%s" % coverPath coverUrl = coverUrl.replace('\/','/') #print "[CoverFind] " + title, coverUrl descr=overview + '<br/>' + 'Premiera: ' + release_date + '<br/>' + 'Popularność: ' + popularity + '<br/>' + 'Ocena: ' + vote_average return descr, coverUrl coverPath,overview,release_date,id,otitle,original_language,title,popularity,vote_average = list[0] coverUrl = "http://image.tmdb.org/t/p/w185%s" % coverPath coverUrl = coverUrl.replace('\/','/') print "[CoverFind] " + title, coverUrl descr=overview + '<br/>' + 'Premiera: ' + release_date + '<br/>' + 'Popularność: ' + popularity + '<br/>' + 'Ocena: ' + vote_average return descr, coverUrl
def _createViewedFile(self, hashData): if hashData != None and mkdirs( GetFavouritesDir('IPTVWatched') + ('/%s/' % hashData[0])): flagFilePath = GetFavouritesDir('IPTVWatched/%s/.%s.iptvhash' % hashData) if touch(flagFilePath): return True return False
def createPath(self, path): sts = True msg = '' try: if not os_path.isdir(path) and not os_path.islink(path): if not mkdirs(path): msg = _("The problem with creating a directory [%s].") % path sts = False except: printExc() msg = _("Problem with the directory [%s].") % path sts = False return sts, msg
def createPath(self, path): sts = True msg = '' try: if not os_path.isdir(path) and not os_path.islink(path): if not mkdirs(path): msg = _( "The problem with creating a directory [%s].") % path sts = False except: printExc() msg = _("Problem with the directory [%s].") % path sts = False return sts, msg
def listIso(self, cItem): printDBG("LocalMedia.listIso [%s]" % cItem) # check if iso file is mounted path = cItem['path'] defaultMountPoint = GetTmpDir(self.ISO_MOUNT_POINT_NAME) defaultMountPoint = defaultMountPoint.replace('//', '/') mountPoint = self.getMountPoint(path) if '' == mountPoint: # umount if different image already mounted if self.isMountPoint(defaultMountPoint): cmd = 'umount "{0}"'.format(defaultMountPoint) + ' 2>&1' ret = iptv_execute_wrapper(cmd) if ret['sts'] and 0 != ret['code']: # normal umount failed, so detach filesystem only cmd = 'umount -l "{0}"'.format(defaultMountPoint) + ' 2>&1' ret = iptv_execute_wrapper(cmd) # now mount the iso file if not mkdirs(defaultMountPoint): message = _('Make directory [%s]') % (defaultMountPoint) self.showErrorMessage(message) return else: cmd = 'mount -r "{0}" "{1}"'.format( path, defaultMountPoint) + ' 2>&1' ret = iptv_execute_wrapper(cmd) if ret['sts']: if 0 != ret['code']: message = _( 'Mount ISO file [%s] on [%s] failed.\nReturn code[%s].\nReturn data[%s].' ) % (path, defaultMountPoint, ret['code'], ret['data']) self.showErrorMessage(message) return else: mountPoint = defaultMountPoint if '' != mountPoint: params = dict(cItem) params.update({ 'next_good_for_fav': False, 'path': mountPoint, 'category': 'dir' }) self.listDir(params)
def listIso(self, cItem): printDBG("LocalMedia.listIso [%s]" % cItem) # check if iso file is mounted path = cItem['path'] defaultMountPoint = GetTmpDir(self.ISO_MOUNT_POINT_NAME) defaultMountPoint = defaultMountPoint.replace('//', '/') mountPoint = self.getMountPoint(path) if '' == mountPoint: # umount if different image already mounted if self.isMountPoint(defaultMountPoint): cmd = 'umount "{0}"'.format(defaultMountPoint) + ' 2>&1' ret = iptv_execute()(cmd) if ret['sts'] and 0 != ret['code']: # normal umount failed, so detach filesystem only cmd = 'umount -l "{0}"'.format(defaultMountPoint) + ' 2>&1' ret = iptv_execute()(cmd) # now mount the iso file if not mkdirs(defaultMountPoint): message = _('Make directory [%s]') % (defaultMountPoint) self.showErrorMessage(message) return else: cmd = 'mount -r "{0}" "{1}"'.format(path, defaultMountPoint) + ' 2>&1' ret = iptv_execute()(cmd) if ret['sts']: if 0 != ret['code']: message = _('Mount ISO file [%s] on [%s] failed.\nReturn code[%s].\nReturn data[%s].') % (path, defaultMountPoint, ret['code'], ret['data']) self.showErrorMessage(message) return else: mountPoint = defaultMountPoint if '' != mountPoint: params = dict(cItem) params.update( {'path':mountPoint, 'category':'dir'} ) self.listDir(params)