class AcePlayer(TorrentPlayer): def __init__(self, settings): self.settings = settings from ASCore import TSengine self.engine = TSengine() del TSengine def close(self): if self.engine != None: self.engine.end() self.engine = None def _AddTorrent(self, path): if filesystem.exists(path): with filesystem.fopen(path, 'rb') as tfile: content = tfile.read() try: self.status = self.engine.load_torrent(base64.b64encode(content), 'RAW') except KeyError: pass debug('AcePlayer: Torrent loaded') def StartBufferFile(self, fileIndex): self._AddTorrent(self.path) self.fileIndex = fileIndex def GetStreamURL(self, playable_item): file_path = playable_item['name'].replace('\\', '/').encode('utf-8') link = str(self.engine.get_link(int(self.fileIndex), file_path)) debug('AcePlayer: GetStreamURL - ' + link) return link def loop(self): self.engine.loop() def updateDialogInfo(self, progress, progressBar): pass def GetTorrentInfo(self): try: return { 'downloaded' : 100, 'size' : 100, 'dl_speed' : 1, 'ul_speed' : 0, 'num_seeds' : 1, 'num_peers' : 0 } except: pass return None def GetBufferingProgress(self): return 100 def CheckBufferComplete(self): return True
def play_url2(params): #print 'play' torr_link = urllib.unquote(params["torr_url"]) img = urllib.unquote_plus(params["img"]) title = urllib.unquote_plus(params["title"]) #showMessage('heading', torr_link, 10000) TSplayer = TSengine() out = TSplayer.load_torrent(torr_link, 'TORRENT') if out == 'Ok': lnk = TSplayer.get_link(int(params['ind']), title, img, img) if lnk: item = xbmcgui.ListItem(path=lnk, thumbnailImage=img, iconImage=img) xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, item) while not xbmc.Player().isPlaying: xbmc.sleep(300) while TSplayer.player.active and not TSplayer.local: TSplayer.loop() xbmc.sleep(300) if xbmc.abortRequested: TSplayer.log.out("XBMC is shutting down") break if TSplayer.local and xbmc.Player().isPlaying: try: time1 = TSplayer.player.getTime() except: time1 = 0 i = xbmcgui.ListItem("***%s" % title) i.setProperty('StartOffset', str(time1)) xbmc.Player().play(TSplayer.filename.decode('utf-8'), i) else: item = xbmcgui.ListItem(path='') xbmcplugin.setResolvedUrl(int(sys.argv[1]), False, item) TSplayer.end() xbmc.Player().stop
def play_ace(url, ind): from ASCore import TSengine,_TSPlayer #print 'play' torr_link=url img="" title="" #showMessage('heading', torr_link, 10000) TSplayer=TSengine() out=TSplayer.load_torrent(torr_link,'TORRENT') if out=='Ok': lnk=TSplayer.get_link(ind,title, img, img) if lnk: item = xbmcgui.ListItem(path=lnk, thumbnailImage=img, iconImage=img) xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, item) while not xbmc.Player().isPlaying: xbmc.sleep(300) while TSplayer.player.active and not TSplayer.local: TSplayer.loop() xbmc.sleep(300) if xbmc.abortRequested: TSplayer.log.out("XBMC is shutting down") break if TSplayer.local and xbmc.Player().isPlaying: try: time1=TSplayer.player.getTime() except: time1=0 i = xbmcgui.ListItem("***%s"%title) i.setProperty('StartOffset', str(time1)) xbmc.Player().play(TSplayer.filename.decode('utf-8'),i) else: pass TSplayer.end() xbmc.Player().stop
class AcePlayer(TorrentPlayer): def __init__(self, settings): self.settings = settings from ASCore import TSengine self.engine = TSengine() del TSengine TorrentPlayer.__init__(self) def close(self): if self.engine != None: self.engine.end() self.engine = None def _AddTorrent(self, path): if filesystem.exists(path): with filesystem.fopen(path, 'rb') as tfile: content = tfile.read() try: self.status = self.engine.load_torrent(base64.b64encode(content), 'RAW') except KeyError: pass debug('AcePlayer: Torrent loaded') def StartBufferFile(self, fileIndex): self._AddTorrent(self.path) self.fileIndex = fileIndex def GetStreamURL(self, playable_item): file_path = playable_item['name'].replace('\\', '/').encode('utf-8') link = str(self.engine.get_link(int(self.fileIndex), file_path)) debug('AcePlayer: GetStreamURL - ' + link) return link def loop(self): self.engine.loop()
def play_url2(params): #print 'play' torr_link=urllib.unquote(params["torr_url"]) img=urllib.unquote_plus(params["img"]) title=urllib.unquote_plus(params["title"]) #showMessage('heading', torr_link, 10000) TSplayer=TSengine() out=TSplayer.load_torrent(torr_link,'RAW') if out=='Ok': lnk=TSplayer.get_link(int(params['ind']),title, img, img) if lnk: item = xbmcgui.ListItem(path=lnk) xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, item) while not xbmc.Player().isPlaying: xbmc.sleep(300) while TSplayer.player.active and not TSplayer.local: TSplayer.loop() xbmc.sleep(300) if xbmc.abortRequested: TSplayer.log.out("XBMC is shutting down") break if TSplayer.local and xbmc.Player().isPlaying: try: time1=TSplayer.player.getTime() except: time1=0 i = xbmcgui.ListItem("***%s"%title) i.setProperty('StartOffset', str(time1)) xbmc.Player().play(TSplayer.filename.decode('utf-8'),i) else: item = xbmcgui.ListItem(path='') xbmcplugin.setResolvedUrl(int(sys.argv[1]), False, item) TSplayer.end() xbmc.Player().stop