예제 #1
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)
예제 #2
0
    def pairHandler(self):
        selection = self.pairMenu.getListItem(self.pairMenu.getSelectedPosition()).getLabel()
        self.close()

        pair_item = re.sub('\[.*?]', '', selection).replace('Pair for ', '').replace(' ', '_').lower()
        for item in PAIR_LIST:
            if str(item[0]) == pair_item:
                site = item[1]
                site_name = item[0].replace('_', ' ').capitalize()
                break

        if self.open_browser:
            check_os = platform()
            if check_os == 'android':
                xbmc.executebuiltin('StartAndroidActivity(,android.intent.action.VIEW,,%s)' % (site))
            elif check_os == 'osx':
                os.system("open " + site)
            else:
                webbrowser.open(site)
        else:
            try:
                from resources.lib.dialogs import ok
                ok.load('%s Stream Authorization' % (site_name), 'Using a device on your network, visit the link below to   authorize streams:', site)
            except Exception:
                failure = traceback.format_exc()
                log_utils.log('Pairing - Exception: \n' + str(failure))
                return
예제 #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)
예제 #4
0
 def rem_channel(self, dbase):
     temp = dbase.decode('base64').split('|')
     chan_id = temp[1]
     action = temp[2]
     try:
         del self.bookmarks['Channels'][action][chan_id]
         self.save()
         control.refresh()
     except Exception:
         from resources.lib.dialogs import ok
         ok.load('Bookmarks Error', '[B]Error removing channel.[/B]')
         failure = traceback.format_exc()
         log_utils.log('Remove Channel Bookmark - Exception: \n' + str(failure))
         return
예제 #5
0
    def tvtapPlay(self, chan_id):
        headers = {"app-token": "37a6259cc0c1dae299a7866489dff0bd"}
        data = {"payload": payload(), "channel_id": chan_id, "username": "******"}
        try:
            response = client.request(self.token_url, post=data, headers=headers)
            if 'could not connect' in str(response).lower() or 'some error occurred' in str(response).lower():
                from resources.lib.dialogs import ok
                ok.load('Connection Error', '[B]Issue connecting to server. Try again later.[/B]')
            else:
                response = json.loads(response)
                if response["success"] == 1:
                    links = []
                    for stream in response["msg"]["channel"][0].keys():
                        if "stream" in stream or "chrome_cast" in stream:
                            _crypt_link = response["msg"]["channel"][0][stream]
                        if _crypt_link:
                            d = pydes.des(b"98221122")
                            # d = DES.new(b"98221122", DES.MODE_ECB)
                            link = d.decrypt(b64decode(_crypt_link))
                            link = unpad(link, 8).decode("utf-8")
                            # link = unpad(d.decrypt(b64decode(_crypt_link)), 8).decode("utf-8")
                            if not link == "dummytext" and link not in links:
                                links.append(link)

                    lazy_mode = control.setting('tv.tvtap.lazymode')
                    if lazy_mode == '' or lazy_mode == 'true':
                        link = links[0]
                    else:
                        dialog = xbmcgui.Dialog()
                        ret = dialog.select("Choose Stream", links)
                        link = links[ret]

                    if link.startswith("http"):
                        media_url = "%s|User-Agent=%s" % (link, quote(self.Player_User_Agent))
                    else:
                        media_url = link

                    title = response["msg"]["channel"][0]['channel_name']
                    image = response["msg"]["channel"][0]['img']

                    li = control.item(title, path=media_url)
                    li.setArt({"thumb": image, "icon": image})
                    li.setInfo(type="video", infoLabels={"Title": title})

                    if "playlist.m3u8" in media_url:
                        inputstream = control.setting('tv.tvtap.inputstream')
                        if inputstream == '' or inputstream == 'true':
                            li.setMimeType("application/vnd.apple.mpegurl")
                            li.setProperty("inputstreamaddon", "inputstream.adaptive")
                            li.setProperty("inputstream.adaptive.manifest_type", "hls")
                            li.setProperty("inputstream.adaptive.stream_headers", media_url.split("|")[-1])
                            li.setProperty('IsPlayable', 'true')
                        else:
                            li.setMimeType("application/vnd.apple.mpegurl")
                            li.setProperty('IsPlayable', 'true')
                    else:
                        li.setProperty('IsPlayable', 'true')

                    try:
                        li.setContentLookup(False)
                    except AttributeError:
                        pass
                    xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=True, listitem=li)
                else:
                    self.addDirectoryItem('[B]System down for maintenance[/B]', 'sectionItem', 'tools.png', 'DefaultTvShows.png')
                    self.endDirectory()
                    return
        except Exception:
            from resources.lib.dialogs import ok
            ok.load('Connection Error', '[B]Error finding streams. Try again later.[/B]')
            failure = traceback.format_exc()
            log_utils.log('TV Tap - Exception: \n' + str(failure))
            return
예제 #6
0
    def swiftPlay(self, url):
        url = url.decode('base64')
        tmp = url.split('|', 2)
        title = tmp[0]
        url = tmp[1]
        token = tmp[2]

        data = {"data": get_post_data()}
        token_url = 'http://swiftstreamz.com/newapptoken%s.php' % (token)
        get_token = requests.post(token_url,
                                  headers={"User-Agent": self.User_Agent},
                                  data=data,
                                  timeout=10)
        auth_token = get_token.text.partition('=')[2]

        auth_token = "".join([
            auth_token[:-59],
            auth_token[-58:-47],
            auth_token[-46:-35],
            auth_token[-34:-23],
            auth_token[-22:-11],
            auth_token[-10:],
        ])
        try:
            url = url + '?wmsAuthSign=' + auth_token + '|User-Agent=%s' % (
                self.Play_User_Agent)

            item = control.item(title, path=url)
            item.setArt({"thumb": addonIcon, "icon": addonIcon})
            item.setInfo(type="video", infoLabels={"Title": title})
            item.setProperty('IsPlayable', 'true')

            if 'playlist.m3u8' in url or '.2ts' in url:
                inputstream = control.setting('tv.swift.inputstream')
                if inputstream == '' or inputstream == 'true':
                    item.setMimeType("application/vnd.apple.mpegurl")
                    item.setProperty("inputstreamaddon",
                                     "inputstream.adaptive")
                    item.setProperty("inputstream.adaptive.manifest_type",
                                     "hls")
                    item.setProperty("inputstream.adaptive.stream_headers",
                                     url.split("|")[-1])
                else:
                    item.setMimeType("application/vnd.apple.mpegurl")
            else:
                item.setMimeType("video/x-mpegts")

            try:
                item.setContentLookup(False)
            except AttributeError:
                pass
            xbmcplugin.setResolvedUrl(handle=syshandle,
                                      succeeded=True,
                                      listitem=item)
        except Exception:
            from resources.lib.dialogs import ok
            ok.load('Connection Error',
                    '[B]Error finding streams. Try again later.[/B]')
            failure = traceback.format_exc()
            log_utils.log('Swift Streamz - Exception: \n' + str(failure))
            return