예제 #1
0
	def __init__(self, settings):
		self.settings = settings
		from ASCore import TSengine
		self.engine = TSengine()
		del TSengine

		TorrentPlayer.__init__(self)
예제 #2
0
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()
예제 #3
0
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()
예제 #4
0
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
예제 #5
0
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
예제 #6
0
파일: main.py 프로젝트: bestblast/tdw
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
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
예제 #8
0
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()
예제 #9
0
	def __init__(self, settings):
		self.settings = settings
		from ASCore import TSengine
		self.engine = TSengine()
		del TSengine