示例#1
0
 def addDirectoryItem(self, name, query, thumb, icon, isAction=True, isFolder=True):
     try: name = control.lang(name).encode('utf-8')
     except: pass
     url = '%s?action=%s' % (sysAddon, query) if isAction == True else query
     thumb = os.path.join(artPath, thumb) if not artPath == None else icon
     item = control.item(name, iconImage=thumb, thumbnailImage=thumb)
     item.addContextMenuItems([], replaceItems=False)
     if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart)
     control.addItem(handle=int(sys.argv[1]),url=url,listitem=item,isFolder=isFolder)
示例#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 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
示例#4
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
示例#5
0
    def sourcesDialog(self):
        try:
            l = '00 | [B]%s[/B]' % control.lang(30408).encode('utf-8').upper()
            sourceList = [l] ; urlList = [''] ; providerList = ['']

            for i in self.sources:
                sourceList.append(i['label']) ; urlList.append(i['url']) ; providerList.append(i['provider'])

            select = control.selectDialog(sourceList)
            if select == 0: return self.sourcesDirect()
            if select == -1: return 'close://'

            url = self.sourcesResolve(urlList[select], providerList[select])
            self.selectedSource = self.sources[select-1]['label']
            return url
        except:
            return
示例#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 addDirectoryItem(self,
                      name,
                      query,
                      thumb,
                      icon,
                      isAction=True,
                      isFolder=True):
     try:
         name = control.lang(name).encode('utf-8')
     except:
         pass
     url = '%s?action=%s' % (sysAddon, query) if isAction == True else query
     thumb = os.path.join(artPath, thumb) if not artPath == None else icon
     item = control.item(name, iconImage=thumb, thumbnailImage=thumb)
     item.addContextMenuItems([], replaceItems=False)
     if not addonFanart == None:
         item.setProperty('Fanart_Image', addonFanart)
     control.addItem(handle=int(sys.argv[1]),
                     url=url,
                     listitem=item,
                     isFolder=isFolder)
示例#8
0
    def sourcesDialog(self):
        try:
            l = "00 | [B]%s[/B]" % control.lang(30408).encode("utf-8").upper()
            sourceList = [l]
            urlList = [""]
            providerList = [""]

            for i in self.sources:
                sourceList.append(i["label"])
                urlList.append(i["url"])
                providerList.append(i["provider"])

            select = control.selectDialog(sourceList)
            if select == 0:
                return self.sourcesDirect()
            if select == -1:
                return "close://"

            url = self.sourcesResolve(urlList[select], providerList[select])
            self.selectedSource = self.sources[select - 1]["label"]
            return url
        except:
            return
示例#9
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