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')
Ejemplo n.º 2
0
def mini_picker(hl, sl, params):

    try:
        image = params.get('image').encode('latin-1')
        title = params.get('title').encode('latin-1')
    except (UnicodeEncodeError, UnicodeDecodeError, AttributeError):
        image = params.get('image')
        title = params.get('title')

    if len(hl) == 1:

        stream = cache.get(gm_debris, 12, sl[0])

        if control.setting('action_type') == '2':
            if control.setting('auto_play') == 'true':
                play_url = sysaddon + play_action + quote(
                    stream) + '&image=' + quote(image) + '&title=' + quote(
                        title)
                control.execute('PlayMedia("{0}")'.format(play_url))
            else:
                m3u_file = playlist_maker(hl, sl, title, image)
                control.playlist().load(m3u_file)
                control.openPlaylist()
        else:
            control.infoDialog(hl[0])
            return stream

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

        m3u_file = playlist_maker(hl, sl, title, image)

        control.playlist().load(m3u_file)

        if control.setting('auto_play') == 'true':
            control.execute('Action(Play)')
        else:
            control.openPlaylist()
        return

    else:

        choice = control.selectDialog(heading=control.lang(30064), list=hl)

        if choice <= len(sl) and not choice == -1:
            popped = sl[choice]
            return cache.get(gm_debris, 12, popped)
        else:
            return
Ejemplo n.º 3
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)
Ejemplo n.º 4
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)
Ejemplo n.º 5
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)
Ejemplo n.º 6
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')
Ejemplo n.º 7
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')
Ejemplo n.º 8
0
def directory_picker(url, argv):

    params = dict(parse_qsl(argv[2].replace('?', '')))

    items = cache.get(items_directory, 12, 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)
Ejemplo n.º 9
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')
Ejemplo n.º 10
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')
Ejemplo n.º 11
0
def gk_filler(url):

    items = []

    if CACHE_DEBUG:
        sources = gk_debris(url)
    else:
        sources = cache.get(gk_debris, 6, url)

    lists = list(zip(sources['hosts'], sources['links']))

    t = sources['title']
    y = sources['year']
    i = sources['image']
    d = sources['duration']

    for h, l in lists:

        label = SEPARATOR.join([t, h])

        data = {
            'label': label,
            'title': '{0} ({1})'.format(t, y),
            'url': l,
            'image': i,
            'year': y,
            'duration': d
        }

        items.append(data)

    return items
Ejemplo n.º 12
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)
Ejemplo n.º 13
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)
Ejemplo n.º 14
0
    def download(self, path, url):

        try:
            cookie = None

            anonymous = (self.user == '' or self.password == '')

            code, result = client.request(url, output='response', error=True)

            if code == '429' and anonymous is True:
                control.dialog.ok(str('xsubs.tv'), str(result), str(''))
                return
            elif anonymous is False:
                cookie = cache.get(self.cookie, 6)

            result, headers, content, cookie = client.request(
                url, cookie=cookie, output='extended')

            subtitle = content['Content-Disposition']
            subtitle = re.findall('"(.+?)"', subtitle)[0]

            subtitle = os.path.join(path, subtitle.decode('utf-8'))

            if not subtitle.endswith('.srt'):
                raise Exception()

            with open(subtitle, 'wb') as subFile:
                subFile.write(result)

            return subtitle

        except:

            pass
Ejemplo n.º 15
0
    def archive(self):

        self.list = cache.get(self.items_list, 24, self.archive_link)

        if self.list is None:
            return

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

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

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

        directory.add(self.list, content='videos')
Ejemplo n.º 16
0
def spoofer(headers=None,
            _agent=True,
            age_str=None,
            referer=False,
            ref_str='',
            url=None):

    if age_str is None:
        from tulip import cache
        age_str = cache.get(randomagent, 12)

    pipe = '|'

    if not headers:
        headers = {}

    if _agent and age_str and not headers:
        headers.update({'User-Agent': age_str})

    if referer and ref_str:
        headers.update({'Referer': ref_str})

    if headers:
        string = pipe + urlencode(headers)
        if url:
            url += string
            return url
        else:
            return string
    else:
        return ''
Ejemplo n.º 17
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)
Ejemplo n.º 18
0
    def episodes(self, url):

        if CACHE_DEBUG:
            self.list = self.epeisodia(url)
        else:
            self.list = cache.get(self.epeisodia, 12, url)

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

        for item in self.list:

            item.update({'action': 'play', 'isFolder': 'False'})

        for item in self.list:

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

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

            self.list = sorted(
                self.list,
                key=lambda k: k['group']
                if k['group'] in ['1bynumber', '2bydate'] else k['title'],
                reverse=True)[::-1]

        else:

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

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

            try:

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

            except Exception:

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

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

        control.sortmethods()
        # control.sortmethods('title')
        # control.sortmethods('year')

        directory.add(self.list, content='episodes')
Ejemplo n.º 19
0
    def music_list(self, url):

        html = client.request(url)

        try:

            html = html.decode('utf-8')

        except Exception:

            pass

        if 'albumlist' in html:
            artist = [client.parseDOM(html, 'h4')[0].partition(' <a')[0]]
        else:
            artist = None

        if control.setting('audio_only') == 'true' and control.condVisibility('Window.IsVisible(music)') and artist is not None:
            artist = ''.join(artist)

        if 'songlist' in html:
            songlist = client.parseDOM(html, 'div', attrs={'class': 'songlist'})[0]
            items = client.parseDOM(songlist, 'li')
        elif 'albumlist' in html:
            albumlist = client.parseDOM(html, 'div', attrs={'class': 'albumlist'})[0]
            items = client.parseDOM(albumlist, 'li')
        else:
            artistlist = client.parseDOM(html, 'div', attrs={'class': 'artistlist'})[0]
            items = client.parseDOM(artistlist, 'li')

        if 'icon/music' in html:
            icon = client.parseDOM(html, 'img', attrs={'class': 'img-responsive'}, ret='src')[-1]
            icon = urljoin(gm.GM_BASE, icon)
        else:
            icon = iconname('music')

        for item in items:

            title = client.parseDOM(item, 'a')[0]
            link = client.parseDOM(item, 'a', ret='href')[0]
            link = urljoin(gm.GM_BASE, link)

            if 'gapi.client.setApiKey' in html:
                if CACHE_DEBUG:
                    link = gm.source_maker(url)['links'][0]
                else:
                    link = cache.get(gm.source_maker, 48, url)['links'][0]

            data = {'title': title, 'url': link, 'image': icon}

            if artist:

                data.update({'artist': artist})

            self.list.append(data)

        return self.list
Ejemplo n.º 20
0
    def programs(self):
        self.list = cache.get(self.item_list_1, 24, self.programs_link, self.lang)

        if self.list == None: return

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

        directory.add(self.list, content='videos')
        return self.list
Ejemplo n.º 21
0
    def videos(self, url):
        self.list = cache.get(self.item_list_2, 1, url, self.lang)

        if self.list == None: return

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

        directory.add(self.list, content='videos')
        return self.list
Ejemplo n.º 22
0
    def episodes(self, url):

        if self.base_link in url:
            self.list = cache.get(self.episodes_listing, 3, url)
        elif self.radio_base in url:
            self.list = cache.get(self.pod_episodes, 3, url)
        else:
            self.list = cache.get(
                youtube.youtube(key=self.yt_key).playlist, 3, url)

        if self.list is None:

            return

        for i in self.list:

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

        directory.add(self.list, content='videos')
Ejemplo n.º 23
0
def meta_viewer(url):

    heading = control.infoLabel('Listitem.Label')

    if control.setting('debug') == 'false':
        plot = cache.get(_plot, 96, url)
    else:
        plot = _plot(url)

    control.dialog.textviewer(heading=heading, text=plot)
Ejemplo n.º 24
0
    def download(self, path, url):

        try:

            cookie = None

            anonymous = (self.user == '' or self.password == '')

            code, result = client.request(url, output='response', error=True)

            if code == '429' and anonymous is True:

                control.dialog.ok(str('xsubs.tv'), str(result), str(''))

                return

            elif anonymous is False:

                cookie = cache.get(self.cookie, 12)

            result, headers, content, cookie = client.request(
                url, cookie=cookie, output='extended')

            subtitle = content['Content-Disposition']
            subtitle = re.findall('"(.+?)"', subtitle)[0]

            try:
                subtitle = subtitle.decode('utf-8')
            except Exception:
                pass

            subtitle = control.join(path, subtitle)

            if not subtitle.endswith('.srt'):
                raise Exception()

            with open(subtitle, 'wb') as subFile:
                subFile.write(result)

            fileparts = os_split(subtitle)[1].split('.')
            result = control.join(
                os_split(subtitle)[0],
                'subtitles.' + fileparts[len(fileparts) - 1])

            rename(subtitle, result)

            return result

        except Exception as e:

            log.log(
                'Xsubstv subtitle download failed for the following reason: ' +
                str(e))

            return
Ejemplo n.º 25
0
    def listing(self, url):

        if control.setting('debug') == 'false':
            self.list = cache.get(self._listing, 6, url)
        else:
            self.list = self._listing(url)

        if self.list is None:
            return

        for i in self.list:

            if 'paidikes-tainies' in i['url'] or 'archeio' in i['url']:
                i.update({'action': 'play', 'isFolder': 'False'})
            elif i.get('playable') == 'false':
                i.update({'action': 'listing'})
            else:
                i.update({'action': 'play', 'isFolder': 'False'})

            try:
                del i['playable']
            except KeyError:
                pass

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

            if 'enimerosi-24' in url or 'meta_url' not in i:
                i.update({'cm': [bookmark_cm]})
            else:
                info_cm = {'title': 30043, 'query': {'action': 'info', 'url': i['meta_url']}}
                i.update({'cm': [bookmark_cm, info_cm]})

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

            for i in self.list:

                i.update({'nextaction': 'listing', 'nextlabel': 30500, 'nexticon': control.addonmedia('next.jpg')})

        if 'tainies' in url or 'seires' in url or 'docs' in url or 'pedika' in url:

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

        if 'tainies' in url:
            content = 'movies'
        elif 'category' in url or 'arxeio' in url and not 'enimerosi-24' in url:
            content = 'tvshows'
        else:
            content = 'videos'

        directory.add(self.list, content=content)
Ejemplo n.º 26
0
    def videos(self, url):

        self.list = cache.get(self.video_listing, 3, url)

        if self.list is None:
            return

        for i in self.list:

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

        directory.add(self.list)
Ejemplo n.º 27
0
    def miscellany(self):

        if control.setting('debug') == 'true':
            self.data = cache.get(self.misc_list,
                                  int(control.setting('cache_period')))
        else:
            self.data = cache.get(self.misc_list, 24)

        if self.data is None:
            log_debug('Misc channels list did not load successfully')
            return

        self.list = []

        for item in self.data:

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

            li.setArt({
                'icon': item['icon'],
                'fanart': control.addonInfo('fanart')
            })
            url = item['url']
            isFolder = True
            self.list.append((url, li, isFolder))

        control.addItems(self.syshandle, self.list)
        control.directory(self.syshandle)
Ejemplo n.º 28
0
def wrapper(url):

    if url.endswith('/live'):

        if CACHE_DEBUG:
            url = generic(url)
        else:
            url = cache.get(generic, 6, url)

        if not url:

            return

    streams = youtube_resolver.resolve(url)

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

    if not addon_enabled:

        streams = [s for s in streams if 'dash' not in s['title'].lower()]

    if control.condVisibility('Window.IsVisible(music)') and control.setting('audio_only') == 'true':

        audio_choices = [u for u in streams if 'dash/audio' in u and 'dash/video' not in u]

        if control.setting('yt_quality_picker') == '0':
            resolved = audio_choices[0]['url']
        else:
            qualities = [i['title'] for i in audio_choices]
            urls = [i['url'] for i in audio_choices]

            resolved = stream_picker(qualities, urls)

        return resolved

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

        qualities = [i['title'] for i in streams]
        urls = [i['url'] for i in streams]

        resolved = stream_picker(qualities, urls)

        return resolved

    else:

        resolved = streams[0]['url']

        return resolved
Ejemplo n.º 29
0
def kineskop(url):

    """Deprecated method"""

    html = client.request(url)

    stream = re.search(r"getURLParam\('src','(.+?)'", html).group(1)

    headers = {'User-Agent': cache.get(randomagent, 12), 'Origin': 'http://kineskop.tv', 'Referer': url}

    output = stream + spoofer(headers=headers)

    return output
Ejemplo n.º 30
0
    def episodes(self, url, reverse=False):
        self.list = cache.get(self.items_list, 1, url)

        if self.list is None:
            return

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

        if reverse is True:
            self.list = self.list[::-1]

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