def bm_list():

    bm = bookmarks.get()

    na = [{'title': 30012, 'action': None, 'icon': 'empty.png'}]

    if not bm:
        directory.add(na)
        return na

    for item in bm:
        bookmark = dict((k, v) for k, v in item.iteritems() if not k == 'next')
        bookmark['delbookmark'] = item['url']
        item.update({
            'cm': [{
                'title': 30007,
                'query': {
                    'action': 'deleteBookmark',
                    'url': json.dumps(bookmark)
                }
            }]
        })

    il = sorted(bm, key=lambda k: k['title'].lower())

    directory.add(il, content='videos')
Exemple #2
0
    def persons_index(self, url, post, get_list=True):

        if CACHE_DEBUG:
            self.list = self.persons_listing(url, post)
        else:
            self.list = cache.get(self.persons_listing, 48, url, post)

        if self.list is None:
            return

        for item in self.list:

            item.update({'action': 'listing', 'icon': iconname('user')})

            bookmark = dict(
                (k, v) for k, v in iteritems(item) if not k == 'next')
            bookmark['bookmark'] = item['url']
            bookmark_cm = {
                'title': 30080,
                'query': {
                    'action': 'addBookmark',
                    'url': json.dumps(bookmark)
                }
            }
            refresh_cm = {'title': 30054, 'query': {'action': 'refresh'}}
            item.update({'cm': [bookmark_cm, refresh_cm]})

        if get_list:
            return self.list
        else:
            directory.add(self.list)
Exemple #3
0
    def shows(self, url):

        self.list = cache.get(self.generic_listing, 24, url)

        if self.list is None:
            return

        for i in self.list:

            i.update({'action': 'episodes'})

            bookmark = dict((k, v) for k, v in iteritems(i) if not k == 'next')
            bookmark['bookmark'] = i['url']

            i.update({
                'cm': [{
                    'title': 32501,
                    'query': {
                        'action': 'addBookmark',
                        'url': json.dumps(bookmark)
                    }
                }]
            })

        directory.add(self.list, content='videos')
    def bookmarks(self):

        self.list = bookmarks.get()

        if not self.list:
            na = [{'title': 30016, 'action': None, 'icon': 'open-box.png'}]
            directory.add(na)
            return

        for item in self.list:
            bookmark = dict(
                (k, v) for k, v in iteritems(item) if not k == 'next')
            bookmark['delbookmark'] = item['url']
            item.update({
                'cm': [{
                    'title': 30014,
                    'query': {
                        'action': 'deleteBookmark',
                        'url': json.dumps(bookmark)
                    }
                }]
            })

        self.list = sorted(self.list, key=lambda k: k['title'].lower())

        directory.add(self.list)
Exemple #5
0
    def gm_sports(self):

        if CACHE_DEBUG:
            html = root(SPORTS)
        else:
            html = cache.get(root, 48, SPORTS)

        options = re.compile('(<option value.+?</option>)', re.U).findall(html)

        icons = [
            'https://www.shareicon.net/data/256x256/2015/11/08/157712_sport_512x512.png',
            'https://www.shareicon.net/data/256x256/2015/12/07/196797_ball_256x256.png'
        ]

        items = zip(options, icons)

        for item, image in items:

            title = client.parseDOM(item, 'option')[0]
            url = client.parseDOM(item, 'option', ret='value')[0]
            url = client.replaceHTMLCodes(url)
            index = urljoin(GM_BASE, url)

            data = {
                'title': title,
                'action': 'listing',
                'url': index,
                'image': image
            }
            self.list.append(data)

        directory.add(self.list)
def root():

    null = [{'title': control.lang(30009), 'action': 'add'}]

    urls = tools.read_from_history()

    if not urls:
        directory.add(null)
    else:
        menu = [{
            'title': url,
            'action': 'play',
            'isFolder': 'False',
            'url': url
        } for url in urls]
        for m in menu:
            add_cm = {'title': 30009, 'query': {'action': 'add'}}
            refresh_cm = {'title': 30005, 'query': {'action': 'refresh'}}
            clear_cm = {'title': 30010, 'query': {'action': 'clear_history'}}
            clear_fm_h_cm = {
                'title': 30013,
                'query': {
                    'action': 'delete_from_history',
                    'query': m['url']
                }
            }
            m.update({'cm': [add_cm, refresh_cm, clear_cm, clear_fm_h_cm]})
        directory.add(menu)
Exemple #7
0
    def index(self, url):

        if self.basecy_link in url:
            self.list = self.index_cy(url)
        elif self.basegr_link in url:
            self.list = self.index_gr(url)

        if not self.list:
            return

        for i in self.list:
            if 'action' not in i:
                i.update({'action': 'episodes'})
            if 'next' in i:
                i.update({'nextaction': 'index'})

        for i in self.list:
            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)}}]})

        if self.basegr_link in url:

            control.sortmethods('title')
            control.sortmethods()

        directory.add(self.list, content='videos')
Exemple #8
0
    def techno_choices(self, url):

        self.list = cache.get(youtube.youtube(key=thgiliwt(api_keys['api_key']), replace_url=replace_url).playlist, 12, url)

        if self.list is None:

            return

        for i in self.list:
            i['label'] = i.pop('title')
            # process stupid descriptions/comments put up by uploaders on labels
            i['label'] = re.sub(r'PREMIERE ?:|\(full version\)\.mp4|\(?(?:Un)?Official.*\)? ?(?:HD)?|\[?HD (?:108|72)0p\]?', '', i['label'], flags=re.IGNORECASE)

        for count, i in list(enumerate(self.list, start=1)):

            if '–' in i['label']:
                sep = '–'
            elif ':' in i['label'] and not '-' in i['label']:
                sep = ':'
            elif '-' in i['label']:
                sep = '-'
            else:
                sep = ' '

            artist, separator, title = i['label'].partition(sep)

            if '&' in artist:
                artists_separator = '&'
            elif ',' in artist:
                artists_separator = ','
            elif 'feat.' in artist:
                artists_separator = 'feat.'
            elif 'feat' in artist:
                artists_separator = 'feat'
            elif 'Feat' in artist:
                artists_separator = 'Feat'
            else:
                artists_separator = None

            if artists_separator:
                artist = [a.strip() for a in artist.split(artists_separator)]
                on_label = ' / '.join(artist)
            else:
                on_label = artist.strip()
                artist = [artist.strip()]

            i.update(
                {
                    'action': 'play', 'isFolder': 'False', 'title': title, 'label': ' '.join([on_label, separator , title]),
                    'album': control.lang(30292), 'fanart': 'https://i.ytimg.com/vi/vtjL9IeowUs/maxresdefault.jpg',
                    'tracknumber': count, 'count': count, 'artist': artist
                }
            )

            if control.setting('audio_only') == 'true' and control.condVisibility('Window.IsVisible(music)'):
                i['artist'] = on_label

        control.sortmethods('tracknum', mask='%A')

        directory.add(self.list, content=self.content, infotype=self.infotype, argv=self.argv)
def directory_picker(url, argv):

    params = dict(parse_qsl(argv[2][1:]))

    items = items_directory(url, params)

    if items is None:
        return

    for i in items:

        add_to_playlist = {
            'title': 30226,
            'query': {
                'action': 'add_to_playlist'
            }
        }
        clear_playlist = {
            'title': 30227,
            'query': {
                'action': 'clear_playlist'
            }
        }
        i.update({
            'cm': [add_to_playlist, clear_playlist],
            'action': 'play',
            'isFolder': 'False'
        })

    directory.add(items, content='movies', argv=argv)

    prevent_failure()
Exemple #10
0
    def shows(self):

        self.list = [
            {
                'title': control.lang(30010),
                'url': self.entertainment_link,
                'icon': 'shows.jpg'
            }
            ,
            {
                'title': control.lang(30016),
                'url': self.interviews_link,
                'icon': 'interviews.jpg'
            }
            ,
            {
                'title': control.lang(30017),
                'url': self.ksena_docs,
                'icon': 'documentaries.jpg'
            }
            ,
            {
                'title': control.lang(30018),
                'url': self.ellinika_docs,
                'icon': 'documentaries.jpg'
            }
        ]

        for i in self.list:
            i.update({'action': 'listing'})

        directory.add(self.list)
Exemple #11
0
    def mgreekz_top10(self):

        self.list = cache.get(self._mgreekz_top10, 24)

        if self.list is None:
            log_debug('Mad Greekz top 10 section failed to load')
            return

        for item in self.list:
            item.update({'action': 'play', 'isFolder': 'False'})

        for count, item in list(enumerate(self.list, start=1)):
            add_to_playlist = {'title': 30226, 'query': {'action': 'add_to_playlist'}}
            clear_playlist = {'title': 30227, 'query': {'action': 'clear_playlist'}}
            item.update(
                {
                    'cm': [add_to_playlist, clear_playlist], 'album': control.lang(30127),
                    'fanart': control.addonmedia(
                        addonid=art_id, theme='networks', icon='mgz_fanart.jpg',
                        media_subfolder=False
                    ), 'tracknumber': count, 'code': count
                }
            )

        control.sortmethods('tracknum', mask='%A')
        directory.add(self.list, content=self.content, infotype=self.infotype, argv=self.argv)
Exemple #12
0
    def series(self):

        self.list = [
            {
                'title': control.lang(30047),
                'url': self.greek_series_link,
                'icon': 'series.jpg'
            }
            ,
            {
                'title': control.lang(30057),
                'url': self.series_link,
                'icon': 'series.jpg'
            }
            ,
            {
                'title': control.lang(30053),
                'url': self.catchup_link,
                'icon': 'series.jpg'
            }
            ,
            {
                'title': control.lang(30054),
                'url': self.web_series_link,
                'icon': 'series.jpg'
            }
        ]

        for i in self.list:
            i.update({'action': 'listing'})

        directory.add(self.list)
Exemple #13
0
    def bookmarks(self):

        self.list = bookmarks.get()

        if not self.list:
            na = [{'title': control.lang(30058), 'action': None}]
            directory.add(na)
            return

        for i in self.list:
            bookmark = dict((k, v) for k, v in iteritems(i) if not k == 'next')
            bookmark['delbookmark'] = i['url']
            i.update({'cm': [{'title': 30502, 'query': {'action': 'deleteBookmark', 'url': json.dumps(bookmark)}}]})

        control.sortmethods('title')

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

            clear_menu = {
                'title': control.lang(30059), 'action': 'clear_bookmarks'
            }

            self.list.insert(0, clear_menu)

        directory.add(self.list, content='videos')
Exemple #14
0
def playlist(plid):

    ilist = cache.get(youtube.youtube(key=key).playlist, 12, plid)

    if ilist is None:
        return

    for i in ilist:
        i.update({'action': 'play', 'isFolder': 'False'})

    for item in ilist:
        bookmark = dict((k, v) for k, v in item.iteritems() if not k == 'next')
        bookmark['bookmark'] = item['url']
        bm_cm = {
            'title': 30006,
            'query': {
                'action': 'addBookmark',
                'url': json.dumps(bookmark)
            }
        }
        refresh = {'title': 30008, 'query': {'action': 'refresh'}}
        cache_clear = {'title': 30005, 'query': {'action': 'cache_clear'}}
        item.update({'cm': [refresh, cache_clear, bm_cm]})

    directory.add(ilist, content='videos')
    def root(self):

        self.menu = [{
            'title': control.lang(30029) + ' ' + active_mode()[0],
            'action': 'mode_change',
            'boolean': control.setting('show.mode') == 'true'
        }, {
            'title': 'Reddit: ' + control.lang(30120),
            'action': 'listing',
            'url': base_link() + '/hot/',
            'icon': 'hot.png',
            'boolean': control.setting('show.hot') == 'true'
        }, {
            'title': 'Reddit: ' + control.lang(30121),
            'action': 'listing',
            'url': base_link() + '/new/',
            'icon': 'new.png',
            'boolean': control.setting('show.new') == 'true'
        }, {
            'title': control.lang(30001),
            'action': 'search',
            'url': 'media',
            'icon': 'search_media_files.png',
            'boolean': control.setting('show.media') == 'true'
        }, {
            'title': control.lang(30012),
            'action': 'search',
            'url': 'subreddits',
            'icon': 'search_reddit.png',
            'boolean': control.setting('show.subreddits') == 'true'
        }, {
            'title': control.lang(30002),
            'action': 'saved_subreddits',
            'icon': 'saved_subreddits.png',
            'boolean': control.setting('show.saved') == 'true'
        }, {
            'title': control.lang(30027),
            'action': 'bookmarks',
            'icon': 'bookmarks.png',
            'boolean': control.setting('show.bookmarks') == 'true'
        }, {
            'title': control.lang(30028),
            'action': 'tools',
            'icon': 'settings_tools.png',
            'boolean': control.setting('show.tools') == 'true'
        }]

        my_account = {
            'title': control.lang(30090),
            'action': 'my_account',
            'icon': 'my_account.png',
            'boolean': control.setting('show.account') == 'true'
        }

        if len(control.setting('access.token')) > 0:
            self.menu.insert(5, my_account)

        self.list = [i for i in self.menu if i['boolean']]

        directory.add(self.list, content='addons')
Exemple #16
0
def bookmarks():

    self_list = _bookmarks.get()

    if not self_list:
        na = [{'title': control.lang(30007), 'action': None}]
        directory.add(na)
        return

    for i in self_list:
        bookmark = dict((k, v) for k, v in iteritems(i) if not k == 'next')
        bookmark['delbookmark'] = i['url']
        i.update({
            'cm': [{
                'title': 30006,
                'query': {
                    'action': 'deleteBookmark',
                    'url': json.dumps(bookmark)
                }
            }]
        })

    control.sortmethods()
    control.sortmethods('title')

    directory.add(self_list, content='videos')
    def listing(self, url=None, return_list=False, query=None):

        if url:
            self.data = cache.get(self.items_list,
                                  int(control.setting('cache.size')), url)
        else:
            self.data = cache.get(self.replies_viewer,
                                  int(control.setting('cache.size')), query)

        if self.data is None:

            return

        self.list = action_updater(self.data)

        self.menu = cm_updater(self.list, url)

        if return_list:

            return self.menu

        else:

            if active_mode()[1] == 'pictures':

                directory.add(self.menu, infotype='pictures')

            else:

                directory.add(self.menu, content='movies')
Exemple #18
0
def live():

    self_list = list_live_items()

    if self_list is None:
        return

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

    for item in self_list:

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

    control.sortmethods()
    control.sortmethods('title')

    directory.add(self_list, content='videos')
Exemple #19
0
    def recent(self):

        if control.setting('region') == 'CY':
            url = self.yt_id_cy
        else:
            url = self.yt_id_gr

        self.list = self.yt_videos(url)

        if self.list is None:
            return

        for i in self.list:

            i.update({'title': client.replaceHTMLCodes(py2_decode(i['title'])), 'action': 'play', 'isFolder': 'False'})

        if len(self.list) > int(control.setting('pagination_integer')) and control.setting('paginate') == 'true':

            try:

                pages = utils.list_divider(self.list, int(control.setting('pagination_integer')))
                self.list = pages[int(control.setting('page'))]
                reset = False

            except Exception:

                pages = utils.list_divider(self.list, int(control.setting('pagination_integer')))
                self.list = pages[0]
                reset = True

            self.list.insert(0, self.page_menu(len(pages), reset=reset))

        directory.add(self.list)
    def songs_index(self, url, album):

        self.list = self.music_list(url)

        for count, item in list(enumerate(self.list, start=1)):

            item.update({'action': 'play', 'isFolder': 'False'})
            add_to_playlist = {
                'title': 30226,
                'query': {
                    'action': 'add_to_playlist'
                }
            }
            clear_playlist = {
                'title': 30227,
                'query': {
                    'action': 'clear_playlist'
                }
            }
            try:
                item.update({
                    'cm': [add_to_playlist, clear_playlist],
                    'album': album.encode('latin-1'),
                    'tracknumber': count
                })
            except:
                item.update({
                    'cm': [add_to_playlist, clear_playlist],
                    'album': album,
                    'tracknumber': count
                })

        directory.add(self.list, content=self.content, infotype=self.infotype)
Exemple #21
0
    def news_episodes(self, query):

        self.list = self.news_episodes_listing(query)

        if self.list is None:
            return

        for i in self.list:
            i.update({'action': 'play', 'isFolder': 'False'})

        if len(self.list) > int(control.setting('pagination_integer')) and control.setting('paginate') == 'true':

            try:

                pages = utils.list_divider(self.list, int(control.setting('pagination_integer')))
                self.list = pages[int(control.setting('page'))]
                reset = False

            except Exception:

                pages = utils.list_divider(self.list, int(control.setting('pagination_integer')))
                self.list = pages[0]
                reset = True

            self.list.insert(0, self.page_menu(len(pages), reset=reset))

        directory.add(self.list, content='videos')
def bookmarks():

    self_list = bm.get()

    if not self_list:
        na = [{'title': control.lang(30007), 'action': None}]
        directory.add(na)
        return

    for i in self_list:

        bookmark = dict((k, v) for k, v in iteritems(i) if not k == 'next')
        bookmark['delbookmark'] = i['url']
        i.update({
            'cm': [{
                'title': 30502,
                'query': {
                    'action': 'deleteBookmark',
                    'url': json.dumps(bookmark)
                }
            }]
        })

    self_list.sort(key=lambda k: k['title'].lower())

    directory.add(self_list, infotype='music')
Exemple #23
0
    def theater(self):

        if CACHE_DEBUG:
            self.data = root(THEATER)[0]
        else:
            self.data = cache.get(root, 24, THEATER)[0]

        if self.data is None:
            return

        try:
            self.list = [
                item for item in self.data
                if item['group'] == control.setting('vod_group')
            ]
        except Exception:
            control.setSetting('vod_group', '30213')
            self.list = self.data

        for item in self.list:
            item.update({'icon': iconname('theater'), 'action': 'listing'})

        if control.setting('show_vod_switcher'):
            self.switch.update({'url': THEATER})

            self.list.insert(0, self.switch)

        directory.add(self.list)
def radios(url):

    self_list = radios_list(url)

    if self_list is None:
        return

    if url == ALL_LINK:

        self_list.extend(_devpicks())

    for i in self_list:

        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(self_list, infotype='music')
Exemple #25
0
    def events(self, url):

        self.list = cache.get(self.event_list, 12, url)

        if self.list is None:
            log_debug(
                'Events section failed to load, try resetting indexer methods')
            return

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

        directory.add(self.list)
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')
Exemple #27
0
    def archive(self):

        self.list = cache.get(
            youtube.youtube(key=self.yt_key).playlists, 12, self.yt_channel)

        if self.list is None:
            return

        for i in self.list:
            i['title'] = client.replaceHTMLCodes(i['title'])
            i.update({'action': 'episodes'})
            bookmark = dict((k, v) for k, v in iteritems(i) if not k == 'next')
            bookmark['bookmark'] = i['url']
            i.update({
                'cm': [{
                    'title': 32501,
                    'query': {
                        'action': 'addBookmark',
                        'url': json.dumps(bookmark)
                    }
                }]
            })

        control.sortmethods('title')

        directory.add(self.list, content='videos')
Exemple #28
0
    def input_stream_addons(self):

        self.list = [{
            'title':
            control.lang(30253),
            'action':
            'isa_enable',
            'isFolder':
            'False',
            'isPlayable':
            'False',
            'cm': [{
                'title': 30253,
                'query': {
                    'action': 'other_addon_settings',
                    'query': 'inputstream.adaptive'
                }
            }]
        }, {
            'title': control.lang(30273),
            'action': 'other_addon_settings',
            'query': 'inputstream.adaptive',
            'isFolder': 'False',
            'isPlayable': 'False'
        }, {
            'title': control.lang(30275),
            'action': 'rtmp_enable',
            'isFolder': 'False',
            'isPlayable': 'False'
        }]

        directory.add(self.list)
Exemple #29
0
    def podcasts(self, url=None):

        if url is None:
            url = self.podcasts_link

        self.list = cache.get(self.pod_listing, 24, url)

        if self.list is None:
            return

        for i in self.list:

            i.update({'action': 'episodes'})

            bookmark = dict((k, v) for k, v in iteritems(i) if not k == 'next')
            bookmark['bookmark'] = i['url']

            i.update({
                'cm': [{
                    'title': 32501,
                    'query': {
                        'action': 'addBookmark',
                        'url': json.dumps(bookmark)
                    }
                }]
            })

        directory.add(self.list, content='music')
Exemple #30
0
    def teams_index(self):

        index_items = self.index()

        if index_items is None:
            return

        if control.setting('sport') == '0':
            integer = 30020
            self.list = index_items['teams_football']
        else:
            self.list = index_items['teams_basket']
            integer = 30021

        for i in self.list:
            i.update({'action': 'videos'})
            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)}}]})

        selector = {
            'title': control.lang(30019).format(control.lang(integer)),
            'action': 'switch',
            'isFolder': 'False',
            'isPlayable': 'False'
        }

        self.list.insert(0, selector)

        directory.add(self.list)