def getContentList(self): filelist = [] for fs in self.engine.list(): stringdata = {"title": ensure_str(fs.name), "size": fs.size, "ind": fs.index, 'offset': fs.offset} filelist.append(stringdata) return filelist
def getContentList(self): filelist = [] for fs in self.engine.list_from_info(): stringdata = {"title": ensure_str(fs.name), "size": fs.size, "ind": fs.index, 'offset': fs.offset} filelist.append(stringdata) return filelist
def getContentList_engine(self): self.setup_engine() files = [] filelist = [] with closing(self.engine): self.engine.start() #media_types=[MediaType.VIDEO, MediaType.AUDIO, MediaType.SUBTITLES, MediaType.UNKNOWN] iterator = 0 text = Localization.localize('Magnet-link is converting') if self.magnetLink\ else Localization.localize('Opening torrent file') while not files and not xbmc.abortRequested and iterator < 100: files = self.engine.list() self.engine.check_torrent_error() if iterator==4: progressBar = xbmcgui.DialogProgress() progressBar.create(Localization.localize('Please Wait'), Localization.localize('Magnet-link is converting')) elif iterator>4: progressBar.update(iterator, Localization.localize('Please Wait'),text+'.' * (iterator % 4), ' ') if progressBar.iscanceled(): progressBar.update(0) progressBar.close() return [] xbmc.sleep(500) iterator += 1 for fs in files: stringdata = {"title": ensure_str(fs.name), "size": fs.size, "ind": fs.index, 'offset': fs.offset} filelist.append(stringdata) return filelist
def _get_status_lines(self, s, f): return [ ensure_str(self.display_name), "%.2f%% %s" % (f.progress * 100, self.localize(STATE_STRS[s.state])), "D:%.2f%s U:%.2f%s S:%d P:%d" % (s.download_rate, self.localize('kb/s'), s.upload_rate, self.localize('kb/s'), s.num_seeds, s.num_peers) ]
def magnetToTorrent(self, magnet): try: from SkorbaLoader import SkorbaLoader torrent = SkorbaLoader(self.storageDirectory, magnet) torrent.magnetToTorrent(magnet) self.torrentFile = torrent.torrentFile except: self.torrentFile = magnet log('['+author+'Loader][magnetToTorrent]: self.torrentFile '+ensure_str((self.torrentFile)))
def magnetToTorrent(self, magnet): try: from SkorbaLoader import SkorbaLoader torrent = SkorbaLoader(self.storageDirectory, magnet) torrent.magnetToTorrent(magnet) self.torrentFile = torrent.torrentFile except: self.torrentFile = magnet log('[AnteoLoader][magnetToTorrent]: self.torrentFile '+ensure_str(self.torrentFile))
def setup_subs(self, label, path): iterator = 0 subs = self.torrent.getSubsIds(label) debug('[setup_subs] subs: ' + str(subs)) if len(subs) > 0: self.torrent.startSession() showMessage( self.localize('Information'), self.localize('Downloading and copy subtitles. Please wait.')) for ind, title in subs: self.torrent.continueSession(ind) while iterator < 100: xbmc.sleep(1000) self.torrent.debug() status = self.torrent.torrentHandle.status() iterator = int(status.progress * 100) # xbmc.sleep(2000) for ind, title in subs: folder = title.split(os.sep)[0] temp = os.path.basename(title) addition = os.path.dirname(title).lstrip(folder + os.sep).replace( os.sep, '.').replace( ' ', '_').strip() ext = temp.split('.')[-1] temp = temp[:len(temp) - len(ext) - 1] + '.' + addition + '.' + ext newFileName = os.path.join( ensure_str(os.path.dirname(decode_str(path))), ensure_str(temp)) debug('[setup_subs]: {} {}'.format(newFileName, title)) if not xbmcvfs.exists(newFileName): fileName = os.path.join( ensure_str( os.path.dirname(os.path.dirname( decode_str(path)))), ensure_str(title)) xbmcvfs.copy(fileName, newFileName)