Ejemplo n.º 1
0
def endDirectory(content, close):
    if content in ['movies', 'tvshows', 'seasons', 'episodes']:
        control.content(int(sys.argv[1]), content)

    if close == True: control.directory(int(sys.argv[1]), cacheToDisc=True)

    if close == True and content in ['movies', 'tvshows', 'seasons', 'episodes']:
        views.setView(content)
Ejemplo n.º 2
0
def endDirectory(content, close):
    if content in ['movies', 'tvshows', 'seasons', 'episodes']:
        control.content(int(sys.argv[1]), content)

    if close == True: control.directory(int(sys.argv[1]), cacheToDisc=True)

    if close == True and content in [
            'movies', 'tvshows', 'seasons', 'episodes'
    ]:
        views.setView(content)
Ejemplo n.º 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
Ejemplo n.º 4
0
def getSearch():
    addDirectoryItem('Search...', '0', 'searchDirectory', '0', '0', '0', '0', '0', {})
    addDirectoryItem('Clear History', '0', 'clearSearch', '0', '0', '0', '0', '0', {})

    try:
        def search(): return
        result = cache.get(search, 600000000, table='rel_srch')
        for q in result:
                try: addDirectoryItem('%s...' % q, q, 'searchDirectory2', '0', '0', '0', '0', '0', {})
                except: pass
    except:
        pass

    control.directory(int(sys.argv[1]), cacheToDisc=True)
Ejemplo n.º 5
0
def getSearch():
    addDirectoryItem('Search...', '0', 'searchDirectory', '0', '0', '0', '0',
                     '0', {})
    addDirectoryItem('Clear History', '0', 'clearSearch', '0', '0', '0', '0',
                     '0', {})

    try:

        def search():
            return

        result = cache.get(search, 600000000, table='rel_srch')
        for q in result:
            try:
                addDirectoryItem('%s...' % q, q, 'searchDirectory2', '0', '0',
                                 '0', '0', '0', {})
            except:
                pass
    except:
        pass

    control.directory(int(sys.argv[1]), cacheToDisc=True)
Ejemplo n.º 6
0
 def endDirectory(self, cacheToDisc=True):
     control.directory(int(sys.argv[1]), cacheToDisc=cacheToDisc)
Ejemplo n.º 7
0
def endCategory():
    if control.skin == 'skin.confluence':
        control.execute('Container.SetViewMode(500)')
    control.directory(int(sys.argv[1]), cacheToDisc=True)
Ejemplo n.º 8
0
def searchDirectory(query=None):
    if (query == None or query == ''):
        keyboard = control.keyboard('', 'Search')
        keyboard.doModal()
        if not (keyboard.isConfirmed()): return
        query = keyboard.getText()

    if (query == None or query == ''): return

    def search():
        return [query]

    result = cache.get(search, 600000000, table='rel_srch')

    def search():
        return [
            x for y, x in enumerate((result + [query]))
            if x not in (result + [query])[:y]
        ]

    result = cache.get(search, 0, table='rel_srch')

    global global_search
    global_search = []

    def worker(url):
        global_search.append(str(client.request(url)))

    servers = client.request(phLink)
    servers = str(servers).replace('\n', '')
    servers = re.findall('</name><link>(.+?)</link>', servers)
    servers = [urlparse.urlparse(i).netloc for i in servers]
    servers = [phSearch % i for i in servers if not 'mecca' in i]

    threads = []
    for server in servers:
        threads.append(Thread(worker, server))
    [i.start() for i in threads]
    [i.join() for i in threads]

    urls = global_search
    global_search = []
    urls = [str(i).replace('\n', '') for i in urls]
    urls = [re.findall('<link>(.+?)</link>', i)[:30] for i in urls]
    urls = sum(urls, [])

    threads = []
    for url in urls:
        threads.append(Thread(worker, url))
    [i.start() for i in threads]
    [i.join() for i in threads]

    links = global_search
    global_search = []

    for link in links:
        try:
            link = str(link).replace('\r', '').replace('\n', '').replace(
                '\t', '').replace('&nbsp;', '')

            try:
                fanart = re.findall('<fanart>(.+?)</fanart>', link)[0]
            except:
                fanart = '0'

            try:
                vip = re.findall('<poster>(.+?)</poster>', link)[0]
            except:
                vip = ''

            if vip == 'Team Phoenix': vip = ''

            try:
                content = re.findall('<meta>(.+?)</meta>', link)[0]
            except:
                content = '0'

            try:
                tvshow = re.findall('<tvshow>(.+?)</tvshow>', link)[0]
            except:
                tvshow = '0'

            if content in ['seasons', 'episodes'] and tvshow == '0':
                content = '0'

            dirs = re.compile('<dir>(.+?)</dir>').findall(link)

            for dir in dirs:
                try:
                    data = {}

                    name = re.findall('<name>(.+?)</name>', dir)[0]
                    name = cleantitle(name)

                    if not query.lower() in name.lower(): raise Exception()

                    url = re.findall('<link>(.+?)</link>', dir)[0]

                    try:
                        image = re.findall('<thumbnail>(.+?)</thumbnail>',
                                           dir)[0]
                    except:
                        image = '0'

                    try:
                        fanart2 = re.findall('<fanart>(.+?)</fanart>', dir)[0]
                    except:
                        fanart2 = fanart

                    if content == 'tvshows':
                        try:
                            title = cleantitle(name).encode('utf-8')
                            data = {'title': title, 'tvshowtitle': title}
                        except:
                            pass

                    if re.search('[a-zA-Z]', vip):
                        name += ' [COLOR orange]%s[/COLOR]' % vip

                    addDirectoryItem(name, url, 'ndmode', image, image,
                                     fanart2, '0', content, data)
                except:
                    pass

            items = re.compile('<item>(.+?)</item>').findall(link)

            for item in items:
                try:

                    data = {}

                    name = re.findall('<title>(.+?)</title>', item)[0]
                    name = cleantitle(name)

                    if not query.lower() in name.lower(): raise Exception()

                    url = re.findall('<link>(.+?)</link>', item)[0]

                    try:
                        image = re.findall('<thumbnail>(.+?)</thumbnail>',
                                           item)[0]
                    except:
                        image = '0'

                    try:
                        fanart2 = re.findall('<fanart>(.+?)</fanart>', item)[0]
                    except:
                        fanart2 = fanart

                    if content == 'movies':
                        try:
                            title = cleantitle(name).encode('utf-8')
                            data = {'title': title}

                            title, year = re.compile(
                                '(.+?)[(](\d{4})[)]').findall(name)[0]
                            title = cleantitle(title).encode('utf-8')
                            data = {'title': title, 'year': year}
                        except:
                            pass

                    if re.search('[a-zA-Z]', vip):
                        name += ' [COLOR orange]%s[/COLOR]' % vip

                    if 'sublink' in url:
                        addDirectoryItem(name,
                                         url,
                                         'subDirectory',
                                         image,
                                         image,
                                         fanart2,
                                         '0',
                                         content,
                                         data,
                                         isFolder=True)
                    else:
                        addDirectoryItem(name,
                                         url,
                                         'resolveUrl',
                                         image,
                                         image,
                                         fanart2,
                                         '0',
                                         content,
                                         data,
                                         isFolder=False)
                except:
                    pass
        except:
            pass

    control.directory(int(sys.argv[1]), cacheToDisc=True)
Ejemplo n.º 9
0
def subDirectory(name, url, audio, image, fanart, playable, tvshow, content):
    match = re.compile('<sublink>(.+?)</sublink>').findall(url)
    if len(match) == 0: return

    try:
        title = cleantitle(name).encode('utf-8')
        data = {'title': title}
    except:
        pass

    try:
        if not content == 'movies': raise Exception()

        title = cleantitle(name).encode('utf-8')
        data = {'title': title}

        title, year = re.compile('(.+?)[(](\d{4})[)]').findall(name)[0]
        title = cleantitle(title).encode('utf-8')
        data = {'title': title, 'year': year}

        from metahandler import metahandlers
        metaget = metahandlers.MetaData(preparezip=False)

        #data = metaget.get_meta('movie', title, year=year)
        data = cachemeta.get(metaget.get_meta, 24, 'movie', title, '', '',
                             year)

        metaimage = data['cover_url']
        if not metaimage == '': image = metaimage
        metafanart = data['backdrop_url']
        if not metafanart == '': fanart = metafanart
    except:
        pass

    try:
        if tvshow == '0' and not content == 'episodes': raise Exception()

        try:
            title = cleantitle(name).encode('utf-8')
            data = {'title': title, 'tvshowtitle': tvshow}
        except:
            pass
        try:
            i = cleaneptitle(tvshow, title)
            title, season, episode = i[0].encode('utf-8'), i[1], i[2]
            data = {
                'title': title,
                'tvshowtitle': tvshow,
                'season': season,
                'episode': episode
            }
        except:
            pass

        from metahandler import metahandlers
        metaget = metahandlers.MetaData(preparezip=False)
        tvd = metaget.get_meta('tvshow', tvshow)
        tvd = cachemeta.get(metaget.get_meta, 24, 'tvshow', tvshow, '', '', '')

        data.update({
            'year': tvd['year'],
            'imdb_id': tvd['imdb_id'],
            'tvdb_id': tvd['tvdb_id'],
            'tvshowtitle': tvd['TVShowTitle'],
            'genre': tvd['genre'],
            'studio': tvd['studio'],
            'status': tvd['status'],
            'duration': tvd['duration'],
            'rating': tvd['rating'],
            'mpaa': tvd['mpaa'],
            'plot': tvd['plot'],
            'cast': tvd['cast']
        })

        metafanart = tvd['backdrop_url']
        if not metafanart == '': image = fanart = metafanart
    except:
        pass

    for i in range(0, len(match)):
        url = match[i]
        label = '%s Link %s' % (name, str(i + 1))
        addDirectoryItem(label,
                         url,
                         'resolveUrl',
                         image,
                         image,
                         fanart,
                         '0',
                         content,
                         data,
                         isFolder=False)

    control.directory(int(sys.argv[1]), cacheToDisc=True)
Ejemplo n.º 10
0
 def endDirectory(self, cacheToDisc=True):
     control.directory(int(sys.argv[1]), cacheToDisc=cacheToDisc)
Ejemplo n.º 11
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
Ejemplo n.º 12
0
def endCategory():
    if control.skin == 'skin.confluence': control.execute('Container.SetViewMode(500)')
    control.directory(int(sys.argv[1]), cacheToDisc=True)
Ejemplo n.º 13
0
def searchDirectory(query=None):
    if (query == None or query == ''):
        keyboard = control.keyboard('', 'Search')
        keyboard.doModal()
        if not (keyboard.isConfirmed()): return
        query = keyboard.getText()

    if (query == None or query == ''): return

    def search(): return [query]
    result = cache.get(search, 600000000, table='rel_srch')
    def search(): return [x for y,x in enumerate((result + [query])) if x not in (result + [query])[:y]]
    result = cache.get(search, 0, table='rel_srch')


    global global_search ; global_search = []

    def worker(url): global_search.append(str(client.request(url)))

    servers = client.request(phLink)
    servers = str(servers).replace('\n','')
    servers = re.findall('</name><link>(.+?)</link>', servers)
    servers = [urlparse.urlparse(i).netloc for i in servers]
    servers = [phSearch % i for i in servers if not 'mecca' in i]

    threads = []
    for server in servers: threads.append(Thread(worker, server))
    [i.start() for i in threads]
    [i.join() for i in threads]

    urls = global_search ; global_search = []
    urls = [str(i).replace('\n','') for i in urls]
    urls = [re.findall('<link>(.+?)</link>', i)[:30] for i in urls]
    urls = sum(urls, [])

    threads = []
    for url in urls: threads.append(Thread(worker, url))
    [i.start() for i in threads]
    [i.join() for i in threads]

    links = global_search ; global_search = []

    for link in links:
        try:
            link = str(link).replace('\r','').replace('\n','').replace('\t','').replace('&nbsp;','')

            try: fanart = re.findall('<fanart>(.+?)</fanart>', link)[0]
            except: fanart = '0'

            try: vip = re.findall('<poster>(.+?)</poster>', link)[0]
            except: vip = ''

            if vip == 'Team Phoenix': vip = ''

            try: content = re.findall('<meta>(.+?)</meta>', link)[0]
            except: content = '0'

            try: tvshow = re.findall('<tvshow>(.+?)</tvshow>', link)[0]
            except: tvshow = '0'

            if content in ['seasons', 'episodes'] and tvshow == '0':
                content = '0'


            dirs = re.compile('<dir>(.+?)</dir>').findall(link)

            for dir in dirs:
                try:
                    data = {}

                    name = re.findall('<name>(.+?)</name>', dir)[0]
                    name = cleantitle(name)

                    if not query.lower() in name.lower() : raise Exception()

                    url = re.findall('<link>(.+?)</link>', dir)[0]

                    try: image = re.findall('<thumbnail>(.+?)</thumbnail>', dir)[0]
                    except: image = '0'

                    try: fanart2 = re.findall('<fanart>(.+?)</fanart>', dir)[0]
                    except: fanart2 = fanart

                    if content =='tvshows':
                        try:
                            title = cleantitle(name).encode('utf-8')
                            data = {'title': title, 'tvshowtitle': title}
                        except:
                            pass

                    if re.search('[a-zA-Z]', vip): name += ' [COLOR orange]%s[/COLOR]' % vip

                    addDirectoryItem(name, url, 'ndmode', image, image, fanart2, '0', content, data)
                except:
                    pass


            items = re.compile('<item>(.+?)</item>').findall(link)

            for item in items:
                try:

                    data = {}

                    name = re.findall('<title>(.+?)</title>', item)[0]
                    name = cleantitle(name)

                    if not query.lower() in name.lower() : raise Exception()

                    url = re.findall('<link>(.+?)</link>', item)[0]

                    try: image = re.findall('<thumbnail>(.+?)</thumbnail>', item)[0]
                    except: image = '0'

                    try: fanart2 = re.findall('<fanart>(.+?)</fanart>', item)[0]
                    except: fanart2 = fanart

                    if content =='movies':
                        try:
                            title = cleantitle(name).encode('utf-8')
                            data = {'title': title}

                            title, year = re.compile('(.+?)[(](\d{4})[)]').findall(name)[0]
                            title = cleantitle(title).encode('utf-8')
                            data = {'title': title, 'year': year}
                        except:
                            pass

                    if re.search('[a-zA-Z]', vip): name += ' [COLOR orange]%s[/COLOR]' % vip

                    if 'sublink' in url:
                        addDirectoryItem(name, url, 'subDirectory', image, image, fanart2, '0', content, data, isFolder=True)
                    else:
                        addDirectoryItem(name, url, 'resolveUrl', image, image, fanart2, '0', content, data, isFolder=False)
                except:
                    pass
        except:
            pass

    control.directory(int(sys.argv[1]), cacheToDisc=True)
Ejemplo n.º 14
0
def subDirectory(name, url, audio, image, fanart, playable, tvshow, content):
    match = re.compile('<sublink>(.+?)</sublink>').findall(url)
    if len(match) == 0: return

    try:
        title = cleantitle(name).encode('utf-8')
        data = {'title': title}
    except:
        pass

    try:
        if not content == 'movies': raise Exception()

        title = cleantitle(name).encode('utf-8')
        data = {'title': title}

        title, year = re.compile('(.+?)[(](\d{4})[)]').findall(name)[0]
        title = cleantitle(title).encode('utf-8')
        data = {'title': title, 'year': year}

        from metahandler import metahandlers
        metaget = metahandlers.MetaData(preparezip=False)

        #data = metaget.get_meta('movie', title, year=year)
        data = cachemeta.get(metaget.get_meta, 24, 'movie', title, '', '', year)

        metaimage = data['cover_url']
        if not metaimage == '': image = metaimage
        metafanart = data['backdrop_url']
        if not metafanart == '': fanart = metafanart
    except:
        pass

    try:
        if tvshow == '0' and not content == 'episodes': raise Exception()

        try:
            title = cleantitle(name).encode('utf-8')
            data = {'title': title, 'tvshowtitle': tvshow}
        except:
            pass
        try:
            i = cleaneptitle(tvshow, title)
            title, season, episode = i[0].encode('utf-8'), i[1], i[2]
            data = {'title': title, 'tvshowtitle': tvshow, 'season': season, 'episode': episode}
        except:
            pass

        from metahandler import metahandlers
        metaget = metahandlers.MetaData(preparezip=False)
        tvd = metaget.get_meta('tvshow', tvshow)
        tvd = cachemeta.get(metaget.get_meta, 24, 'tvshow', tvshow, '', '', '')

        data.update({'year': tvd['year'], 'imdb_id' : tvd['imdb_id'], 'tvdb_id' : tvd['tvdb_id'], 'tvshowtitle': tvd['TVShowTitle'], 'genre' : tvd['genre'], 'studio': tvd['studio'], 'status': tvd['status'], 'duration' : tvd['duration'], 'rating': tvd['rating'], 'mpaa' : tvd['mpaa'], 'plot': tvd['plot'], 'cast': tvd['cast']})

        metafanart = tvd['backdrop_url']
        if not metafanart == '': image = fanart = metafanart
    except:
        pass

    for i in range(0, len(match)):
        url = match[i]
        label = '%s Link %s' % (name, str(i+1))
        addDirectoryItem(label, url, 'resolveUrl', image, image, fanart, '0', content, data, isFolder=False)

    control.directory(int(sys.argv[1]), cacheToDisc=True)