Exemplo n.º 1
0
 def get(self, url=None):
     if url is None:
         self.root()
     else:
         self.items = self.docu_list(url)
         control.addItems(syshandle, self.items)
         self.endDirectory('videos', category='Documentary Heaven')
Exemplo n.º 2
0
    def show_podcasts(self):
        items = []
        for action in self.bookmarks['Podcasts'].keys():
            for entry in self.bookmarks['Podcasts'][action].keys():
                try:
                    show = self.bookmarks['Podcasts'][action][entry]
                    item = control.item(label=show['name'])
                    item.setProperty("IsPlayable", "false")
                    item.setArt({"thumb": show['icon'], "icon": show['icon']})
                    url = '%s?action=%s&podcastshow=%s' % (
                        sys.argv[0], show['action'], show['url'])

                    cm = self.build_cm('Podcasts',
                                       name=show['name'],
                                       id=show['id'],
                                       action=show['action'],
                                       icon=show['icon'],
                                       url=show['url'])
                    item.addContextMenuItems(cm)

                    try:
                        item.setContentLookup(False)
                    except AttributeError:
                        pass
                    items.append((url, item, True))
                except Exception:
                    from resources.lib.dialogs import ok
                    ok.load('Bookmarks Error',
                            '[B]Error loading bookmarks.[/B]')
                    failure = traceback.format_exc()
                    log_utils.log('Show Podcast Bookmarks - Exception: \n' +
                                  str(failure))
                    return
        control.addItems(int(sys.argv[1]), items)
        self.endDirectory('files', xbmcplugin.SORT_METHOD_LABEL)
Exemplo n.º 3
0
    def show_channels(self):
        items = []
        for action in self.bookmarks['Channels'].keys():
            for entry in self.bookmarks['Channels'][action].keys():
                try:
                    channel = self.bookmarks['Channels'][action][entry]
                    item = control.item(label=channel['name'])
                    item.setProperty("IsPlayable", "true")
                    item.setArt({"thumb": channel['icon'], "icon": channel['icon']})
                    item.setInfo(type="video", infoLabels={"Title": channel['name'], "mediatype": "video"})
                    url = '%s?action=%s&url=%s' % (sys.argv[0], channel['action'], channel['url'])

                    cm = self.build_cm('Channels', name=channel['name'], id=channel['id'], action=channel['action'], icon=channel['icon'], url=channel['url'])
                    item.addContextMenuItems(cm)

                    try:
                        item.setContentLookup(False)
                    except AttributeError:
                        pass
                    items.append((url, item, False))
                except Exception:
                    from resources.lib.dialogs import ok
                    ok.load('Bookmarks Error', '[B]Error loading bookmarks.[/B]')
                    failure = traceback.format_exc()
                    log_utils.log('Show Channel Bookmarks - Exception: \n' + str(failure))
                    return
        control.addItems(int(sys.argv[1]), items)
        self.endDirectory('files', xbmcplugin.SORT_METHOD_LABEL)
Exemplo n.º 4
0
    def pco_cat(self, category):
        try:
            items = []
            url = self.pcocats_link % category
            html = client.request(url)

            div_list = re.compile(
                '<div class="podcast-container flex no-wrap" data-program-name="(.+?)">(.+?)</a></div>',
                re.DOTALL).findall(html)
            for show_title, content in div_list:
                show_url = re.compile('href="(.+?)"', re.DOTALL).findall(content)[0]
                show_url = show_url.replace('/', '', 1)
                if 'viewProgram' in show_url:
                    url = self.pcocats_link % show_url
                    html = client.request(url)
                    more_ep_block = re.compile('<div class="col-xs-12">(.+?)</div>', re.DOTALL).findall(html)[0]
                    show_url = re.compile(
                        'href="(.+?)"', re.DOTALL).findall(more_ep_block)[0].replace('/', '').replace('?showAllEpisodes=true', '')
                icon = urlparse.urljoin(self.pco_link, re.compile('<img src="(.+?)"', re.DOTALL).findall(content)[0])
                show_action = 'podcastOne&podcastshow=%s&page=1' % show_url

                item = control.item(label=show_title)
                item.setArt({"thumb": icon, "icon": icon})
                item.setProperty("IsPlayable", "false")
                link = '%s?action=%s' % (sysaddon, show_action)

                '''
                Let's build out this context menu bitches
                '''
                try:
                    cm = jsonbm.jsonBookmarks().build_cm('Podcasts', name=show_title, id=show_url, action='podcastOne', icon=icon, url=show_url+'&page=1')
                    if len(cm) > 0:
                        item.addContextMenuItems(cm)
                except Exception:
                    failure = traceback.format_exc()
                    log_utils.log('PodcastOne - BM Exception: \n' + str(failure))

                items.append((link, item, True))
        except Exception:
            pass

        control.addItems(syshandle, items)
        self.endDirectory()
        return
Exemplo n.º 5
0
    def scrape(self, url):
        url = self.series_link % (url)
        self.showItems = []

        try:
            html = client.request(url, timeout=10)
            results = json.loads(html)
            '''
            Promoted Content left out, cuz that is related, or unrelated content to the show. AKA, Promoted could be a different show
            so we ignore it and go on.
            '''
            # promoted = results['collections']['promoted_content']['content']
            # self.buildShows(promoted, 'Promoted')
            episodes = results['collections']['episodes']['content']
            self.buildShows(episodes, 'Episode')
            clips = results['collections']['clips']['content']
            self.buildShows(clips, 'Clip')
        except Exception:
            pass
        control.addItems(syshandle, self.showItems)
        self.endDirectory('episodes', category=results['object']['title'])
Exemplo n.º 6
0
    def pb_cat(self, category):
        try:
            items = []
            url = self.pbcats_link % category
            html = client.request(url)

            page_list = re.compile('<ul class="thumbnails">(.+?)</ul>', re.DOTALL).findall(html)[0]
            show_list = re.compile('<li class="span3">(.+?)</li>', re.DOTALL).findall(page_list)
            for entry in show_list:
                show_url = re.compile('href="(.+?)"', re.DOTALL).findall(entry)[0]
                icon = re.compile('src="(.+?)"', re.DOTALL).findall(entry)[0]
                show_title = re.compile('<h4>(.+?)</h4>', re.DOTALL).findall(entry)[0].encode('utf-8', 'ignore').decode('utf-8')
                show_action = 'podbay&podcastshow=%s' % show_url
                link = '%s?action=%s' % (sysaddon, show_action)

                item = control.item(label=show_title)
                item.setArt({"thumb": icon, "icon": icon})
                item.setProperty("IsPlayable", "false")

                '''
                Let's build out this context menu bitches
                '''
                try:
                    cm = jsonbm.jsonBookmarks().build_cm('Podcasts', name=show_title, id=show_url, action='podbay', icon=icon, url=show_url)
                    if len(cm) > 0:
                        item.addContextMenuItems(cm)
                except Exception:
                    failure = traceback.format_exc()
                    log_utils.log('Podbay - BM Exception: \n' + str(failure))

                items.append((link, item, True))
        except Exception:
            pass

        control.addItems(syshandle, items)
        self.endDirectory()
        return
Exemplo n.º 7
0
    def scrape(self, url):
        url = urlparse.urljoin(self.base_main_link, url)
        items = []

        try:
            html = client.request(url, timeout=10)
            item_list = client.parseDOM(
                html,
                'div',
                attrs={'class': 'item col-lg-3 col-md-3 col-sm-12 '})
            for content in item_list:
                link = re.compile('href="(.+?)"',
                                  re.DOTALL).findall(content)[0]
                icon, title = re.compile('img src="(.+?)" alt="(.+?)"',
                                         re.DOTALL).findall(content)[0]
                try:
                    link = link.replace(self.base_main_link, '')
                    title = utils.convert(title).encode('utf-8')

                    item = control.item(label=title)
                    item.setArt({"thumb": icon, "icon": icon})

                    if 'videos_categories' in link:
                        # Still navigating categories
                        link = '%s?action=b98RabbitNav&url=%s' % (sysaddon,
                                                                  link)
                        items.append((link, item, True))
                    else:
                        # This is where the goodies are
                        item.setInfo(type="video",
                                     infoLabels={
                                         "Title": title,
                                         "mediatype": "video"
                                     })
                        item.setProperty("IsPlayable", "true")
                        link = '%s?action=b98CarrotLink&url=%s&title=%s&image=%s' % (
                            sysaddon, link, title, icon)
                        items.append((link, item, False))
                except Exception:
                    failure = traceback.format_exc()
                    log_utils.log('B98 - Failed to Build: \n' + str(failure))
                    continue

            # Try doing a next hole, if available
            try:
                navi_link = re.compile(
                    'a class="next page-numbers" href="(.+?)"',
                    re.DOTALL).findall(html)[0]
                navi_link = navi_link.replace(self.base_main_link, '')
                next_url = '%s?action=b98RabbitNav&url=%s' % (sysaddon,
                                                              navi_link)
                item = control.item(label=control.lang(32053).encode('utf-8'))
                item.setArt({
                    "thumb": control.addonNext(),
                    "icon": control.addonNext()
                })
                items.append((next_url, item, True))
            except Exception:
                pass
        except Exception:
            pass
        control.addItems(syshandle, items)
        self.endDirectory(category='B98 Cartoons')
Exemplo n.º 8
0
    def channel_directory(self, items):
        if items is None or len(items) == 0:
            control.idle()
            sys.exit()

        sysaddon = sys.argv[0]

        syshandle = int(sys.argv[1])

        try:
            isOld = False
            control.item().getArt('type')
        except:
            isOld = True

        refreshMenu = control.lang(32072).encode('utf-8')

        list_items = []

        for order, channel in enumerate(items):
            label = channel['name']
            meta = channel
            meta.update({'mediatype': channel['mediatype'] if 'mediatype' in channel else 'tvshow'})  # string - "video", "movie", "tvshow", "season", "episode" or "musicvideo"
            meta.update({'playcount': 0, 'overlay': 6})
            meta.update({'duration': channel['duration']}) if 'duration' in channel else None
            meta.update({'title': channel['title']}) if 'title' in channel else None
            meta.update({'tagline': channel['tagline']}) if 'tagline' in channel else None
            meta.update({'year': channel['year']}) if 'year' in channel else None

            meta.update({'sorttitle': meta['title']})
            meta.update({'title': meta['name']})

            sysmeta = urllib.quote_plus(json.dumps(meta))
            id_globo_videos = channel['id']
            brplayprovider = channel['brplayprovider'] if 'brplayprovider' in channel else None
            isFolder = channel['isFolder'] == 'true' if 'isFolder' in channel else False
            isPlayable = channel['playable'] == 'true' if 'playable' in channel else False

            url = channel['url'] if 'url' in channel else '%s?action=playlive&provider=%s&id_globo_videos=%s&isFolder=%s&meta=%s&t=%s' % (sysaddon, brplayprovider, id_globo_videos, isFolder, sysmeta, self.systime)

            cm = [(refreshMenu, 'RunPlugin(%s?action=refresh)' % sysaddon)]

            if isOld is True:
                cm.append((control.lang2(19033).encode('utf-8'), 'Action(Info)'))

            item = control.item(label=label)

            fanart = channel['fanart']

            art = {'icon': channel['logo'], 'fanart': fanart}

            if 'poster' in channel:
                art.update({'poster': channel['poster']})
            if 'banner' in channel:
                art.update({'banner': channel['banner']})
            if 'clearart' in channel:
                art.update({'clearart': channel['clearart']})
            if 'clearlogo' in channel:
                art.update({'clearlogo': channel['clearlogo']})
            if 'landscape' in channel:
                art.update({'landscape': channel['landscape']})
            if 'thumb' in channel:
                art.update({'thumb': channel['thumb']})

            item.setArt(art)

            if 'logo' in channel and 'logo2' in channel:
                item.setProperty('Logo1', channel['logo'])
                item.setProperty('Logo2', channel['logo2'])
                item.setProperty('Initials1', channel['initials1'])
                item.setProperty('Initials2', channel['initials2'])

            if 'live' in channel:
                item.setProperty('Live', str(channel['live']))

            if 'gamedetails' in channel:
                item.setProperty('GameDetails', channel['gamedetails'])

            item.setProperty('Fanart_Image', fanart)

            if 'hd' not in channel or channel['hd'] == True:
                video_info = {'aspect': 1.78, 'width': 1280, 'height': 720}
            else:
                video_info = {'aspect': 1.78, 'width': 720, 'height': 480}

            item.addStreamInfo('video', video_info)

            item.addContextMenuItems(cm)
            item.setProperty('IsPlayable', 'false' if isFolder or not isPlayable else 'true')
            item.setInfo(type='video', infoLabels=meta)

            item.setContentLookup(False)

            if 'duration' in channel and channel['duration'] is not None:
                duration = float(meta['duration'])
                startdate = util.strptime_workaround(channel['dateadded'], '%Y-%m-%d %H:%M:%S') if 'dateadded' in channel else None
                offset = float(util.get_total_seconds(datetime.datetime.now() - startdate)) if startdate else 0
                item.setProperty('Progress', str((offset / duration) * 100) if duration else str(0))
                item.setProperty('totaltime', str(duration))

            # if not isFolder:
            #     item.setMimeType("application/vnd.apple.mpegurl")

            list_items.append((url, item, isFolder))

        # control.addSortMethod(int(sys.argv[1]), control.SORT_METHOD_VIDEO_SORT_TITLE)
        # control.addSortMethod(int(sys.argv[1]), control.SORT_METHOD_DATEADDED)
        # control.addSortMethod(int(sys.argv[1]), control.SORT_METHOD_LABEL_IGNORE_FOLDERS)

        control.addItems(syshandle, list_items)
        control.category(handle=syshandle, category=control.lang(32001).encode('utf-8'))

        content = 'LiveTV' if control.isJarvis else 'tvshows'

        control.content(syshandle, content)
        control.directory(syshandle, cacheToDisc=False)
Exemplo n.º 9
0
 def scrape4(self, url):
     try:
         headers = {
             'User-Agent':
             'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0',
             'Referer': self.base4_link
         }
         html = client.request(url, headers=headers)
         if '/watch-' in url:
             contents = re.compile(
                 '<p style="text-align: center;">(.+?)</p>',
                 re.DOTALL).findall(html)
             for content in contents:
                 links = re.compile(
                     '<a href="(.+?)" class="small cool-blue vision-button" target="_blank">(.+?)</a>',
                     re.DOTALL).findall(content)
                 for link, info1 in links:
                     if 'pakfashionstore.com' in link:
                         link = self.cleanURL(link)
                         sourcepage = client.request(link, headers=headers)
                         try:
                             try:
                                 link = re.compile(
                                     '<iframe.+?src="(.+?)"',
                                     flags=re.DOTALL
                                     | re.IGNORECASE).findall(sourcepage)[0]
                             except:
                                 link = re.compile(
                                     "<iframe.+?src='(.+?)'",
                                     flags=re.DOTALL
                                     | re.IGNORECASE).findall(sourcepage)[0]
                         except:
                             link = link
                     CustomResolved = self.resolve(link)
                     if CustomResolved:
                         link = CustomResolved
                     Blocked = self.checkURL(link)
                     if Blocked:
                         continue
                     icon = re.compile('<img.+?src="(.+?)"',
                                       re.DOTALL).findall(html)[0]
                     elements = urlparse.urlparse(link)
                     host = elements.netloc
                     title = '[B]%s[/B] - %s' % (host.replace('www.',
                                                              ''), info1)
                     item = control.item(label=title)
                     item.setProperty("IsPlayable", "true")
                     item.setArt({"thumb": icon, "icon": icon})
                     item.setInfo(type="video",
                                  infoLabels={
                                      "title": title,
                                      "mediatype": "video"
                                  })
                     link = '%s?action=wrestlingPlay&url=%s' % (sysaddon,
                                                                link)
                     self.items.append((link, item, False))
         else:
             page = client.parseDOM(
                 html,
                 'div',
                 attrs={'class':
                        'loop-content switchable-view grid-mini'})[0]
             contents = client.parseDOM(page,
                                        'div',
                                        attrs={'class': 'thumb'})
             for content in contents:
                 title, link = re.compile(
                     '<a class="clip-link" .+? title="(.+?)" href="(.+?)">',
                     re.DOTALL).findall(content)[0]
                 icon = re.compile('<img src="(.+?)"',
                                   re.DOTALL).findall(content)[0]
                 item = control.item(label=title)
                 item.setArt({"thumb": icon, "icon": icon})
                 link = '%s?action=wrestlingScrape&url=%s' % (sysaddon,
                                                              link)
                 self.items.append((link, item, True))
         try:
             navi_link = re.compile('<link rel="next" href="(.+?)" />',
                                    re.DOTALL).findall(html)[0]
             next_url = '%s?action=wrestlingScrape&url=%s' % (sysaddon,
                                                              navi_link)
             item = control.item(label=control.lang(32053).encode('utf-8'))
             item.setArt({
                 "thumb": control.addonNext(),
                 "icon": control.addonNext()
             })
             self.items.append((next_url, item, True))
         except:
             pass
         if not self.items:
             self.errorForSources()
             self.addDirectoryItem('No Results Found, Go Back to Menu?',
                                   'wrestlingMenuAWL', self.art4_link,
                                   'DefaultTVShows.png')
     except Exception:
         pass
     control.addItems(syshandle, self.items)
     self.endDirectory()
Exemplo n.º 10
0
    def tvtapCategory(self, id):
        headers = {"app-token": "37a6259cc0c1dae299a7866489dff0bd"}
        data = {"payload": payload(), "username": "******"}
        try:
            items = []
            try:
                response = client.request(self.list_url, post=data, headers=headers)
                if 'could not connect' in str(response).lower() or 'some error occurred' in str(response).lower():
                    self.addDirectoryItem('[B]System down for maintenance[/B]',
                                          'sectionItem', 'tools.png', 'DefaultTvShows.png')
                else:
                    countries = control.setting('tv.tvtap.poached')
                    if countries == '':
                        countries = 'All'
                    response = json.loads(response)
                    if response["success"] == 1:
                        for a in response['msg']['channels']:
                            try:
                                if a['cat_id'] == id:
                                    country = a['country']
                                    if country == countries or countries == 'All':
                                        if countries == 'All':
                                            name = a['channel_name'].rstrip('.,-') + ' (' + str(country) + ')'
                                        else:
                                            name = a['channel_name'].rstrip('.,-')
                                        chan_id = a["pk_id"]
                                        icon = self.icon_url % (a['img'])

                                        item = control.item(label=name)
                                        item.setProperty("IsPlayable", "true")
                                        item.setArt({"thumb": icon, "icon": icon})
                                        item.setInfo(type="video", infoLabels={"Title": name, "mediatype": "video"})

                                        '''
                                        Let's build out this context menu bitches
                                        '''
                                        try:
                                            cm = jsonbm.jsonBookmarks().build_cm('Channels', name=name, id=chan_id, action='tvtapPlay', icon=icon, url=chan_id)
                                            if len(cm) > 0:
                                                item.addContextMenuItems(cm)
                                        except Exception:
                                            failure = traceback.format_exc()
                                            log_utils.log('TV Tap - BM Exception: \n' + str(failure))

                                        try:
                                            item.setContentLookup(False)
                                        except AttributeError:
                                            pass
                                        url = '%s?action=tvtapPlay&url=%s' % (sysaddon, chan_id)
                                        items.append((url, item, False))
                                    else:
                                        continue
                            except Exception:
                                pass
                    else:
                        self.addDirectoryItem('[B]System down for maintenance[/B]', 'sectionItem', 'tools.png', 'DefaultTvShows.png')
                        self.endDirectory()
                        return
                    control.addItems(syshandle, items)
            except Exception:
                self.addDirectoryItem('[B]Issue connecting to server. Try again later.[/B]',
                                      'sectionItem', 'tools.png', 'DefaultTvShows.png')
                self.endDirectory()
                return
        except Exception:
            pass
        self.endDirectory(sortMethod=control.xDirSort.Label, category='TV Tap')
Exemplo n.º 11
0
    def pco_show(self, show, page):
        try:
            url = self.pcocats_link % show
            url = url + '?showAllEpisodes=true'
            html = client.request(url)
            progID = re.compile('categoryID2=(.+?)"', re.DOTALL).findall(html)[0]

            first = None
            items = []
            if page == '1':
                icon_item = client.parseDOM(html, 'div', attrs={'class': 'col-sm-3 col-xs-12 current-episode-img'})[0]
                icon = client.parseDOM(icon_item, 'img', ret='src')[0]

                latest_content = re.compile('<div class="letestEpiDes">(.+?)</div>', re.DOTALL).findall(html)[0]
                ep_title = re.compile('href=".+?" style="color:inherit;">(.+?)</a>', re.DOTALL).findall(latest_content)[0]
                first = ep_title
                ep_page = urlparse.urljoin(self.pco_link, re.compile('href="(.+?)"', re.DOTALL).findall(latest_content)[0])
                episode_action = 'podcastOne&podcastepisode=%s' % ep_page

                item = control.item(label=ep_title)
                item.setArt({"thumb": icon, "icon": icon})
                item.setInfo(type="music", infoLabels={"Title": ep_title, "mediatype": "music"})
                item.setProperty("IsPlayable", "true")
                link = '%s?action=%s' % (sysaddon, episode_action)
                items.append((link, item, False))

            url = self.pco_page_link % (page, progID)
            html = client.request(url)

            episode_list = client.parseDOM(html, 'div', attrs={'class': 'flex space-between align-center no-wrap'})
            for content in episode_list:
                icon = re.compile('src="(.+?)"', re.DOTALL).findall(content)[0]
                ep_title = re.compile('href=".+?" style="color:inherit;">(.+?)</a>', re.DOTALL).findall(content)[0]
                if ep_title == first:
                    continue
                ep_page = urlparse.urljoin(self.pco_link, re.compile('href="(.+?)"', re.DOTALL).findall(content)[0])
                episode_action = 'podcastOne&podcastepisode=%s' % ep_page

                item = control.item(label=ep_title)
                item.setArt({"thumb": icon, "icon": icon})
                item.setInfo(type="music", infoLabels={"Title": ep_title, "mediatype": "music"})
                item.setProperty("IsPlayable", "true")
                link = '%s?action=%s' % (sysaddon, episode_action)
                items.append((link, item, False))
        except Exception:
            failure = traceback.format_exc()
            log_utils.log('PodCastOne Show - Exception: \n' + str(failure))

        try:
            if len(items) > 13:
                next_url = '%s?action=podcastOne&podcastshow=%s&page=%s' % (sysaddon, show, int(page)+1)
                item = control.item(label=control.lang(32053).encode('utf-8'))
                item.setArt({"thumb": control.addonNext(), "icon": control.addonNext()})
                items.append((next_url, item, True))
        except Exception:
            failure = traceback.format_exc()
            log_utils.log('PodCastOne Show - Exception: \n' + str(failure))

        control.addItems(syshandle, items)
        self.endDirectory()
        return
Exemplo n.º 12
0
 def scrape3(self, url):
     try:
         headers = {
             'User-Agent': client.agent(),
             'Referer': self.base3_link
         }
         html = client.request(url, headers=headers)
         if '/category/' in url:
             page = client.parseDOM(
                 html, 'div', attrs={'class': 'main-content-col-body'})[0]
             contents = client.parseDOM(page,
                                        'div',
                                        attrs={'class': 'entry-content'})
             for content in contents:
                 link, title = re.compile(
                     '<a href=(.+?) target=_self title="(.+?)">',
                     re.DOTALL).findall(content)[0]
                 icon = re.compile('<img src=(.+?) alt style>',
                                   re.DOTALL).findall(content)[0]
                 item = control.item(label=title)
                 item.setArt({"thumb": icon, "icon": icon})
                 link = '%s?action=wrestlingScrape&url=%s' % (sysaddon,
                                                              link)
                 self.items.append((link, item, True))
         else:
             contents = re.compile(
                 '<p style="text-align: center;">(.+?)</p>',
                 re.DOTALL).findall(html)
             for content in contents:
                 links = re.compile(
                     '<a class=.+?href="(.+?)" target=_blank.+?>(.+?)</a>',
                     re.DOTALL).findall(content)
                 for link, info1 in links:
                     if 'education-load.com' in link:
                         sourcepage = client.request(link, headers=headers)
                         try:
                             try:
                                 link = re.compile(
                                     '<iframe.+?src="(.+?)"',
                                     flags=re.DOTALL | re.IGNORECASE
                                     | re.MULTILINE).findall(sourcepage)[0]
                             except:
                                 link = re.compile(
                                     "<iframe.+?src='(.+?)'",
                                     flags=re.DOTALL | re.IGNORECASE
                                     | re.MULTILINE).findall(sourcepage)[0]
                         except:
                             link = link
                     CustomResolved = self.resolve(link)
                     if CustomResolved:
                         link = CustomResolved
                     Blocked = self.checkURL(link)
                     if Blocked:
                         continue
                     icon = re.compile('<img.+?src="(.+?)"',
                                       re.DOTALL).findall(html)[0]
                     elements = urlparse.urlparse(link)
                     host = elements.netloc
                     title = '[B]%s[/B] - %s' % (host.replace('www.',
                                                              ''), info1)
                     item = control.item(label=title)
                     item.setProperty("IsPlayable", "true")
                     item.setArt({"thumb": icon, "icon": icon})
                     item.setInfo(type="video",
                                  infoLabels={
                                      "title": title,
                                      "mediatype": "video"
                                  })
                     link = '%s?action=wrestlingPlay&url=%s' % (sysaddon,
                                                                link)
                     self.items.append((link, item, False))
         try:
             navi_link = re.compile('<link rel=next href=(.+?)>',
                                    re.DOTALL).findall(html)[0]
             next_url = '%s?action=wrestlingScrape&url=%s' % (sysaddon,
                                                              navi_link)
             item = control.item(label=control.lang(32053).encode('utf-8'))
             item.setArt({
                 "thumb": control.addonNext(),
                 "icon": control.addonNext()
             })
             self.items.append((next_url, item, True))
         except:
             pass
         if not self.items:
             self.errorForSources()
             self.addDirectoryItem('No Results Found, Go Back to Menu?',
                                   'wrestlingMenu24', self.art3_link,
                                   'DefaultTVShows.png')
     except Exception:
         pass
     control.addItems(syshandle, self.items)
     self.endDirectory()
Exemplo n.º 13
0
    def swiftCategory(self, id):
        url = self.base_cat_url % (id)
        headers = {
            'Authorization': 'Basic @Swift11#:@Swift11#',
            'User-Agent': self.User_Agent
        }
        response = client.request(url, headers=headers)

        items = []
        try:
            if 'Erreur 503' in str(response):
                self.addDirectoryItem('[B]System down for maintenance[/B]',
                                      'sectionItem', 'tools.png',
                                      'DefaultTvShows.png')
            else:
                response = json.loads(response)
                for a in response['LIVETV']:
                    streams = []
                    for entry in a['stream_list']:
                        if '.m3u8' in entry['stream_url'] or '.2ts' in entry[
                                'stream_url']:
                            streams.append(entry)

                    if len(streams) == 0:
                        continue

                    name = a['channel_title']
                    icon = a['channel_thumbnail']

                    # For now, just supporting the first stream, even when multiple available. Cuz I am fat and lazy
                    url = streams[0]['stream_url']
                    token = streams[0]['token']

                    playencode = '%s|%s|%s' % (name, url, token)

                    item = control.item(label=name)
                    item.setProperty("IsPlayable", "true")
                    item.setArt({"thumb": icon, "icon": icon})
                    item.setInfo(type="video",
                                 infoLabels={
                                     "Title": name,
                                     "mediatype": "video"
                                 })
                    '''
                    Let's build out this context menu bitches
                    '''
                    try:
                        cm = jsonbm.jsonBookmarks().build_cm(
                            'Channels',
                            name=name,
                            id=a['id'],
                            action='swiftPlay',
                            icon=icon,
                            url=playencode.encode('base64'))
                        if len(cm) > 0:
                            item.addContextMenuItems(cm)
                    except Exception:
                        failure = traceback.format_exc()
                        log_utils.log('Swift Streamz - BM Exception: \n' +
                                      str(failure))

                    try:
                        item.setContentLookup(False)
                    except AttributeError:
                        pass
                    url = '%s?action=swiftPlay&url=%s' % (
                        sysaddon, playencode.encode('base64'))

                    items.append((url, item, False))
                control.addItems(syshandle, items)
        except Exception:
            pass

        self.endDirectory('files',
                          xbmcplugin.SORT_METHOD_LABEL,
                          category='Swift Streamz TV')