Beispiel #1
0
elif action == 'addSearch':
    from resources.lib.indexers import kratos
    kratos.indexer().addSearch(url)

elif action == 'delSearch':
    from resources.lib.indexers import kratos
    kratos.indexer().delSearch()

elif action == 'queueItem':
    from resources.lib.zmodules import control
    control.queueItem()

elif action == 'openSettings':
    from resources.lib.zmodules import control
    control.openSettings()

elif action == 'urlresolverSettings':
    from resources.lib.zmodules import control
    control.openSettings(id='script.module.urlresolver')

elif action == 'addView':
    from resources.lib.zmodules import views
    views.addView(content)

elif action == 'downloader':
    from resources.lib.zmodules import downloader
    downloader.downloader()

elif action == 'addDownload':
    from resources.lib.zmodules import downloader
Beispiel #2
0
    def resolve(self, url):
        try:
            m3u8 = [
                '#EXTM3U',
                '#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio",DEFAULT=YES,AUTOSELECT=YES,NAME="Stream 1",URI="{audio_stream}"',
                '',
                '#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=0,NAME="{stream_name}",AUDIO="audio"',
                '{video_stream}'
            ]

            query = urlparse.parse_qs(url)
            query = dict([(key, query[key][0]) if query[key] else (key, '')
                          for key in query])

            auth = 'http://streamtorrent.tv/api/torrent/%s/%s.m3u8?json=true' % (
                query['vid_id'], query['stream_id'])

            r = client.request(auth)
            r = json.loads(r)
            try:
                url = r['url']
            except:
                url = None

            if not url == None:

                def dialog(url):
                    try:
                        self.disableScraper = control.yesnoDialog(
                            'To watch this video visit from any device',
                            '[COLOR skyblue]%s[/COLOR]' % url, '', 'Torba',
                            'Cancel', 'Settings')
                    except:
                        pass

                workers.Thread(dialog, url).start()
                control.sleep(3000)

                for i in range(100):
                    try:
                        if not control.condVisibility(
                                'Window.IsActive(yesnoDialog)'):
                            break

                        r = client.request(auth)
                        r = json.loads(r)
                        try:
                            url = r['url']
                        except:
                            url = None

                        if url == None: break

                        workers.Thread(dialog, url).start()
                        control.sleep(3000)
                    except:
                        pass

                if self.disableScraper:
                    control.openSettings(query='2.0')
                    return ''

                control.execute('Dialog.Close(yesnoDialog)')

            if not url == None: return

            stream_name = '%sp' % (query['height'])
            video_stream = r[stream_name]

            if not 'audio' in r: return video_stream

            audio_stream = r['audio']

            content = ('\n'.join(m3u8)).format(
                **{
                    'audio_stream': audio_stream,
                    'stream_name': stream_name,
                    'video_stream': video_stream
                })

            path = os.path.join(control.dataPath, 'torbase.m3u8')

            control.makeFile(control.dataPath)
            control.deleteFile(path)

            file = control.openFile(path, 'w')
            file.write(content)
            file.close()

            return path
        except:
            return