示例#1
0
    def addPlayableItem(self, name, title, year, imdb, tvdb, season, episode, show, show_alt, date, genre, meta):
        try:
            if tvdb == None: tvdb = '0'

            if show == None: content = 'movie'
            else: content = 'episode'

            self.sources = self.getSources(name, title, year, imdb, tvdb, season, episode, show, show_alt, date, genre)
            if self.sources == []: raise Exception()
            self.sources = self.sourcesFilter()

            meta = json.loads(meta)

            try: poster, banner, thumb, fanart = meta['poster'], meta['banner'], meta['thumb'], meta['fanart']
            except: poster, banner, thumb, fanart = meta['poster'], meta['poster'], meta['poster'], meta['fanart']

            if control.setting('fanart') == 'true' and not fanart == '0': pass
            else: fanart = control.addonFanart()

            sysaddon = sys.argv[0]

            for i in self.sources:
                try:
                    url, source, provider = i['url'], i['label'], i['provider']

                    sysname, sysimdb, systvdb, sysurl, syssource, sysprovider = urllib.quote_plus(name), urllib.quote_plus(imdb), urllib.quote_plus(tvdb), urllib.quote_plus(url), urllib.quote_plus(source), urllib.quote_plus(provider)

                    query = 'action=playItem&content=%s&name=%s&imdb=%s&tvdb=%s&url=%s&source=%s&provider=%s' % (content, sysname, sysimdb, systvdb, sysurl, syssource, sysprovider)

                    cm = []
                    cm.append((control.lang(30401).encode('utf-8'), 'RunPlugin(%s?action=item_queue)' % (sysaddon)))
                    cm.append((control.lang(30402).encode('utf-8'), 'RunPlugin(%s?action=download&name=%s&url=%s&provider=%s)' % (sysaddon, sysname, sysurl, sysprovider)))
                    cm.append((control.lang(30412).encode('utf-8'), 'Action(Info)'))
                    cm.append((control.lang(30427).encode('utf-8'), 'RunPlugin(%s?action=container_refresh)' % (sysaddon)))
                    cm.append((control.lang(30410).encode('utf-8'), 'RunPlugin(%s?action=settings_open)' % (sysaddon)))
                    cm.append((control.lang(30411).encode('utf-8'), 'RunPlugin(%s?action=playlist_open)' % (sysaddon)))

                    item = control.item(source, iconImage='DefaultVideo.png', thumbnailImage=thumb)
                    try: item.setArt({'poster': poster, 'tvshow.poster': poster, 'season.poster': poster, 'banner': banner, 'tvshow.banner': banner, 'season.banner': banner})
                    except: pass
                    item.setInfo(type='Video', infoLabels = meta)
                    if not fanart == None: item.setProperty('Fanart_Image', fanart)
                    item.setProperty('Video', 'true')
                    item.setProperty('IsPlayable', 'true')
                    item.addContextMenuItems(cm, replaceItems=True)
                    control.addItem(handle=int(sys.argv[1]),url='%s?%s' % (sysaddon, query),listitem=item,isFolder=False)
                except:
                    pass

            control.directory(int(sys.argv[1]), cacheToDisc=True)
        except:
            control.infoDialog(control.lang(30308).encode('utf-8'))
            pass
示例#2
0
    def play(self, name, title, year, imdb, tvdb, season, episode, show, show_alt, date, genre, url):
        try:
            if show == None:
                content = "movie"
            else:
                content = "episode"

            self.sources = self.getSources(name, title, year, imdb, tvdb, season, episode, show, show_alt, date, genre)
            if self.sources == []:
                raise Exception()
            self.sources = self.sourcesFilter()

            if control.window.getProperty("PseudoTVRunning") == "True":
                url = self.sourcesDirect()

            elif url == "dialog://":
                url = self.sourcesDialog()

            elif url == "direct://":
                url = self.sourcesDirect()

            elif (
                not control.infoLabel("Container.FolderPath").startswith("plugin://")
                and control.setting("autoplay_library") == "false"
            ):
                url = self.sourcesDialog()

            elif (
                control.infoLabel("Container.FolderPath").startswith("plugin://")
                and control.setting("autoplay") == "false"
            ):
                url = self.sourcesDialog()

            else:
                url = self.sourcesDirect()

            if url == None:
                raise Exception()
            if url == "close://":
                return

            if control.setting("playback_info") == "true":
                control.infoDialog(self.selectedSource, heading=name)

            from modules.libraries.player import player

            player().run(content, name, url, imdb, tvdb)

            return url
        except:
            control.infoDialog(control.lang(30308).encode("utf-8"))
            pass
示例#3
0
    def playItem(self, content, name, imdb, tvdb, url, source, provider):
        try:
            url = self.sourcesResolve(url, provider)
            if url == None: raise Exception()

            if control.setting('playback_info') == 'true':
                control.infoDialog(source, heading=name)

            from modules.libraries.player import player
            player().run(content, name, url, imdb, tvdb)

            return url
        except:
            control.infoDialog(control.lang(30308).encode('utf-8'))
            pass
示例#4
0
    def clearSources(self):
        try:
            yes = control.yesnoDialog('Are you sure?', '', '')
            if not yes: return

            control.makeFile(control.dataPath)
            dbcon = database.connect(control.cachesourcesFile)
            dbcur = dbcon.cursor()
            dbcur.execute("DROP TABLE IF EXISTS rel_src")
            dbcur.execute("VACUUM")
            dbcon.commit()

            control.infoDialog('Process Complete')
        except:
            pass
示例#5
0
    def clearSources(self):
        try:
            yes = control.yesnoDialog("Are you sure?", "", "")
            if not yes:
                return

            control.makeFile(control.dataPath)
            dbcon = database.connect(control.cachesourcesFile)
            dbcur = dbcon.cursor()
            dbcur.execute("DROP TABLE IF EXISTS rel_src")
            dbcur.execute("VACUUM")
            dbcon.commit()

            control.infoDialog("Process Complete")
        except:
            pass
示例#6
0
    def play(self, name, title, year, imdb, tvdb, season, episode, show, show_alt, date, genre, url):
        try:
            if show == None: content = 'movie'
            else: content = 'episode'

            self.sources = self.getSources(name, title, year, imdb, tvdb, season, episode, show, show_alt, date, genre)
            if self.sources == []: raise Exception()
            self.sources = self.sourcesFilter()


            if control.window.getProperty('PseudoTVRunning') == 'True':
                url = self.sourcesDirect()

            elif url == 'dialog://':
                url = self.sourcesDialog()

            elif url == 'direct://':
                url = self.sourcesDirect()

            elif not control.infoLabel('Container.FolderPath').startswith('plugin://') and control.setting('autoplay_library') == 'false':
                url = self.sourcesDialog()

            elif control.infoLabel('Container.FolderPath').startswith('plugin://') and control.setting('autoplay') == 'false':
                url = self.sourcesDialog()

            else:
                url = self.sourcesDirect()

            if url == None: raise Exception()
            if url == 'close://': return

            if control.setting('playback_info') == 'true':
                control.infoDialog(self.selectedSource, heading=name)

            from modules.libraries.player import player
            player().run(content, name, url, imdb, tvdb)

            return url
        except:
            control.infoDialog(control.lang(30308).encode('utf-8'))
            pass
示例#7
0
def resolveUrl(name, url, audio, image, fanart, playable, content):
    try:
        if '.f4m' in url:
            label = cleantitle(name)
            ext = url.split('?')[0].split('&')[0].split('|')[0].rsplit(
                '.')[-1].replace('/', '').lower()
            if not ext == 'f4m': raise Exception()
            from modules.libraries.f4mproxy.F4mProxy import f4mProxyHelper
            return f4mProxyHelper().playF4mLink(url, label, None, None, '',
                                                image)

        #legacy issue, will be removed later
        if 'afdah.org' in url and not '</source>' in url:
            url += '<source>afdah</source>'

        if '</source>' in url:
            source = re.compile('<source>(.+?)</source>').findall(url)[0]
            url = re.compile('(.+?)<source>').findall(url)[0]

            for i in ['_mv', '_tv', '_mv_tv']:
                try:
                    call = __import__('modules.sources.%s%s' % (source, i),
                                      globals(), locals(), ['object'],
                                      -1).source()
                except:
                    pass

            from modules import sources
            d = sources.sources()

            url = call.get_sources(url, d.hosthdfullDict, d.hostsdfullDict,
                                   d.hostlocDict)

            if type(url) == list and len(url) == 1:
                url = url[0]['url']

            elif type(url) == list:
                url = sorted(url, key=lambda k: k['quality'])
                for i in url:
                    i.update(
                        (k, '720p') for k, v in i.iteritems() if v == 'HD')
                for i in url:
                    i.update(
                        (k, '480p') for k, v in i.iteritems() if v == 'SD')
                q = [i['quality'].upper() for i in url]
                u = [i['url'] for i in url]
                select = control.selectDialog(q)
                if select == -1: return
                url = u[select]

            url = call.resolve(url)

        from modules import resolvers
        url = resolvers.request(url)

        if type(url) == list and len(url) == 1:
            url = url[0]['url']

        elif type(url) == list:
            url = sorted(url, key=lambda k: k['quality'])
            for i in url:
                i.update((k, '720p') for k, v in i.iteritems() if v == 'HD')
            for i in url:
                i.update((k, '480p') for k, v in i.iteritems() if v == 'SD')
            q = [i['quality'].upper() for i in url]
            u = [i['url'] for i in url]
            select = control.selectDialog(q)
            if select == -1: return
            url = u[select]

        if url == None: raise Exception()
    except:
        return control.infoDialog('Unplayable stream')
        pass

    if playable == 'true':
        item = control.item(path=url)
        return control.resolve(int(sys.argv[1]), True, item)
    else:
        label = cleantitle(name)
        item = control.item(path=url, iconImage=image, thumbnailImage=image)
        item.setInfo(type='Video', infoLabels={'title': label})
        control.playlist.clear()
        control.player.play(url, item)
示例#8
0
    def addPlayableItem(self, name, title, year, imdb, tvdb, season, episode, show, show_alt, date, genre, meta):
        try:
            if tvdb == None:
                tvdb = "0"

            if show == None:
                content = "movie"
            else:
                content = "episode"

            self.sources = self.getSources(name, title, year, imdb, tvdb, season, episode, show, show_alt, date, genre)
            if self.sources == []:
                raise Exception()
            self.sources = self.sourcesFilter()

            meta = json.loads(meta)

            try:
                poster, banner, thumb, fanart = meta["poster"], meta["banner"], meta["thumb"], meta["fanart"]
            except:
                poster, banner, thumb, fanart = meta["poster"], meta["poster"], meta["poster"], meta["fanart"]

            if control.setting("fanart") == "true" and not fanart == "0":
                pass
            else:
                fanart = control.addonFanart()

            sysaddon = sys.argv[0]

            for i in self.sources:
                try:
                    url, source, provider = i["url"], i["label"], i["provider"]

                    sysname, sysimdb, systvdb, sysurl, sysimage, syssource, sysprovider = (
                        urllib.quote_plus(name),
                        urllib.quote_plus(imdb),
                        urllib.quote_plus(tvdb),
                        urllib.quote_plus(url),
                        urllib.quote_plus(poster),
                        urllib.quote_plus(source),
                        urllib.quote_plus(provider),
                    )

                    query = "action=playItem&content=%s&name=%s&imdb=%s&tvdb=%s&url=%s&source=%s&provider=%s" % (
                        content,
                        sysname,
                        sysimdb,
                        systvdb,
                        sysurl,
                        syssource,
                        sysprovider,
                    )

                    cm = []
                    cm.append((control.lang(30401).encode("utf-8"), "RunPlugin(%s?action=queueItem)" % (sysaddon)))
                    cm.append(
                        (
                            control.lang(30402).encode("utf-8"),
                            "RunPlugin(%s?action=addDownload&name=%s&url=%s&image=%s&provider=%s)"
                            % (sysaddon, sysname, sysurl, sysimage, sysprovider),
                        )
                    )
                    cm.append((control.lang(30412).encode("utf-8"), "Action(Info)"))
                    cm.append((control.lang(30427).encode("utf-8"), "RunPlugin(%s?action=refresh)" % (sysaddon)))
                    cm.append((control.lang(30410).encode("utf-8"), "RunPlugin(%s?action=openSettings)" % (sysaddon)))
                    cm.append((control.lang(30411).encode("utf-8"), "RunPlugin(%s?action=openPlaylist)" % (sysaddon)))

                    item = control.item(source, iconImage="DefaultVideo.png", thumbnailImage=thumb)
                    try:
                        item.setArt(
                            {
                                "poster": poster,
                                "tvshow.poster": poster,
                                "season.poster": poster,
                                "banner": banner,
                                "tvshow.banner": banner,
                                "season.banner": banner,
                            }
                        )
                    except:
                        pass
                    item.setInfo(type="Video", infoLabels=meta)
                    if not fanart == None:
                        item.setProperty("Fanart_Image", fanart)
                    item.setProperty("Video", "true")
                    item.setProperty("IsPlayable", "true")
                    item.addContextMenuItems(cm, replaceItems=True)
                    control.addItem(
                        handle=int(sys.argv[1]), url="%s?%s" % (sysaddon, query), listitem=item, isFolder=False
                    )
                except:
                    pass

            control.directory(int(sys.argv[1]), cacheToDisc=True)
        except:
            control.infoDialog(control.lang(30308).encode("utf-8"))
            pass
示例#9
0
def nhlStreams(name, url):
    try:
        name = re.sub('\s\[COLOR.+?\].+?\[/COLOR\]', '', name).strip()
        n1 = name + ' [COLOR gold]%s[/COLOR]' ; n2 = name + ' [COLOR red]%s[/COLOR]'

        selectHomeGame = 'x0xe%sx0xehome' % str(url)
        selectAwayGame = 'x0xe%sx0xeaway' % str(url)

        url = re.compile('(\d{4})(\d{2})(\d{4})').findall(url)[0]
        url = 'http://smb.cdnak.neulion.com/fs/nhl/mobile/feed_new/data/streams/%s/ipad/%s_%s.json' % (url[0], url[1], url[2])

        result = client.request(url)
        result = json.loads(result)

        items = result['gameStreams']['ipad']
        h = items['home'] ; a = items['away']
    except:
        pass

    l1 = []; l2 = []

    try: finish = result['finish']
    except: finish = 'true'

    try: image = re.compile('"image" *: *"(.+?)"').findall(json.dumps(h))[-1]
    except: image = '0'

    try: l1.append({'name': n1 % 'Home LIVE', 'url': h['live']['bitrate0'] + selectHomeGame, 'image': image})
    except: pass

    try: l2.append({'name': n2 % 'Home Whole', 'url': h['vod-whole']['bitrate0'], 'image': image})
    except: pass

    try: l2.append({'name': n2 % 'Home Continuous', 'url': h['vod-continuous']['bitrate0'], 'image': image})
    except: pass

    try: l2.append({'name': n2 % 'Home Condensed', 'url': h['vod-condensed']['bitrate0'], 'image': image})
    except: pass

    try: image = re.compile('"image" *: *"(.+?)"').findall(json.dumps(a))[-1]
    except: image = '0'

    try: l1.append({'name': n1 % 'Away LIVE', 'url': a['live']['bitrate0'] + selectAwayGame, 'image': image})
    except: pass

    try: l2.append({'name': n2 % 'Away Whole', 'url': a['vod-whole']['bitrate0'], 'image': image})
    except: pass

    try: l2.append({'name': n2 % 'Away Continuous', 'url': a['vod-continuous']['bitrate0'], 'image': image})
    except: pass

    try: l2.append({'name': n2 % 'Away Condensed', 'url': a['vod-condensed']['bitrate0'], 'image': image})
    except: pass

    if finish == 'false':
        for i in l1: addDirectoryItem(i['name'], i['url'], 'nhlResolve', i['image'], '0', isFolder=False)
    else:
        for i in l2: addDirectoryItem(i['name'], i['url'], 'nhlResolve', i['image'], '0', isFolder=False)

    if l1 == [] and l2 == []:
        return control.infoDialog('[COLOR red]Feed not available yet[/COLOR]', name, addonIcon)

    endDirectory()
示例#10
0
def resolveUrl(name, url, audio, image, fanart, playable, content):
    try:
        if '.f4m'in url:
            label = cleantitle(name)
            ext = url.split('?')[0].split('&')[0].split('|')[0].rsplit('.')[-1].replace('/', '').lower()
            if not ext == 'f4m': raise Exception()
            from modules.libraries.f4mproxy.F4mProxy import f4mProxyHelper
            return f4mProxyHelper().playF4mLink(url, label, None, None,'',image)


        #legacy issue, will be removed later
        if 'afdah.org' in url and not '</source>' in url: url += '<source>afdah</source>'

        if '</source>' in url:
            source = re.compile('<source>(.+?)</source>').findall(url)[0]
            url = re.compile('(.+?)<source>').findall(url)[0]

            for i in ['_mv', '_tv', '_mv_tv']:
                try: call = __import__('modules.sources.%s%s' % (source, i), globals(), locals(), ['object'], -1).source()
                except: pass

            from modules import sources ; d = sources.sources()

            url = call.get_sources(url, d.hosthdfullDict, d.hostsdfullDict, d.hostlocDict)

            if type(url) == list and len(url) == 1:
                url = url[0]['url']

            elif type(url) == list:
                url = sorted(url, key=lambda k: k['quality'])
                for i in url: i.update((k, '720p') for k, v in i.iteritems() if v == 'HD')
                for i in url: i.update((k, '480p') for k, v in i.iteritems() if v == 'SD')
                q = [i['quality'].upper() for i in url]
                u = [i['url'] for i in url]
                select = control.selectDialog(q)
                if select == -1: return
                url = u[select]

            url = call.resolve(url)


        from modules import resolvers
        url = resolvers.request(url)

        if type(url) == list and len(url) == 1:
            url = url[0]['url']

        elif type(url) == list:
            url = sorted(url, key=lambda k: k['quality'])
            for i in url: i.update((k, '720p') for k, v in i.iteritems() if v == 'HD')
            for i in url: i.update((k, '480p') for k, v in i.iteritems() if v == 'SD')
            q = [i['quality'].upper() for i in url]
            u = [i['url'] for i in url]
            select = control.selectDialog(q)
            if select == -1: return
            url = u[select]

        if url == None: raise Exception()
    except:
        return control.infoDialog('Unplayable stream')
        pass


    if playable == 'true':
        item = control.item(path=url)
        return control.resolve(int(sys.argv[1]), True, item)
    else:
        label = cleantitle(name)
        item = control.item(path=url, iconImage=image, thumbnailImage=image)
        item.setInfo( type='Video', infoLabels = {'title': label} )
        control.playlist.clear()
        control.player.play(url, item)