示例#1
0
    def _start(self):
        util.LOG('DOWNLOAD SERVICE: START')
        info = self.getNextQueuedDownload()

        while info and not xbmc.abortRequested:
            t = threading.Thread(target=YDStreamExtractor._handleDownload,args=(info['data'],),kwargs={'path':info['path'],'duration':info['duration'],'bg':True})
            t.start()

            while t.isAlive() and not xbmc.abortRequested:
                xbmc.sleep(100)

            info = self.getNextQueuedDownload()

        util.LOG('DOWNLOAD SERVICE: FINISHED')
示例#2
0
    def downloadPlaying(self):
        title = xbmc.getInfoLabel('Player.Title')
        # xbmc.getInfoLabel('Player.Filenameandpath')
        url = xbmc.Player().getPlayingFile()
        thumbnail = xbmc.getInfoLabel('Player.Art(thumb)')
        extra = None
        if '|' in url:
            url, extra = url.rsplit('|', 1)
            url = url.rstrip('?')
        import time
        info = {'url': url, 'title': title, 'thumbnail': thumbnail,
                'id': int(time.time()), 'media_type': 'video'}
        if extra:
            try:
                import urlparse
                for k, v in urlparse.parse_qsl(extra):
                    if k.lower() == 'user-agent':
                        info['user_agent'] = v
                        break
            except:
                util.ERROR(hide_tb=True)

        util.LOG(repr(info), debug=True)

        from lib import YDStreamExtractor
        YDStreamExtractor.handleDownload(info, bg=True)
    def _start(self):
        util.LOG('DOWNLOAD SERVICE: START')
        info = self.getNextQueuedDownload()
        monitor = xbmc.Monitor()

        while info and not monitor.abortRequested():
            t = threading.Thread(target=YDStreamExtractor._handleDownload,
                                 args=(info['data'], ),
                                 kwargs={
                                     'path': info['path'],
                                     'duration': info['duration'],
                                     'bg': True
                                 })
            t.start()

            while t.is_alive():
                if xbmc.waitForAbort(0.1):
                    break

            info = self.getNextQueuedDownload()

        util.LOG('DOWNLOAD SERVICE: FINISHED')
示例#4
0
    def getNextQueuedDownload(self):
        try:
            dataHEX = jsonqueue.XBMCJsonRAFifoQueue(util.QUEUE_FILE).pop()
            if not dataHEX: return None
            dataJSON = binascii.unhexlify(dataHEX)
            self.downloadCount+=1
            util.LOG('Loading from queue. #{0} this session'.format(self.downloadCount))
            return json.loads(dataJSON)
        except:
            import traceback
            traceback.print_exc()

        return None