Exemplo n.º 1
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:

        kodi_auth()

    elif choice == 2:

        manual_auth()

    if choice != -1:
        control.sleep(200)
        control.refresh()
Exemplo n.º 2
0
def reddit_subs(action, sr_name):

    if action is None:
        action = 'sub'
        sleep = True
    else:
        sleep = False

    if sr_name is None:
        from tulip.bookmarks import get
        bookmarks = get(file_=saved_subrs)
        if not bookmarks:
            return
        sr_name = ','.join([i['sr_name'] for i in bookmarks])

    post_data = {'action': action, 'sr_name': sr_name}

    result = client.request(base_link() + '/api/subscribe',
                            post=post_data,
                            headers=request_headers(),
                            output='response')

    if control.setting('debugging.toggle') == 'true':
        log_debug(result)

    if action == 'unsub' or sleep:

        if sleep:
            control.sleep(200)

        control.refresh()
Exemplo n.º 3
0
def lang_choice():
    def set_other_options():

        set_a_setting('locale.longdateformat', 'regional')
        set_a_setting('locale.shortdateformat', 'regional')
        set_a_setting('locale.speedunit', 'regional')
        set_a_setting('locale.temperatureunit', 'regional')
        set_a_setting('locale.timeformat', 'regional')
        # set_a_setting('locale.timezone', 'default')
        # set_a_setting('locale.timezonecountry', 'default')
        set_a_setting('locale.use24hourclock', 'regional')

    selections = [control.lang(30020), control.lang(30021)]

    dialog = control.selectDialog(selections)

    if dialog == 0:
        set_a_setting('locale.language', 'resource.language.en_gb')
        set_a_setting('locale.country', 'Central Europe')
        set_other_options()
    elif dialog == 1:
        set_a_setting('locale.language', 'resource.language.el_gr')
        set_a_setting('locale.country', 'Ελλάδα')
        set_other_options()
    else:
        control.execute('Dialog.Close(all)')

    control.sleep(100)
    refresh()
Exemplo n.º 4
0
def authorize():

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

    kodi_auth()
    control.sleep(200)
    control.refresh()
Exemplo n.º 5
0
def keys_registration():

    filepath = control.transPath(
        control.join(
            control.addon('plugin.video.youtube').getAddonInfo('profile'),
            'api_keys.json'))

    setting = control.addon('plugin.video.youtube').getSetting(
        'youtube.allow.dev.keys') == 'true'

    if file_exists(filepath):

        f = open(filepath)

        jsonstore = json.load(f)

        try:
            old_key_found = jsonstore['keys']['developer'][control.addonInfo(
                'id')]['api_key'] == 'AIzaSyCE6qoV77uQMWR6g2mIVzjQs8wtqqa_KyM'
        except KeyError:
            old_key_found = False

        no_keys = control.addonInfo('id') not in jsonstore.get(
            'keys', 'developer').get('developer') or old_key_found

        if setting and no_keys:

            keys = json.loads(decompress(b64decode(scramble)))

            register_api_keys(control.addonInfo('id'), keys['api_key'],
                              keys['id'], keys['secret'])

            control.sleep(200)

        f.close()
Exemplo n.º 6
0
def clear_bookmarks():

    bookmarks.clear('bookmark',
                    withyes=True,
                    file_=control.bookmarksFile,
                    notify=False,
                    label_yes_no=30025)
    control.sleep(200)
    control.refresh()
Exemplo n.º 7
0
def prevent_failure():

    for i in range(0, 500):

        if control.condVisibility('Window.IsActive(busydialog)'):
            control.sleep(100)
        else:
            control.execute('Dialog.Close(all,true)')
            break
Exemplo n.º 8
0
def clear_history(file_=history_file):

    if control.exists(file_):

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

    control.infoDialog(control.lang(30011))
    control.sleep(200)
    control.refresh()
Exemplo n.º 9
0
    def switch(query):

        pages = [control.lang(30026).format(i) for i in list(range(1, int(query) + 1))]

        choice = control.selectDialog(pages, heading=control.lang(30028))

        if choice != -1:
            control.setSetting('page', str(choice))
            control.sleep(200)
            control.refresh()
Exemplo n.º 10
0
def check_stream(stream_list,
                 shuffle_list=False,
                 start_from=0,
                 show_pd=False,
                 cycle_list=True):

    if not stream_list:
        return

    if shuffle_list:
        shuffle(stream_list)

    for (c, (h, stream)) in list(enumerate(stream_list[start_from:])):

        if stream.endswith('blank.mp4'):
            return stream

        if show_pd:
            pd = control.progressDialog
            pd.create(control.name(),
                      ''.join([control.lang(30459),
                               h.partition(': ')[2]]))

        try:
            resolved = conditionals(stream)
        except Exception:
            resolved = None

        if resolved is not None:
            if show_pd:
                pd.close()
            return resolved
        elif show_pd and pd.iscanceled():
            return
        elif c == len(stream_list[start_from:]) and not resolved:
            control.infoDialog(control.lang(30411))
            if show_pd:
                pd.close()
        elif resolved is None:
            if cycle_list:
                log_debug('Removing unplayable stream: {0}'.format(stream))
                stream_list.remove((h, stream))
                return check_stream(stream_list)
            else:
                if show_pd:
                    _percent = percent(c, len(stream_list[start_from:]))
                    pd.update(
                        _percent,
                        ''.join([control.lang(30459),
                                 h.partition(': ')[2]]))
                control.sleep(1000)
                continue
Exemplo n.º 11
0
def txt_box(heading, announce):

    window_id = 10147
    control_id1 = 1
    control_id2 = 5
    gui_window = control.window(window_id)

    control.execute('ActivateWindow(%d)' % window_id)
    control.sleep(200)

    gui_window.getControl(control_id1).setLabel(heading)

    gui_window.getControl(control_id2).setText(announce)
Exemplo n.º 12
0
def unpin():

    control.busy()

    title = control.infoLabel('ListItem.Title')

    unpin_from_file(PINNED, title)

    control.sleep(100)
    control.refresh()

    control.infoDialog(control.lang(30338), time=750)

    control.idle()
Exemplo n.º 13
0
    def switch(self):

        choices = [control.lang(30020), control.lang(30021)]

        choice = control.selectDialog(choices)

        if choice == 0:
            control.setSetting('sport', '0')
        elif choice == 1:
            control.setSetting('sport', '1')

        if choice != -1:
            control.sleep(100)
            control.refresh()
Exemplo n.º 14
0
    def vod_switcher(self, url):

        self.data = root(url)[1]

        translated = [control.lang(int(i)) for i in self.data]

        choice = control.selectDialog(heading=control.lang(30062), list=translated)

        if choice <= len(self.data) and not choice == -1:
            control.setSetting('vod_group', self.data[choice])
            control.idle()
            control.sleep(100)  # ensure setting has been saved
            control.refresh()
        else:
            control.execute('Dialog.Close(all)')
Exemplo n.º 15
0
def delete_from_history(txt, file_=history_file):

    with open(file_, 'r') as f:
        text = [i.rstrip('\n') for i in f.readlines()]

    text.remove(txt)

    with open(file_, 'w') as f:
        if not text:
            text = ''
        else:
            text = '\n'.join(text) + '\n'
        f.write(text)

    control.sleep(200)
    control.refresh()
Exemplo n.º 16
0
def page_selector(query):

    pages = [control.lang(30415).format(i) for i in list(range(1, int(query) + 1))]

    _choice = control.selectDialog(pages, heading=control.lang(30416))

    if _choice != -1:

        control.setSetting('page', str(_choice))
        control.sleep(200)
        control.refresh()

        if control.setting('pagination_reset') == 'true':
            # wait a second in order to ensure container is first loaded then reset the page
            control.sleep(1000)
            control.setSetting('page', '0')
Exemplo n.º 17
0
    def selector():

        choices = [control.lang(30004), control.lang(30005)]

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

        if choice == 0:
            control.setSetting('region', 'GR')
        elif choice == 1:
            control.setSetting('region', 'CY')

        if choice != -1:

            cache.FunctionCache().reset_cache()
            control.sleep(200)
            control.refresh()
Exemplo n.º 18
0
def add_to_history(file_=history_file):

    if not control.exists(file_):
        control.makeFiles(control.dataPath)

    txt = control.dialog.input(control.name())

    if not txt:
        return

    if txt not in read_from_history():

        with open(file_, 'a') as f:
            f.writelines(txt + '\n')

        trim_history(file_)
        control.sleep(200)
        control.refresh()
Exemplo n.º 19
0
def log_upload():

    exists = control.condVisibility('System.HasAddon(script.kodi.loguploader)')
    addon_path = control.transPath(control.join('special://', 'home', 'addons', 'script.kodi.loguploader'))

    if not exists:

        if path.exists(addon_path):
            control.enable_addon('script.kodi.loguploader')
        else:
            control.execute('InstallAddon(script.kodi.loguploader)')

        while not path.exists(addon_path):
            control.sleep(1000)
        else:
            control.execute('RunScript(script.kodi.loguploader)')

    else:

        control.execute('RunScript(script.kodi.loguploader)')
Exemplo n.º 20
0
def revoke():

    yesno = control.yesnoDialog(control.lang(30079))

    if yesno:

        post = {'token': control.setting('access.token')}
        headers = {'User-Agent': user_agent()}
        username, password = (client_id, '')
        result = client.request(api_link('revoke_token'),
                                post=post,
                                headers=headers,
                                username=username,
                                password=password,
                                output='response')

        if control.setting('debugging.toggle') == 'true':
            log_debug('Revoking tokens, response: ' + result[0])

        tokens_reset()

        control.sleep(200)
        control.refresh()
Exemplo n.º 21
0
    def run(self, query=None):

        if not 'Greek' in str(langs).split(','):
            control.directory(syshandle)
            control.infoDialog(control.lang(32002).encode('utf-8'))
            return

        if query is None:

            title = control.infoLabel('VideoPlayer.Title')

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

            year = control.infoLabel('VideoPlayer.Year')

            tvshowtitle = control.infoLabel('VideoPlayer.TVshowtitle')

            season = control.infoLabel('VideoPlayer.Season')

            episode = control.infoLabel('VideoPlayer.Episode')

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

            if not tvshowtitle == '':  # episode
                query = '%s S%02dE%02d' % (tvshowtitle, int(season),
                                           int(episode))
            elif not year == '':  # movie
                query = '%s (%s)' % (title, year)
            else:  # file
                query, year = getCleanMovieTitle(title)
                if not year == '': query = '%s (%s)' % (query, year)

        self.query = query

        threads = []

        threads.append(workers.Thread(self.xsubstv))
        threads.append(workers.Thread(self.subzxyz))
        threads.append(workers.Thread(self.subtitlesgr))

        [i.start() for i in threads]

        for i in range(0, 10 * 2):
            try:
                is_alive = [x.is_alive() for x in threads]
                if all(x == False for x in is_alive):
                    break
                if control.aborted is True:
                    break
                control.sleep(500)
            except:
                pass

        if len(self.list) == 0:
            control.directory(syshandle)
            return

        f = []

        f += [i for i in self.list if i['source'] == 'xsubstv']
        f += [i for i in self.list if i['source'] == 'subzxyz']
        f += [i for i in self.list if i['source'] == 'subtitlesgr']

        self.list = f

        for i in self.list:

            try:
                if i['source'] == 'subzxyz':
                    i['name'] = '[subzxyz] %s' % i['name']
                elif i['source'] == 'xsubstv':
                    i['name'] = '[xsubstv] %s' % i['name']
            except:
                pass

        for i in self.list:

            try:
                name, url, source, rating = i['name'], i['url'], i[
                    'source'], i['rating']

                u = {'action': 'download', 'url': url, 'source': source}
                u = '%s?%s' % (sysaddon, urllib.urlencode(u))

                item = control.item(label='Greek',
                                    label2=name,
                                    iconImage=str(rating),
                                    thumbnailImage='el')
                item.setProperty('sync', 'false')
                item.setProperty('hearing_imp', 'false')

                control.addItem(handle=syshandle,
                                url=u,
                                listitem=item,
                                isFolder=False)
            except:
                pass

        control.directory(syshandle)
Exemplo n.º 22
0
def player(url):

    qofs = []

    lofs = literal_eval(url)

    print(lofs)

    for item in lofs:

        if '320' in item:
            item = ttz
        elif '256' in item:
            item = tfs
        elif '192' in item:
            item = ont
        elif '130' in item:
            item = aac1
        elif '64' in item:
            item = aac2
        elif '32' in item:
            item = aac3
        else:
            item = ote

        qofs.append(item)

    if control.setting('quality_selector') == '0':

        choice = control.selectDialog(heading='Select quality', list=qofs)

        if choice <= len(lofs) and not choice == -1:

            link = lofs.pop(choice)

            stream = resolver(link)

            directory.resolve(stream)

        else:

            control.execute('Playlist.Clear')
            control.sleep(100)
            control.execute('Dialog.Close(all)')

    elif control.setting('quality_selector') == '1':

        stream = client.request(selector(qofs, lofs))
        stream = resolver(stream)
        directory.resolve(stream)

    elif control.setting('quality_selector') == '2':

        if 'MP3 320k' in qofs:
            stream = client.request(selector(qofs, lofs, ttz))
        elif 'MP3 256k' in qofs:
            stream = client.request(selector(qofs, lofs, tfs))
        elif 'MP3 192k' in qofs:
            stream = client.request(selector(qofs, lofs, ont))
        else:
            stream = client.request(selector(qofs, lofs))

        stream = resolver(stream)
        directory.resolve(stream)

    elif control.setting('quality_selector') == '3':

        stream = client.request(selector(qofs, lofs))
        stream = resolver(stream)
        directory.resolve(stream)

    elif control.setting('quality_selector') == '4':

        if 'AAC 128k' in qofs:
            stream = client.request(selector(qofs, lofs, aac1))
        elif 'AAC 64k' in qofs:
            stream = client.request(selector(qofs, lofs, aac2))
        elif 'AAC 32k' in qofs:
            stream = client.request(selector(qofs, lofs, aac3))
        else:
            stream = selector(qofs, lofs)

        stream = resolver(stream)
        directory.resolve(stream)

    elif control.setting('quality_selector') == '5':

        if 'AAC 128k' in qofs:
            stream = client.request(selector(qofs, lofs, aac3))
        elif 'AAC 64k' in qofs:
            stream = client.request(selector(qofs, lofs, aac2))
        elif 'AAC 32k' in qofs:
            stream = client.request(selector(qofs, lofs, aac1))
        else:
            stream = selector(qofs, lofs)

        stream = resolver(stream)
        directory.resolve(stream)

    else:

        selector(qofs, lofs)
Exemplo n.º 23
0
def refresh_and_clear():

    cache_clear()
    control.sleep(100)
    refresh()
Exemplo n.º 24
0
        def seq(choose):

            control.setSetting('papers_group', choose)
            control.idle()
            control.sleep(100)
            control.refresh()
    def root(self):

        self.list = [{
            'title': control.lang(30001),
            'action': 'live',
            'icon': 'live.jpg'
        }, {
            'title':
            control.lang(30036),
            'action':
            'play',
            'isFolder':
            'False',
            'url':
            self.radio_url,
            'icon':
            'radio.png',
            'fanart':
            control.join(control.addonPath, 'resources', 'media',
                         'bgradio.jpg')
        }, {
            'title': control.lang(30002),
            'action': 'videos',
            'icon': 'youtube.png'
        }, {
            'title': control.lang(30003),
            'action': 'playlist',
            'url': 'PL0cttCfQzkdtUFNDIHozh_EpVSUYwCVuI',
            'icon': 'newspapers.png'
        }, {
            'title': control.lang(30004),
            'action': 'playlist',
            'url': 'PL0cttCfQzkduInQQt3nCEKYValRROk1AV',
            'icon': 'users.png'
        }, {
            'title': control.lang(30005),
            'action': 'playlist',
            'url': 'PL0cttCfQzkdskGTTd3pLvUVKmlK8UyK3J',
            'icon': 'diet.png'
        }, {
            'title': control.lang(30006),
            'action': 'playlist',
            'url': 'PL0cttCfQzkdve608IsDG2jHqQ2AwAB4rm',
            'icon': 'sports.png'
        }, {
            'title': control.lang(30007),
            'action': 'playlist',
            'url': 'PL0cttCfQzkduVZzwQZyAXOgkL_2CRCBlC',
            'icon': 'culture.png'
        }, {
            'title': control.lang(30008),
            'action': 'playlist',
            'url': 'PL0cttCfQzkdsgy5MDvGyl_Qsw7bKKq7V9',
            'icon': 'events.png'
        }, {
            'title': control.lang(30009),
            'action': 'playlist',
            'url': 'PL0cttCfQzkdvjJGEFQsNvQSOXaFA6jFde',
            'icon': 'world.png'
        }, {
            'title': control.lang(30010),
            'action': 'playlist',
            'url': 'PL0cttCfQzkdtnlBmYgZM75dVPbN3V6YsP',
            'icon': 'doctor.png'
        }, {
            'title':
            control.lang(30013),
            'action':
            'favourites' if 'CEMC' in control.infoLabel('System.FriendlyName')
            else 'bookmarks',
            'icon':
            'favourites.png'
        }, {
            'title': control.lang(30017),
            'action': 'search',
            'icon': 'search.png'
        }, {
            'title': control.lang(30025),
            'action': 'weather',
            'icon': 'weather.png'
        }, {
            'title': control.lang(30032),
            'action': 'external_links',
            'icon': 'external.png'
        }, {
            'title': control.lang(30037),
            'action': 'presentation',
            'icon': control.addonInfo('icon'),
            'isFolder': 'False',
            'isPlayable': 'False'
        }, {
            'title': control.lang(30012),
            'action': 'settings',
            'icon': 'settings.png',
            'isFolder': 'False',
            'isPlayable': 'False'
        }, {
            'title': control.lang(30018),
            'action': 'quit_kodi',
            'icon': 'quit.png',
            'isFolder': 'False',
            'isPlayable': 'False'
        }]

        if control.setting('show_exit_button') == 'false':
            self.list = [
                d for d in self.list if d.get('action') != 'quit_kodi'
            ]

        if not get_weather_bool()[0] and not get_weather_bool()[1]:
            self.list = [d for d in self.list if d.get('action') != 'weather']

        for item in self.list:

            cache_clear = {'title': 30015, 'query': {'action': 'cache_clear'}}
            refresh_cm = {'title': 30022, 'query': {'action': 'refresh'}}
            item.update({'cm': [cache_clear, refresh_cm]})

        control.set_view_mode('500')
        control.sleep(50)
        directory.add(self.list, content='videos')
        control.wait(1)
        checkpoint()
Exemplo n.º 26
0
    def seq(choose):

        control.setSetting('group', choose)
        control.sleep(50)
        control.refresh()
Exemplo n.º 27
0
elif action == 'unpin':

    utils.unpin()

elif action == 'bookmarks':

    bookmarks.Indexer().bookmarks()

elif action == 'clear_bookmarks':
    bm.clear('bookmark',
             withyes=True,
             label_yes_no=30311,
             file_=control.bookmarksFile,
             notify=False)
    control.sleep(200)
    control.refresh()

elif action == 'search':

    search.Indexer().search()

elif action == 'settings':

    settings.Indexer().menu()

elif action == 'tools_menu':

    utils.tools_menu()

elif action == 'openSettings':
Exemplo n.º 28
0
if action is None:
    ert.Indexer().root()

elif action == 'addBookmark':
    bookmarks.add(url)

elif action == 'deleteBookmark':
    bookmarks.delete(url)

elif action == 'clear_bookmarks':
    bookmarks.clear('bookmark',
                    withyes=True,
                    file_=bookmarksFile,
                    notify=False,
                    label_yes_no=30025)
    sleep(200)
    refresh()

elif action == 'channels':
    ert.Indexer().channels()

elif action == 'bookmarks':
    ert.Indexer().bookmarks()

elif action == 'index':
    ert.Indexer().index()

elif action == 'sports':
    ert.Indexer().sports()

elif action == 'listing':
Exemplo n.º 29
0
        def seq(group):

            control.setSetting('live_group', str(group))
            control.idle()
            control.sleep(100)
            control.refresh()
    def get(self, query):

        query = py3_dec(query)

        try:

            query = ' '.join(
                unquote_plus(re.sub(r'%\w\w', ' ', quote_plus(query))).split())

            match = re.findall(
                r'(.+?)(?: -)?[ \.](?:\(?(\d{4})\)?|S?(\d{1,2})X?(?: |\.)?E?P?(\d{1,2})(?: \. (.+))?)',
                query,
                flags=re.I)

            if match:

                query, year, season, episode, episode_title = match[0]

                search = quote_plus(' '.join(
                    [query, 's', season, 'e', episode, episode_title]))

                url = self.search_show.format(search)

            else:

                url = self.search_movie.format(quote_plus(query))

            self.data = [
                client.request(url, timeout=control.setting('timeout'))
            ]

            try:
                _next_button = client.parseDOM(
                    self.data[0],
                    'a',
                    attrs={'class': 'next page-numbers'},
                    ret='href')[0]
            except IndexError:
                _next_button = None

            while _next_button:

                self.data.append(
                    client.request(_next_button,
                                   timeout=control.setting('timeout')))

                try:
                    _next_button = client.parseDOM(
                        self.data[-1],
                        'a',
                        attrs={'class': 'next page-numbers'},
                        ret='href')[0]
                    control.sleep(200)
                except IndexError:
                    _next_button = None
                    break

            html = '\n'.join(self.data)

            items = client.parseDOM(html,
                                    'div',
                                    attrs={'class': 'article__summary'})

            if not items:
                log_debug('Vipsubs.gr did not provide any results')
                return

        except Exception as e:

            _, __, tb = sys.exc_info()

            print(traceback.print_tb(tb))

            log_debug('Vipsubs.gr failed at get function, reason: ' + str(e))

            return

        for item in items:

            try:

                label = itertags_wrapper(item, 'a', attrs={'rel':
                                                           "bookmark"})[0].text

                label = client.replaceHTMLCodes(label)

                url = itertags_wrapper(item, 'a', ret='href')[-1]
                if 'vipsubs.gr' in url:
                    continue
                rating = 10.0

                self.list.append({
                    'name': label,
                    'url': url,
                    'source': 'vipsubs',
                    'rating': rating,
                    'title': label,
                    'downloads': '1000'
                })

            except Exception as e:

                _, __, tb = sys.exc_info()

                print(traceback.print_tb(tb))

                log_debug(
                    'Vipsubs.gr failed at self.list formation function, reason: '
                    + str(e))

                return

        return self.list