コード例 #1
0
    def install():

        if control.conditional_visibility('System.Platform.Linux') and not (
                path.exists(control.transPath(xbmc_path))
                or path.exists(control.transPath(home_path))):

            control.okDialog(heading='AliveGR', line1=control.lang(30323))

            return False

        elif path.exists(control.transPath(xbmc_path)) or path.exists(
                control.transPath(home_path)):

            return True

        elif control.kodi_version() >= 18.0 and not control.condVisibility(
                'System.HasAddon(pvr.iptvsimple)'):

            control.execute('InstallAddon(pvr.iptvsimple)')

            return True

        elif control.condVisibility('System.HasAddon(pvr.iptvsimple)'):

            return 'enabled'

        else:

            return False
コード例 #2
0
def seq():

    conditions = [
        bool(
            control.addon('plugin.video.youtube').getSetting(
                'youtube.api.id')),
        bool(
            control.addon('plugin.video.youtube').getSetting(
                'youtube.api.key')),
        bool(
            control.addon('plugin.video.youtube').getSetting(
                'youtube.api.secret'))
    ]

    if int(YT_VERSION) >= 670:
        conditions.insert(
            0,
            control.addon('plugin.video.youtube').getSetting(
                'youtube.api.enable') == 'true')

    if any(conditions) and bool(control.setting('local')) or bool(
            control.setting('remote')):
        control.okDialog(control.addonInfo('name'), control.lang(30017))

    if not bool(control.setting('local')) and not bool(
            control.setting('remote')):

        result = None

    elif control.setting('local_or_remote') == '0':

        result = local(control.setting('local'))

    else:

        result = remote(control.setting('remote'))

    if not result:

        control.okDialog(control.lang(30010), control.lang(30011))

    else:

        if control.yesnoDialog(line1=control.lang(30012),
                               line2='',
                               line3='',
                               yeslabel=control.lang(30013),
                               nolabel=control.lang(30014)):

            setup(result)

            if control.setting('wizard') == 'true':
                wizard()
            else:
                pass

        else:

            control.infoDialog(control.lang(30014))
コード例 #3
0
def rtmp_enable():

    if control.kodi_version() < 17.0:

        control.infoDialog(control.lang(30322))
        return

    try:

        enabled = control.addon_details('inputstream.rtmp').get('enabled')

    except Exception:

        enabled = False

    try:

        if enabled:

            control.infoDialog(control.lang(30276))
            return

        else:

            xbmc_path = control.join('special://xbmc', 'addons',
                                     'inputstream.rtmp')
            home_path = control.join('special://home', 'addons',
                                     'inputstream.rtmp')

            if path.exists(control.transPath(xbmc_path)) or path.exists(
                    control.transPath(home_path)):

                yes = control.yesnoDialog(control.lang(30277))

                if yes:

                    control.enable_addon('inputstream.rtmp')
                    control.infoDialog(control.lang(30402))

            else:

                try:

                    control.execute('InstallAddon(inputstream.rtmp)')

                except Exception:

                    control.okDialog(heading='AliveGR',
                                     line1=control.lang(30323))

    except Exception:

        control.infoDialog(control.lang(30279))
コード例 #4
0
        def seq():

            string_start = '<keymap><slideshow><mouse>'
            string_end = '</mouse></slideshow></keymap>'
            string_for_left = '<leftclick>NextPicture</leftclick>'
            string_for_right = '<rightclick>PreviousPicture</rightclick>'
            string_for_middle = '<middleclick>Rotate</middleclick>'
            string_for_up = '<wheelup>ZoomIn</wheelup>'
            string_for_down = '<wheeldown>ZoomOut</wheeldown>'

            classes = [
                string_for_left, string_for_right, string_for_middle,
                string_for_up, string_for_down
            ]

            map_left = control.lang(30241)
            map_right = control.lang(30242)
            map_middle = control.lang(30243)
            map_up = control.lang(30244)
            map_down = control.lang(30245)

            keys = [
                map_left, map_right, map_middle, map_up, map_down
            ]

            control.okDialog(control.name(), control.lang(30240))

            indices = control.dialog.multiselect(control.name(), keys)

            if not indices:

                control.infoDialog(control.lang(30246))

            else:

                finalized = []

                for i in indices:
                    finalized.append(classes[i])

                joined = ''.join(finalized)

                to_write = string_start + joined + string_end

                try:
                    with open(location, mode='w', encoding='utf-8') as f:
                        f.write(to_write)
                except Exception:
                    with open(location, 'w') as f:
                        f.write(to_write)

                control.execute('Action(reloadkeymaps)')
コード例 #5
0
def prompt():

    control.okDialog('AliveGR', control.lang(30356).format(remote_version()))

    choices = [control.lang(30357), control.lang(30358), control.lang(30359)]

    _choice = control.selectDialog(choices, heading=control.lang(30482))

    if _choice == 0:
        force()
    elif _choice == 1:
        control.close_all()
    elif _choice == 2:
        do_not_ask_again()
コード例 #6
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
コード例 #7
0
ファイル: tools.py プロジェクト: DoBucki/Kodi_Remote_Manager
def isa_enable():

    if addon_version('xbmc.python') < 2250:

        control.infoDialog(control.lang(30322))
        return

    try:

        enabled = control.addon_details('inputstream.adaptive').get('enabled')

    except Exception:

        enabled = False

    try:

        if enabled:

            control.infoDialog(control.lang(30254))
            return

        else:

            xbmc_path = control.join('special://xbmc', 'addons', 'inputstream.adaptive')
            home_path = control.join('special://home', 'addons', 'inputstream.adaptive')

            if path.exists(control.transPath(xbmc_path)) or path.exists(control.transPath(home_path)):

                yes = control.yesnoDialog(control.lang(30252))

                if yes:

                    control.enable_addon('inputstream.adaptive')
                    control.infoDialog(control.lang(30402))

            else:

                try:

                    control.execute('InstallAddon(inputstream.adaptive)')

                except Exception:

                    control.okDialog(heading='AliveGR', line1=control.lang(30323))

    except Exception:

        control.infoDialog(control.lang(30278))
コード例 #8
0
def manual_auth(tell=True):

    if tell:
        control.okDialog(control.name(),
                         control.lang(30146).format(short_link))

    if control.setting('ip.address') == '0.0.0.0':
        ip_address_set()

    auth_token = control.dialog.input(heading=control.lang(30082))

    if not auth_token:
        control.okDialog(control.name(), control.lang(30083))
        return
    else:
        control.setSetting('auth.token', auth_token)
        get_tokens(code=auth_token)
コード例 #9
0
def authorize():

    control.setSetting('get.toggle', 'true')

    choices = [
        control.lang(30063),
        control.lang(30080),
        control.lang(30149),
        control.lang(30081)
    ]

    choice = control.selectDialog(choices, control.lang(30061))

    if choice == 0:

        control.open_web_browser(authorization_link())
        reddit_server()

    elif choice == 1:

        window = QR_display(control.name())

        window.doModal()

        del window

    elif choice == 2:

        kodi_auth()

    elif choice == 3:

        control.okDialog(control.name(),
                         control.lang(30146).format(QR_display.link))

        if control.setting('ip.address') == '0.0.0.0':
            ip_address_set()

        auth_token = control.dialog.input(heading=control.lang(30082))

        if not auth_token:
            control.okDialog(control.name(), control.lang(30083))
            return
        else:
            control.setSetting('auth.token', auth_token)
            get_tokens(code=auth_token)
コード例 #10
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
コード例 #11
0
        choices = [
            control.lang(30020),
            control.lang(30016),
            control.lang(30019)
        ]

        selection = control.selectDialog(choices)

        if selection == 0:

            seq()

        elif selection == 1:

            control.openSettings()

        elif selection == 2:

            control.openSettings(id='plugin.video.youtube')


if __name__ == '__main__':

    start()

else:

    control.okDialog(heading=control.addonInfo('name'),
                     line1=control.lang(30001))
コード例 #12
0
def kodi_auth():

    aspect_ratio = control.infoLabel('Skin.AspectRatio')

    def obtain_authorization(_cookie, _uh):

        data = {
            'authorize': 'Allow',
            'state': state,
            'redirect_uri': redirect_uri,
            'response_type': 'code',
            'client_id': client_id,
            'duration': 'permanent',
            'scope': ' '.join(scope),
            'uh': _uh
        }

        headers = client.request(api_link('authorize'),
                                 cookie=_cookie,
                                 post=data,
                                 redirect=False,
                                 output='headers')

        geturl = dict([
            line.partition(': ')[::2] for line in str(headers).splitlines()
        ]).get('location')

        token = dict(parse_qsl(urlparse(geturl).query)).get('code')

        if not token:

            return

        get_tokens(code=token)

    class Prompt(pyxbmct.AddonDialogWindow):

        pyxbmct.skin.estuary = control.setting('pyxbmct.estuary') == 'true'

        if aspect_ratio == '4:3':
            geometry = (506, 380, 5, 5)
        else:
            geometry = (676, 380, 5, 5)

        def __init__(self, title, description, _cookie, _uh):

            super(Prompt, self).__init__(title)
            self.allow_button = None
            self.deny_button = None
            self.text_box = None
            self.text = description
            self.cookie = _cookie
            self.uh = _uh
            self.setGeometry(*self.geometry)
            self.set_controls()
            self.set_navigation()
            self.connect(pyxbmct.ACTION_NAV_BACK, self.close)

        def set_controls(self):

            # Text box
            self.text_box = pyxbmct.TextBox()
            self.placeControl(self.text_box, 0, 0, 4, 5)
            self.text_box.setText(self.text)
            self.text_box.autoScroll(1000, 1000, 1000)
            # Allow
            self.allow_button = pyxbmct.Button(control.lang(30150))
            self.placeControl(self.allow_button, 4, 1)
            self.connect(self.allow_button, lambda: self.authorize())
            # Deny
            self.deny_button = pyxbmct.Button(control.lang(30151))
            self.placeControl(self.deny_button, 4, 3)
            self.connect(self.deny_button, self.close)

        def set_navigation(self):

            self.allow_button.controlRight(self.deny_button)
            self.deny_button.controlLeft(self.allow_button)
            self.setFocus(self.allow_button)

        def authorize(self):

            obtain_authorization(self.cookie, self.uh)
            self.close()

    class UserPass(pyxbmct.AddonDialogWindow):

        pyxbmct.skin.estuary = control.setting('pyxbmct.estuary') == 'true'

        if aspect_ratio == '4:3':
            geometry = (341, 296, 6, 1)
        else:
            geometry = (455, 296, 6, 1)

        def __init__(self, title):

            super(UserPass, self).__init__(title)
            self.username_label = None
            self.user_input = None
            self.password_label = None
            self.pass_input = None
            self.submit_button = None
            self.cancel_button = None
            self.setGeometry(*self.geometry)
            self.set_controls()
            self.set_navigation()
            self.connect(pyxbmct.ACTION_NAV_BACK, self.close)

        def set_controls(self):

            # Username label
            self.username_label = pyxbmct.Label(control.lang(30152))
            self.placeControl(self.username_label, 0, 0)
            # Username input
            self.user_input = pyxbmct.Edit(control.lang(30152))
            self.placeControl(self.user_input, 1, 0)
            # Password label
            self.password_label = pyxbmct.Label(control.lang(30153))
            self.placeControl(self.password_label, 2, 0)
            # Password input
            self.pass_input = pyxbmct.Edit(control.lang(30153),
                                           isPassword=True)
            self.placeControl(self.pass_input, 3, 0)
            # Submit button
            self.submit_button = pyxbmct.Button(control.lang(30154))
            self.placeControl(self.submit_button, 4, 0)
            self.connect(self.submit_button, lambda: self.submit(True))
            # Cancel button
            self.cancel_button = pyxbmct.Button(control.lang(30064))
            self.placeControl(self.cancel_button, 5, 0)
            self.connect(self.cancel_button, self.close)

        def set_navigation(self):

            self.user_input.controlDown(self.pass_input)
            self.pass_input.controlUp(self.user_input)
            self.pass_input.controlDown(self.submit_button)
            self.submit_button.controlUp(self.pass_input)
            self.submit_button.controlDown(self.cancel_button)
            self.cancel_button.controlUp(self.submit_button)
            self.setFocus(self.user_input)

        def credentials(self):

            return self.user_input.getText(), self.pass_input.getText()

        def submit(self, _submitted=False):

            if _submitted:

                self.close()

                return True

    userpass_window = UserPass(control.name())
    userpass_window.doModal()

    username, password = userpass_window.credentials()

    if not username or not password:

        return

    login_url = base_link(True) + '/api/login/' + username

    data = {
        'form_is_compact': 'true',
        'dest': authorization_link(True),
        'passwd': password,
        'user': username,
        'rem': 'on',
        'api_type': 'json',
        'op': 'login'
    }

    del userpass_window

    cookie = client.request(login_url, close=False, post=data, output='cookie')

    html = client.request(authorization_link(True), cookie=cookie)

    try:

        uh = client.parseDOM(html, 'input', attrs={'name': 'uh'},
                             ret='value')[0]

        permissions = client.parseDOM(html,
                                      'div',
                                      attrs={'class': 'access-permissions'})[0]
        notice = client.parseDOM(html, 'p', attrs={'class': 'notice'})[0]

        text = client.replaceHTMLCodes(
            client.stripTags(permissions + '[CR]' + notice))

        text = substitute(r'([.:]) ?', r'\1[CR]', text).partition('[CR]')

        prompt_window = Prompt(title=text[0],
                               description=text[2],
                               _cookie=cookie,
                               _uh=uh)
        prompt_window.doModal()

        del prompt_window

    except IndexError:

        control.okDialog(control.name(), control.lang(30114))
コード例 #13
0
ファイル: tools.py プロジェクト: DoBucki/Kodi_Remote_Manager
def setup_various_keymaps(keymap):

    keymap_settings_folder = control.transPath('special://profile/keymaps')

    if not path.exists(keymap_settings_folder):
        control.makeFile(keymap_settings_folder)

    if keymap == 'previous':

        location = control.join(keymap_settings_folder, 'alivegr_tvguide.xml')

        lang_int = 30025

        def seq():

            previous_keymap = """<keymap>
    <tvguide>
        <keyboard>
            <key id="61448">previousmenu</key>
        </keyboard>
    </tvguide>
    <tvchannels>
        <keyboard>
            <key id="61448">previousmenu</key>
        </keyboard>
    </tvchannels>
</keymap>
"""

            with open(location, 'w') as f:
                f.write(previous_keymap)

    elif keymap == 'mouse':

        location = control.transPath(control.join('special://profile', 'keymaps', 'alivegr_mouse.xml'))

        lang_int = 30238

        def seq():

            string_start = '<keymap><slideshow><mouse>'
            string_end = '</mouse></slideshow></keymap>'
            string_for_left = '<leftclick>NextPicture</leftclick>'
            string_for_right = '<rightclick>PreviousPicture</rightclick>'
            string_for_middle = '<middleclick>Rotate</middleclick>'
            string_for_up = '<wheelup>ZoomIn</wheelup>'
            string_for_down = '<wheeldown>ZoomOut</wheeldown>'

            classes = [
                string_for_left, string_for_right, string_for_middle,
                string_for_up, string_for_down
            ]

            map_left = control.lang(30241)
            map_right = control.lang(30242)
            map_middle = control.lang(30243)
            map_up = control.lang(30244)
            map_down = control.lang(30245)

            keys = [
                map_left, map_right, map_middle, map_up, map_down
            ]

            control.okDialog(control.name(), control.lang(30240))

            indices = control.dialog.multiselect(control.name(), keys)

            if not indices:

                control.infoDialog(control.lang(30246))

            else:

                finalized = []

                for i in indices:
                    finalized.append(classes[i])

                joined = ''.join(finalized)

                to_write = string_start + joined + string_end

                with open(location, 'w') as f:
                    f.write(to_write)

    elif keymap == 'remote_slideshow':

        location = control.transPath(control.join('special://profile', 'keymaps', 'alivegr_remote_slideshow.xml'))

        lang_int = 30238

        def seq():

            string_start = '<keymap><slideshow><keyboard>'
            ok_button = ''
            long_ok_button = ''
            next_pic = ''
            previous_pic = ''
            context = ''
            string_end = '</keyboard></slideshow></keymap>'

            yes_clicked = control.yesnoDialog(control.lang(30026))

            if yes_clicked:

                to_write = string_start + ok_button + long_ok_button + next_pic + previous_pic + context + string_end

            else:

                to_write = string_start + ok_button + long_ok_button + context + string_end

            with open(location, 'w') as f:
                f.write(to_write)

    yes = control.yesnoDialog(control.lang(lang_int))

    if yes:

        if path.exists(location):

            choices = [control.lang(30248), control.lang(30249)]

            choice = control.selectDialog(choices, heading=control.lang(30247))

            if choice == 0:

                seq()
                control.execute('Action(reloadkeymaps)')
                control.okDialog(control.name(), control.lang(30027) + ', ' + (control.lang(30028)))
                control.infoDialog(control.lang(30402))

            elif choice == 1:

                control.deleteFile(location)
                control.execute('Action(reloadkeymaps)')
                control.infoDialog(control.lang(30402))

            else:

                control.infoDialog(control.lang(30403))

        else:

            seq()
            control.okDialog(control.name(), control.lang(30027) + ', ' + (control.lang(30028)))
            control.infoDialog(control.lang(30402))

    else:

        control.infoDialog(control.lang(30403))
コード例 #14
0
    def run(self, query=None):

        if 'Greek' not in str(self.langs).split(','):

            control.directory(self.syshandle)
            control.infoDialog(control.lang(30002))

            return

        if not control.conditional_visibility(
                'System.HasAddon(script.module.futures)') and is_py2:

            if 17.0 <= control.kodi_version() <= 18.9:
                control.execute('InstallAddon(script.module.futures)')
                control.sleep(1500)

            elif 16.0 <= control.kodi_version() <= 16.2:
                control.okDialog('Subtitles.gr', control.lang(30229))
                return

        dup_removal = False

        if not query:

            with concurrent.futures.ThreadPoolExecutor(5) as executor:

                if control.condVisibility('Player.HasVideo'):
                    infolabel_prefix = 'VideoPlayer'
                else:
                    infolabel_prefix = 'ListItem'

                title = control.infoLabel('{0}.Title'.format(infolabel_prefix))

                if re.search(r'[^\x00-\x7F]+', title) is not None:

                    title = control.infoLabel(
                        '{0}.OriginalTitle'.format(infolabel_prefix))

                title = unicodedata.normalize('NFKD',
                                              title).encode('ascii', 'ignore')
                title = py3_dec(title)
                year = control.infoLabel('{0}.Year'.format(infolabel_prefix))
                tvshowtitle = control.infoLabel(
                    '{0}.TVshowtitle'.format(infolabel_prefix))
                season = control.infoLabel(
                    '{0}.Season'.format(infolabel_prefix))

                if len(season) == 1:

                    season = '0' + season

                episode = control.infoLabel(
                    '{0}.Episode'.format(infolabel_prefix))

                if len(episode) == 1:
                    episode = '0' + episode

                if 's' in episode.lower():
                    season, episode = '0', episode[-1:]

                if tvshowtitle != '':  # episode

                    title_query = '{0} {1}'.format(tvshowtitle, title)
                    season_episode_query = '{0} S{1} E{2}'.format(
                        tvshowtitle, season, episode)
                    season_episode_query_nospace = '{0} S{1}E{2}'.format(
                        tvshowtitle, season, episode)

                    threads = [
                        executor.submit(self.subtitlesgr,
                                        season_episode_query_nospace),
                        executor.submit(self.xsubstv, season_episode_query),
                        executor.submit(self.podnapisi, season_episode_query),
                        executor.submit(self.vipsubs, season_episode_query)
                    ]

                    dup_removal = True

                    log_debug('Dual query used for subtitles search: ' +
                              title_query + ' / ' + season_episode_query)

                    if control.setting('queries') == 'true':

                        threads.extend([
                            executor.submit(self.subtitlesgr, title_query),
                            executor.submit(self.vipsubs, title_query),
                            executor.submit(self.podnapisi, title_query),
                            executor.submit(self.subtitlesgr,
                                            season_episode_query)
                        ])

                elif year != '':  # movie

                    query = '{0} ({1})'.format(title, year)

                    threads = [
                        executor.submit(self.subtitlesgr, query),
                        executor.submit(self.xsubstv, query),
                        executor.submit(self.vipsubs, query),
                        executor.submit(self.podnapisi, query)
                    ]

                else:  # file

                    query, year = control.cleanmovietitle(title)

                    if year != '':

                        query = '{0} ({1})'.format(query, year)

                    threads = [
                        executor.submit(self.subtitlesgr, query),
                        executor.submit(self.xsubstv, query),
                        executor.submit(self.vipsubs, query),
                        executor.submit(self.podnapisi, query)
                    ]

                for future in concurrent.futures.as_completed(threads):

                    item = future.result()

                    if not item:
                        continue

                    self.list.extend(item)

                if not dup_removal:

                    log_debug('Query used for subtitles search: ' + query)

                self.query = query

                self.query = py3_dec(self.query)

        else:

            with concurrent.futures.ThreadPoolExecutor(5) as executor:

                query = py3_dec(query)

                threads = [
                    executor.submit(self.subtitlesgr, query),
                    executor.submit(self.xsubstv, query),
                    executor.submit(self.vipsubs, query),
                    executor.submit(self.podnapisi, query)
                ]

                for future in concurrent.futures.as_completed(threads):

                    item = future.result()

                    if not item:
                        continue

                    self.list.extend(item)

        if len(self.list) == 0:

            control.directory(self.syshandle)

            return

        f = []

        # noinspection PyUnresolvedReferences
        f += [i for i in self.list if i['source'] == 'xsubstv']
        f += [i for i in self.list if i['source'] == 'subtitlesgr']
        f += [i for i in self.list if i['source'] == 'podnapisi']
        f += [i for i in self.list if i['source'] == 'vipsubs']

        self.list = f

        if dup_removal:

            self.list = [
                dict(t) for t in {tuple(d.items())
                                  for d in self.list}
            ]

        for i in self.list:

            try:

                if i['source'] == 'xsubstv':
                    i['name'] = u'[xsubstv] {0}'.format(i['name'])
                elif i['source'] == 'podnapisi':
                    i['name'] = u'[podnapisi] {0}'.format(i['name'])
                elif i['source'] == 'vipsubs':
                    i['name'] = u'[vipsubs] {0}'.format(i['name'])

            except Exception:

                pass

        if control.setting('sorting') == '1':
            key = 'source'
        elif control.setting('sorting') == '2':
            key = 'downloads'
        elif control.setting('sorting') == '3':
            key = 'rating'
        else:
            key = 'title'

        self.list = sorted(self.list,
                           key=lambda k: k[key].lower(),
                           reverse=control.setting('sorting')
                           in ['1', '2', '3'])

        for i in self.list:

            u = {'action': 'download', 'url': i['url'], 'source': i['source']}
            u = '{0}?{1}'.format(self.sysaddon, urlencode(u))

            item = control.item(label='Greek', label2=i['name'])
            item.setArt({'icon': str(i['rating'])[:1], 'thumb': 'el'})
            item.setProperty('sync', 'false')
            item.setProperty('hearing_imp', 'false')

            control.addItem(handle=self.syshandle,
                            url=u,
                            listitem=item,
                            isFolder=False)

        control.directory(self.syshandle)
コード例 #15
0
def conditionals(url):

    add_plugin_dirs(control.transPath(PLUGINS_PATH))

    def yt(uri):

        if uri.startswith('plugin://'):
            return uri

        if len(uri) == 11:

            uri = YT_URL + uri

        try:
            return youtube.wrapper(uri)
        except YouTubeException as exp:
            log_debug('Youtube resolver failure, reason: ' + repr(exp))
            return

    if 'youtu' in url:

        log_debug('Resolved with youtube addon')

        return yt(url)

    elif url.startswith('iptv://'):

        try:
            if CACHE_DEBUG:
                hosts, urls = common.iptv(urlsplit(url).netloc)
            else:
                hosts, urls = cache.get(common.iptv, 2, urlsplit(url).netloc)
        except Exception:
            return

        stream = mini_picker(hosts, urls, dont_check=True)

        return stream

    elif HOSTS(url) and HostedMediaFile(url).valid_url():

        try:
            stream = resolve_url(url)
        except urllib2.HTTPError:
            return url

        return stream

    elif HostedMediaFile(url).valid_url():

        if control.setting('show_alt_vod') == 'true':

            try:
                stream = resolve_url(url)
            except urllib2.HTTPError:
                return url

            return stream

        else:

            control.okDialog('AliveGR', control.lang(30354))
            return 'https://static.adman.gr/inpage/blank.mp4'

    elif GM_BASE in url:

        if CACHE_DEBUG:
            sources = source_maker(url)
        else:
            sources = cache.get(source_maker, 6, url)
            if not sources:
                return

        link = mini_picker(sources['hosts'], sources['links'])

        if not link:
            return

        stream = conditionals(link)
        return stream

    elif GK_BASE in url:

        if CACHE_DEBUG:
            stream = gk_debris(url)
        else:
            stream = cache.get(gk_debris, 48, url)
        if not stream:
            return
        else:
            return stream

    else:

        return url
コード例 #16
0
def do_not_ask_again():

    control.setSetting('new_version_prompt', 'false')

    control.okDialog('AliveGR', control.lang(30361))
コード例 #17
0
    def resolve(self, url):

        _url = url

        if 'radiostreaming' in url:

            return url

        elif 'youtube' in url or len(url) == 11:

            if url.startswith('plugin://'):
                url = url[-11:]

            return self.yt_session(url)

        else:

            html = client.request(url)

            if 'iframe' in html:

                iframe = parseDOM(html, 'iframe', ret='src')[0]

            else:

                availability = parseDOM(html, 'strong')[-1]
                control.okDialog(control.name(), availability)

                return 'https://static.adman.gr/inpage/blank.mp4'

            if 'youtube' in iframe:

                return self.resolve(iframe)

            else:

                result = client.request(iframe)
                urls = re.findall(r'(?:var )?(?:HLSLink|stream)(?:ww)?\s+=\s+[\'"](.+?)[\'"]', result)

                if urls:

                    if control.setting('debug') == 'false':
                        geo = cache.get(self._geo_detect, 192)
                    else:
                        geo = self._geo_detect()

                    if len(urls) >= 2:

                        if _url.endswith('-live/'):

                            if not geo:
                                return urls[-1]
                            else:
                                return urls[0]

                        else:

                            url = [i for i in urls if 'dvrorigingr' in i][0]

                            try:
                                video_ok = client.request(url, timeout=3)
                            except Exception:
                                video_ok = None

                            if video_ok:

                                return url

                            else:

                                url = [i for i in urls if 'dvrorigin' in i][0]

                                return url

                    else:

                        if 'youtube' in urls[0]:
                            return self.resolve(urls[0])
                        else:
                            return urls[0]

                else:

                    iframes = parseDOM(result, 'iframe', ret='src')

                    try:
                        return self.resolve(iframes[-1])
                    except YouTubeException:
                        return self.resolve(iframes[0])
コード例 #18
0
def setup_iptv():

    xbmc_path = control.join('special://xbmc', 'addons', 'pvr.iptvsimple')
    home_path = control.join('special://home', 'addons', 'pvr.iptvsimple')

    def install():

        if control.conditional_visibility('System.Platform.Linux') and not (
                path.exists(control.transPath(xbmc_path))
                or path.exists(control.transPath(home_path))):

            control.okDialog(heading='AliveGR', line1=control.lang(30323))

            return False

        elif path.exists(control.transPath(xbmc_path)) or path.exists(
                control.transPath(home_path)):

            return True

        elif control.kodi_version() >= 18.0 and not control.condVisibility(
                'System.HasAddon(pvr.iptvsimple)'):

            control.execute('InstallAddon(pvr.iptvsimple)')

            return True

        elif control.condVisibility('System.HasAddon(pvr.iptvsimple)'):

            return 'enabled'

        else:

            return False

    def setup_client(apply=False):

        url = thgiliwt('=' + vtpi)

        if apply:

            xml = client.request(url)

            settings = re.findall(r'id="(\w*?)" value="(\S*?)"', xml)

            for k, v in settings:

                control.addon('pvr.iptvsimple').setSetting(k, v)

        else:

            if not path.exists(iptv_folder):
                control.makeFile(iptv_folder)

            client.retriever(url, control.join(iptv_folder, "settings.xml"))

    if path.exists(control.join(iptv_folder, 'settings.xml')):

        integer = 30021

    else:

        integer = 30023

    if control.yesnoDialog(line1=control.lang(integer) + '[CR]' +
                           control.lang(30022)):

        success = install()

        if success:

            setup_client(apply=success == 'enabled')
            control.infoDialog(message=control.lang(30024), time=2000)
            enable_iptv()
            enable_proxy_module()

        else:

            control.okDialog('AliveGR', control.lang(30410))

    else:

        control.infoDialog(message=control.lang(30029), time=2000)
コード例 #19
0
def check_updates():

    control.execute('UpdateAddonRepos')
    control.okDialog(heading=control.addonInfo('name'),
                     line1=control.lang(30402))
コード例 #20
0
def setup_various_keymaps(keymap):

    keymap_settings_folder = control.transPath('special://profile/keymaps')

    if not path.exists(keymap_settings_folder):
        control.makeFile(keymap_settings_folder)

    if keymap == 'previous':

        location = control.join(keymap_settings_folder, 'alivegr_tvguide.xml')

        lang_int = 30022

        def seq():

            previous_keymap = """<keymap>
    <tvguide>
        <keyboard>
            <key id="61448">previousmenu</key>
        </keyboard>
    </tvguide>
    <tvchannels>
        <keyboard>
            <key id="61448">previousmenu</key>
        </keyboard>
    </tvchannels>
</keymap>
"""

            with open(location, 'w') as f:
                f.write(previous_keymap)

    elif keymap == 'mouse':

        location = control.transPath(
            control.join('special://profile', 'keymaps', 'alivegr_mouse.xml'))

        lang_int = 30238

        def seq():

            string_start = '<keymap><slideshow><mouse>'
            string_end = '</mouse></slideshow></keymap>'
            string_for_left = '<leftclick>NextPicture</leftclick>'
            string_for_right = '<rightclick>PreviousPicture</rightclick>'
            string_for_middle = '<middleclick>Rotate</middleclick>'
            string_for_up = '<wheelup>ZoomIn</wheelup>'
            string_for_down = '<wheeldown>ZoomOut</wheeldown>'

            classes = [
                string_for_left, string_for_right, string_for_middle,
                string_for_up, string_for_down
            ]

            map_left = control.lang(30241)
            map_right = control.lang(30242)
            map_middle = control.lang(30243)
            map_up = control.lang(30244)
            map_down = control.lang(30245)

            keys = [map_left, map_right, map_middle, map_up, map_down]

            control.okDialog(control.name(), control.lang(30240))

            indices = control.dialog.multiselect(control.name(), keys)

            if not indices:

                control.infoDialog(control.lang(30246))

            else:

                finalized = []

                for i in indices:
                    finalized.append(classes[i])

                joined = ''.join(finalized)

                to_write = string_start + joined + string_end

                with open(location, 'w') as f:
                    f.write(to_write)

                control.execute('Action(reloadkeymaps)')

    elif keymap == 'samsung':

        string = '''<keymap>
    <global>
        <keyboard>
            <key id="61670">contextmenu</key>
        </keyboard>
    </global>
    <fullscreenvideo>
        <keyboard>
            <key id="61670">osd</key>
        </keyboard>
    </fullscreenvideo>
    <visualisation>
        <keyboard>
            <key id="61670">osd</key>
        </keyboard>
    </visualisation>
</keymap>'''

        location = control.join(keymap_settings_folder, 'samsung.xml')

        lang_int = 30022

        def seq():

            with open(location, 'w') as f:
                f.write(string)

    elif keymap == 'stop_playback':

        string = '''<keymap>
    <fullscreenvideo>
        <keyboard>
            <key id="61448">stop</key>
        </keyboard>
        <keyboard>
            <key id="61448" mod="longpress">back</key>
        </keyboard>
    </fullscreenvideo>
    <visualisation>
        <keyboard>
            <key id="61448">stop</key>
        </keyboard>
        <keyboard>
            <key id="61448" mod="longpress">back</key>
        </keyboard>
    </visualisation>
</keymap>'''

        location = control.join(keymap_settings_folder, 'stop_playback.xml')

        lang_int = 30022

        def seq():

            with open(location, 'w') as f:
                f.write(string)

    yes = control.yesnoDialog(control.lang(lang_int))

    if yes:

        if path.exists(location):

            choices = [control.lang(30248), control.lang(30249)]

            _choice = control.selectDialog(choices,
                                           heading=control.lang(30247))

            if _choice == 0:

                seq()
                control.okDialog(
                    control.name(),
                    control.lang(30027) + ', ' + (control.lang(30028)))
                control.infoDialog(control.lang(30402))
                control.execute('Action(reloadkeymaps)')

            elif _choice == 1:

                control.deleteFile(location)
                control.infoDialog(control.lang(30402))
                control.execute('Action(reloadkeymaps)')

            else:

                control.infoDialog(control.lang(30403))

        else:

            seq()
            control.okDialog(
                control.name(),
                control.lang(30027) + ', ' + (control.lang(30028)))
            control.infoDialog(control.lang(30402))

            control.execute('Action(reloadkeymaps)')

    else:

        control.infoDialog(control.lang(30403))
コード例 #21
0
def conditionals(url):

    add_plugin_dirs(control.transPath(PLUGINS_PATH))

    def yt(uri):

        if uri.startswith('plugin://'):
            return uri

        if len(uri) == 11:

            uri = YT_URL + uri

        try:
            return youtube.wrapper(uri)
        except YouTubeException as exp:
            log_debug('Youtube resolver failure, reason: ' + repr(exp))
            return

    if 'youtu' in url or len(url) == 11:

        log_debug('Resolving with youtube addon...')

        return yt(url)

    elif HOSTS(url) and HostedMediaFile(url).valid_url():

        try:
            stream = resolve_url(url)
            log_debug('Resolving with Resolveurl...')
        except HTTPError:
            return url

        return stream

    elif HostedMediaFile(url).valid_url():

        if control.setting('show_alt_vod') == 'true':

            try:
                stream = resolve_url(url)
                log_debug('Resolving with Resolveurl...')
            except ResolverError:
                return
            except HTTPError:
                return url

            return stream

        else:

            control.okDialog('AliveGR', control.lang(30354))
            return 'https://static.adman.gr/inpage/blank.mp4'

    elif GM_BASE in url:

        sources = gm_source_maker(url)
        stream = mini_picker(sources['links'])

        return conditionals(stream)

    elif urlparse(GK_BASE).netloc in url:

        streams = gk_source_maker(url)
        stream = mini_picker(streams['links'])

        if control.setting('check_streams') == 'true':
            return stream
        else:
            return conditionals(stream)

    else:

        log_debug('Passing direct link...')

        return url