예제 #1
0
def wrapper(_list_, limit=5, score=70):

    results = []

    if not _list_:
        return

    term = control.inputDialog()

    if not term:
        return

    try:
        term = term.decode('utf-8')
    except AttributeError:
        pass

    control.busy()

    titles = [i['title'].encode('unicode-escape') for i in _list_]

    matches = [
        titles.index(l) for l, s in process.extract(
            term.encode('unicode-escape'), titles, limit=limit
        ) if s >= score
    ]

    for m in matches:
        results.append(_list_[m])

    control.idle()

    return results
예제 #2
0
def search():

    input_str = control.inputDialog()

    if not input_str:
        return

    items = radios_list(ALL_LINK) + _devpicks()

    if is_py3:

        titles = [strip_accents(i['title']) for i in items]

        matches = [
            titles.index(t) for t, s in process.extract(
                strip_accents(input_str), titles, limit=10) if s >= 70
        ]

    else:

        titles = [
            strip_accents(i['title']).encode('unicode-escape') for i in items
        ]

        matches = [
            titles.index(t) for t, s in process.extract(strip_accents(
                input_str).encode('unicode-escape'),
                                                        titles,
                                                        limit=10) if s >= 70
        ]

    data = []

    for m in matches:
        data.append(items[m])

    if not data:

        control.infoDialog(30010)

        return

    else:

        for i in data:
            i.update({'action': 'play', 'isFolder': 'False'})
            bookmark = dict((k, v) for k, v in iteritems(i) if not k == 'next')
            bookmark['bookmark'] = i['url']
            i.update({
                'cm': [{
                    'title': 30501,
                    'query': {
                        'action': 'addBookmark',
                        'url': json.dumps(bookmark)
                    }
                }]
            })

        control.sortmethods('title')
        directory.add(data, infotype='music')
예제 #3
0
    def add_date(self):

        input_date = control.inputDialog(type=control.input_date)

        input_date = ''.join(input_date.split('/')[::-1]).replace(' ',  '0')

        directory.run_builtin(action='matches', query=input_date)
예제 #4
0
    def search(self):

        input_str = control.inputDialog()

        try:
            input_str = cleantitle.strip_accents(input_str.decode('utf-8'))
        except (UnicodeEncodeError, UnicodeDecodeError, AttributeError):
            input_str = cleantitle.strip_accents(input_str)

        input_str = quote(input_str.encode('utf-8'))

        directory.run_builtin(action='listing', url=self.search_link.format(input_str))
def play(url, meta=None, quality=None):

    if meta:

        control.busy()

    stream = resolver(url, quality)

    try:
        isa_enabled = control.addon_details('inputstream.adaptive').get(
            'enabled')
    except KeyError:
        isa_enabled = False

    dash = ('.mpd' in stream or 'dash' in stream or '.ism' in stream
            or '.hls' in stream or '.m3u8' in stream) and isa_enabled

    mimetype = None

    if isinstance(meta, dict):

        control.idle()

        if meta['title'] == 'custom':

            title = control.inputDialog()

            meta['title'] = title

    if dash and control.setting('disable_mpd') == 'false':

        if '.hls' in stream or 'm3u8' in stream:
            manifest_type = 'hls'
            mimetype = 'application/vnd.apple.mpegurl'
        elif '.ism' in stream:
            manifest_type = 'ism'
        else:
            manifest_type = 'mpd'

        log_debug('Activating MPEG-DASH for this url: ' + stream)

        directory.resolve(stream,
                          meta=meta,
                          dash=dash,
                          manifest_type=manifest_type,
                          mimetype=mimetype,
                          resolved_mode=meta is None)

    else:

        directory.resolve(stream, meta=meta, resolved_mode=meta is None)
예제 #6
0
    def enter_date(self):

        input_date = control.inputDialog(control.lang(30021), type=control.input_date).replace(' ', '')

        query = ' - '.join(['Alpha News', input_date])

        try:
            date = datetime.strptime(input_date, '%d/%m/%Y').strftime('%d%m%y')
        except TypeError:
            date = datetime(*(time.strptime(input_date, '%d/%m/%Y')[0:6])).strftime('%d%m%y')

        url = ''.join([self.basecy_link, '/shows/news/kentrikodeltio/webtv/kentriko-deltio-{}'.format(date)])

        self.play(url=url, query=query, resolved_mode=False)
예제 #7
0
def remote(url):

    if ('pastebin' in url or 'hastebin' in url
            or 'osmc.tv' in url) and not 'raw' in url:
        address = re.sub(r'(^.+?\.(?:com|tv)/)(\w+)', r'\1raw/\2', url)
    elif 'debian' in url and not 'plain' in url:
        address = re.sub(r'(^.+?\.net/)(\w+)', r'\1plain/\2', url)
    else:
        address = url

    if 'ubuntu' in url and not 'plain' in url:
        html = client.request(address)
        text = client.parseDOM(html, 'pre')[1]
        text = client.replaceHTMLCodes(text)
    else:
        text = client.request(address)

    if not text:
        return

    text = text.strip('\r\n')

    if len(text.splitlines()) in (3, 4):
        keys = text.splitlines()
    elif text.startswith('<?xml'):
        keys = [
            client.parseDOM(text, 'id')[0],
            client.parseDOM(text, 'api_key')[0],
            client.parseDOM(text, 'secret')[0]
        ]
    elif address.endswith('.json') or 'installed' in text:
        payload = json.loads(text)
        if 'installed' in payload:
            payload = payload['installed']
            if 'api_key' not in payload:
                control.okDialog(heading='Youtube Setup',
                                 line1=control.lang(30023))
                api_key = control.inputDialog()
                if not api_key:
                    return
            else:
                api_key = payload['api_key']
            keys = [payload['client_id'], api_key, payload['client_secret']]
        else:
            keys = None
    else:
        keys = None

    return keys
def play(url, meta=None):

    if meta:

        control.busy()

    stream = router(url)

    if isinstance(meta, dict):

        control.idle()

        if meta['title'] == 'custom':

            title = control.inputDialog()

            meta['title'] = title

    directory.resolve(stream, meta=meta, resolved_mode=meta is None)
예제 #9
0
def local(path):

    with open(path) as txtfile:
        f = txtfile.read()

    if not f:
        return

    f = f.strip('\r\n')

    if path.endswith('.txt') or len(f.splitlines()) in (3, 4):
        keys = f.splitlines()
    elif path.endswith('.xml') or f.startswith('<?xml'):
        keys = [
            client.parseDOM(f, 'id')[0],
            client.parseDOM(f, 'api_key')[0],
            client.parseDOM(f, 'secret')[0]
        ]
    elif path.endswith('.json'):
        payload = json.loads(f)
        if 'installed' in payload:
            payload = payload['installed']
            if 'api_key' not in payload:
                control.okDialog(heading='Youtube Setup',
                                 line1=control.lang(30023))
                api_key = control.inputDialog()
                if not api_key:
                    return
            else:
                api_key = payload['api_key']
            keys = [payload['client_id'], api_key, payload['client_secret']]
        else:
            keys = None
    else:
        keys = None

    return keys