Exemple #1
0
def new_version(new=False):

    version_file = control.join(control.dataPath, 'version.txt')

    if not path.exists(version_file) or new:

        if not path.exists(control.dataPath):

            control.makeFile(control.dataPath)

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

        return True

    else:

        try:
            with open(version_file, encoding='utf-8') as f:
                version = f.read()
        except Exception:
            with open(version_file) as f:
                version = f.read()

        if version != control.version():
            return new_version(new=True)
        else:
            return False
def reddit_page(authorized=False, token=''):

    auth_page = """<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <title>Reddit Browser</title>
    </head>
    <body>
        <div style="text-align: center;">
            <h1>Reddit Browser, {version}</h1>
            {line1}!<br>
            {token}<br>
            {line2}
        </div>
    </body>
</html>
    """

    if authorized:
        html = auth_page.format(
            version=control.lang(30070).format(
                control.version()).encode('utf-8'),
            token=control.lang(30069).format(token).encode('utf-8'),
            line1=control.lang(30402).encode('utf-8'),
            line2=control.lang(30065).encode('utf-8'))
    else:
        html = auth_page.format(version=control.lang(30070).format(
            control.version()).encode('utf-8'),
                                token='',
                                line1=control.lang(30067).encode('utf-8'),
                                line2=control.lang(30068).encode('utf-8'))

    return html
Exemple #3
0
def user_agent():

    UA = '{0}, {1}: {2}:v{3} (by /u/TwilightZer0)'.format(
        platform.version(), platform.release(), control.name(),
        control.version())

    return UA
    def _top50(self, url):

        if control.setting('debug') == 'false':

            playlists = client.request(thgiliwt(url),
                                       headers={
                                           'User-Agent':
                                           'AliveGR, version: ' +
                                           control.version()
                                       })

        else:

            if control.setting('local_remote') == '0':
                local = control.setting('top50_local')
                try:
                    with open(local, encoding='utf-8') as xml:
                        playlists = xml.read()
                except Exception:
                    with open(local) as xml:
                        playlists = xml.read()
            elif control.setting('local_remote') == '1':
                playlists = client.request(control.setting('top50_remote'))
            else:
                playlists = client.request(url)

        self.data = client.parseDOM(playlists, 'item')

        for item in self.data:

            title = client.parseDOM(item, 'title')[0]
            genre = client.parseDOM(item, 'genre')[0]
            url = client.parseDOM(item, 'url')[0]
            image = thumb_maker(url.rpartition('=')[2])
            plot = client.parseDOM(item, 'description')[0]
            duration = client.parseDOM(item, 'duration')[0].split(':')
            duration = (int(duration[0]) * 60) + int(duration[1])

            item_data = ({
                'label': title,
                'title': title.partition(' - ')[2],
                'image': image,
                'url': url,
                'plot': plot,
                'comment': plot,
                'duration': duration,
                'genre': genre
            })

            self.list.append(item_data)

        return self.list
Exemple #5
0
def new_version(new=False):

    version_file = control.join(control.dataPath, 'version.txt')

    if not path.exists(version_file) or new:

        if not path.exists(control.dataPath):

            control.makeFile(control.dataPath)

        with open(version_file, 'w') as f:
            f.write(control.version())

        return True

    else:

        with open(version_file) as f:
            version = f.read()

        if version != control.version():
            return new_version(new=True)
        else:
            return False
    def __init__(self):

        # noinspection PyArgumentList
        super(Prompt, self).__init__(control.lang(30267).format(control.version()))

        self.yes_button = None
        self.no_button = None
        self.close_button = None
        self.do_not_ask_again_button = None
        self.description = None
        self.setGeometry(854, 480, 8, 3)
        self.set_controls()
        self.connect(pyxbmct.ACTION_NAV_BACK, self.close)
        self.connect(pyxbmct.ACTION_MOUSE_LEFT_CLICK, self.close)
        self.set_navigation()
    def __init__(self):

        # noinspection PyArgumentList
        super(Card, self).__init__(control.lang(30267).format(control.version()))

        self.changelog_button = None
        self.disclaimer_button = None
        self.close_button = None
        self.external_label = None
        self.description = None
        self.facebook_button = None
        self.twitter_button = None
        self.website_button = None
        self.setGeometry(854, 480, 8, 3)
        self.set_controls()
        self.connect(pyxbmct.ACTION_NAV_BACK, self.close)
        self.set_navigation()
Exemple #8
0
    def misc_list(self):

        if control.setting('debug') == 'false':

            playlist = client.request(thgiliwt('=' + self.misc),
                                      headers={
                                          'User-Agent':
                                          'AliveGR, version: ' +
                                          control.version()
                                      })

        else:

            if control.setting('local_remote') == '0':
                local = control.setting('misc_local')
                try:
                    with open(local, encoding='utf-8') as xml:
                        playlist = xml.read()
                except Exception:
                    with open(local) as xml:
                        playlist = xml.read()
            elif control.setting('local_remote') == '1':
                playlist = client.request(control.setting('misc_remote'))
            else:
                playlist = client.request(thgiliwt('==' + self.misc))

        self.data = client.parseDOM(playlist, 'item')

        for item in self.data:

            title = client.parseDOM(item, 'title')[0]
            icon = client.parseDOM(item, 'icon')[0]
            url = client.parseDOM(item, 'url')[0]
            url = url.replace('https://www.youtube.com/channel',
                              '{0}/channel'.format(YT_ADDON))
            url = '/?'.join(
                [url, 'addon_id={}'.format(control.addonInfo('id'))])

            item_data = {'title': title, 'icon': icon, 'url': url}

            self.list.append(item_data)

        return self.list
Exemple #9
0
def welcome():

    choices = [
        control.lang(30329),
        control.lang(30340),
        control.lang(30129),
        control.lang(30333)
    ]

    _choice = control.selectDialog(choices,
                                   heading=control.lang(30267).format(
                                       control.version()))

    if _choice in [0, -1]:
        control.close_all()
    elif _choice == 1:
        changelog()
    elif _choice == 2:
        disclaimer()
    elif _choice == 3:
        control.open_web_browser(WEBSITE)
Exemple #10
0
def checkpoint():

    check = time() + 10800
    try:
        new_version_prompt = control.setting(
            'new_version_prompt') == 'true' and remote_version() > int(
                control.version().replace('.', ''))
    except ValueError:  # will fail if version install is alpha or beta
        new_version_prompt = False

    if new_version():

        # if control.yesnoDialog(control.lang(30267)):
        #     changelog()
        welcome()

        cache_clear(notify=False)
        reset_idx(notify=False)

        if control.setting('debug') == 'true' or control.setting(
                'toggler') == 'true':

            from tulip.log import log_debug

            log_debug(
                'Debug settings have been reset, please do not touch these settings manually,'
                ' they are *only* meant to help developer test various aspects.'
            )

            control.setSetting('debug', 'false')
            control.setSetting('toggler', 'false')

        control.setSetting('last_check', str(check))

    elif new_version_prompt and time() > float(control.setting('last_check')):

        prompt()
        control.setSetting('last_check', str(check))
Exemple #11
0
    def misc_list(self):

        if control.setting('debug') == 'false':

            playlists = client.request(thgiliwt('=' + self.misc),
                                       headers={
                                           'User-Agent':
                                           'AliveGR, version: ' +
                                           control.version()
                                       })

        else:

            if control.setting('local_remote') == '0':
                local = control.setting('misc_local')
                with open(local) as xml:
                    playlists = xml.read()
                    xml.close()
            elif control.setting('local_remote') == '1':
                playlists = client.request(control.setting('misc_remote'))
            else:
                playlists = client.request(thgiliwt('==' + self.misc))

        self.data = client.parseDOM(playlists, 'item')

        for item in self.data:

            title = client.parseDOM(item, 'title')[0]
            icon = client.parseDOM(item, 'icon')[0]
            url = client.parseDOM(item, 'url')[0]
            url = url.replace('https://www.youtube.com/channel',
                              '{0}/channel'.format(yt_addon))

            item_data = (dict(title=title, icon=icon, url=url))

            self.list.append(item_data)

        return self.list
Exemple #12
0
    def live(self):

        if control.setting('debug') == 'false':

            result = client.request(thgiliwt('=' + self.alivegr),
                                    headers={
                                        'User-Agent':
                                        'AliveGR, version: ' +
                                        control.version()
                                    })

            result = dexteni(b64decode(result))

        else:

            if control.setting('local_remote') == '0':
                local = control.setting('live_local')
                with open(local) as xml:
                    result = xml.read()
                    xml.close()
            elif control.setting('local_remote') == '1':
                result = client.request(control.setting('live_remote'))
            else:
                result = client.request(thgiliwt('==' + self.alivegr))
                result = dexteni(b64decode(result))

        if control.setting('debug') == 'false':
            channels = client.parseDOM(result,
                                       'channel',
                                       attrs={'enable': '1'})
        else:
            channels = client.parseDOM(result,
                                       'channel',
                                       attrs={'enable': '1|2'})

        updated = client.parseDOM(result, 'channels', ret='updated')[0]

        for channel in channels:

            title = client.parseDOM(channel, 'name')[0]
            image = client.parseDOM(channel, 'logo')[0]
            if not image.startswith('http'):
                image = control.addonmedia(image,
                                           logos_id,
                                           theme='logos',
                                           media_subfolder=False)
            group = client.parseDOM(channel, 'group')[0]
            group = live_groups[group]
            url = client.parseDOM(channel, 'url')[0]

            website = client.parseDOM(channel,
                                      'website')[0].replace('&amp;', '&')

            info = client.parseDOM(channel, 'info')[0]
            if len(info) == 5 and info[:5].isdigit():
                info = control.lang(int(info))

            if ' - ' in info:
                if control.setting('lang_split') == '0':
                    if 'Greek' in control.infoLabel('System.Language'):
                        info = info.partition(' - ')[2]
                    elif 'English' in control.infoLabel('System.Language'):
                        info = info.partition(' - ')[0]
                    else:
                        info = info
                elif control.setting('lang_split') == '1':
                    info = info.partition(' - ')[0]
                elif control.setting('lang_split') == '2':
                    info = info.partition(' - ')[2]
                else:
                    info = info

            data = ({
                'title': title,
                'image': image,
                'group': str(group),
                'url': url,
                'genre': control.lang(group),
                'plot': info,
                'website': website
            })

            self.list.append(data)
            self.data.append(group)

        self.groups = list(OrderedDict.fromkeys(self.data))

        return self.list, self.groups, updated
def user_agent():

    UA = '{0} {1}:Reddit Browser:v{2} (by /u/tvaddonsdotco)'.format(
        platform.system(), platform.release(), control.version())

    return UA