def __init__(self, settings): self.settings = settings from ASCore import TSengine self.engine = TSengine() del TSengine TorrentPlayer.__init__(self)
def play_url(torr_link, img): #print torr_link TSplayer = TSengine() out = TSplayer.load_torrent(torr_link, 'TORRENT') if out == 'Ok': for k, v in TSplayer.files.iteritems(): li = xbmcgui.ListItem(urllib.unquote(k)) uri = construct_request({ 't': torr_link, 'tt': k.encode('utf-8'), 'i': v, 'ii': urllib.quote(img), 'mode': 'addplist' }) li.setProperty('IsPlayable', 'true') li.addContextMenuItems([ ('Добавить в плейлист', 'XBMC.RunPlugin(%s)' % uri), ]) uri = construct_request({ 'torr_url': torr_link, 'title': k, 'ind': v, 'img': img, 'func': 'play_url2', 'mode': 'play_url2' }) #li.addContextMenuItems([('Добавить в плейлист', 'XBMC.RunPlugin(%s?func=addplist&torr_url=%s&title=%s&ind=%s&img=%s&func=play_url2)' % (sys.argv[0],urllib.quote(torr_link),k,v,img )),]) xbmcplugin.addDirectoryItem(int(sys.argv[1]), uri, li) xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_LABEL) xbmcplugin.setContent(int(sys.argv[1]), 'movies') xbmcplugin.endOfDirectory(int(sys.argv[1])) TSplayer.end()
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