Beispiel #1
0
    def views(self):
        try:
            control.idle()

            items = [ (control.lang(32001).encode('utf-8'), 'movies'), (control.lang(32002).encode('utf-8'), 'tvshows'), (control.lang(32054).encode('utf-8'), 'seasons'), (control.lang(32038).encode('utf-8'), 'episodes') ]

            select = control.selectDialog([i[0] for i in items], control.lang(32049).encode('utf-8'))

            if select == -1: return

            content = items[select][1]

            title = control.lang(32059).encode('utf-8')
            url = '%s?action=addView&content=%s' % (sys.argv[0], content)

            poster, banner, fanart = control.addonPoster(), control.addonBanner(), control.addonFanart()

            item = control.item(label=title)
            item.setInfo(type='Video', infoLabels = {'title': title})
            item.setArt({'icon': poster, 'thumb': poster, 'poster': poster, 'banner': banner})
            item.setProperty('Fanart_Image', fanart)

            control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=False)
            control.content(int(sys.argv[1]), content)
            control.directory(int(sys.argv[1]), cacheToDisc=True)

            from resources.lib.libraries import views
            views.setView(content, {})
        except:
            return
Beispiel #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)
Beispiel #3
0
def getSearch():
    addDirectoryItem('%s...' % control.lang(30702).encode('utf-8'), '0',
                     'searchDirectory', '0', '0', '0', '0', '0', {})
    addDirectoryItem(
        control.lang(30703).encode('utf-8'), '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)
Beispiel #4
0
def endCategory():
    if control.skin == 'skin.confluence':
        control.execute('Container.SetViewMode(500)')
    control.directory(int(sys.argv[1]), cacheToDisc=True)
Beispiel #5
0
def searchDirectory(query=None):
    if (query == None or query == ''):
        keyboard = control.keyboard('', control.lang(30702).encode('utf-8'))
        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(workers.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(workers.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)
Beispiel #6
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 %s %s' % (name, control.lang(30704).encode('utf-8'),
                              str(i + 1))
        addDirectoryItem(label,
                         url,
                         'resolveUrl',
                         image,
                         image,
                         fanart,
                         '0',
                         content,
                         data,
                         isFolder=False)

    control.directory(int(sys.argv[1]), cacheToDisc=True)
Beispiel #7
0
def downloader():

    thumb = control.addonThumb()
    fanart = control.addonFanart()

    status = control.window.getProperty(property + '.status')

    if not downloadPath == '':
        item = control.item('[COLOR FF00b8ff]Downloads[/COLOR]',
                            iconImage=thumb,
                            thumbnailImage=thumb)
        item.addContextMenuItems([], replaceItems=True)
        item.setProperty('fanart_image', fanart)
        control.addItem(handle=int(sys.argv[1]),
                        url=downloadPath,
                        listitem=item,
                        isFolder=True)

    if status == 'downloading':
        item = control.item('[COLOR red]Stop Downloads[/COLOR]',
                            iconImage=thumb,
                            thumbnailImage=thumb)
        item.addContextMenuItems([], replaceItems=True)
        item.setProperty('fanart_image', fanart)
        control.addItem(handle=int(sys.argv[1]),
                        url=sys.argv[0] + '?action=stopDownload',
                        listitem=item,
                        isFolder=True)
    else:
        item = control.item('[COLOR FF00b8ff]Start Downloads[/COLOR]',
                            iconImage=thumb,
                            thumbnailImage=thumb)
        item.addContextMenuItems([], replaceItems=True)
        item.setProperty('fanart_image', fanart)
        control.addItem(handle=int(sys.argv[1]),
                        url=sys.argv[0] + '?action=startDownload',
                        listitem=item,
                        isFolder=True)

    if status == 'downloading':
        item = control.item('[COLOR gold]Download Status[/COLOR]',
                            iconImage=thumb,
                            thumbnailImage=thumb)
        item.addContextMenuItems([], replaceItems=True)
        item.setProperty('Fanart_Image', fanart)
        control.addItem(handle=int(sys.argv[1]),
                        url=sys.argv[0] + '?action=statusDownload',
                        listitem=item,
                        isFolder=True)

    def download():
        return []

    result = cache.bennu_download_get(download, 600000000, table='rel_dl')

    for i in result:
        try:
            cm = []
            cm.append(('Remove from Queue',
                       'RunPlugin(%s?action=removeDownload&url=%s)' %
                       (sys.argv[0], urllib.quote_plus(i['url']))))
            item = control.item(i['name'],
                                iconImage=i['image'],
                                thumbnailImage=i['image'])
            item.addContextMenuItems(cm, replaceItems=True)
            item.setProperty('fanart_image', fanart)
            item.setProperty('Video', 'true')
            item.setProperty('IsPlayable', 'true')
            control.addItem(handle=int(sys.argv[1]),
                            url=i['url'],
                            listitem=item)
        except:
            pass

    control.directory(int(sys.argv[1]), cacheToDisc=True)
Beispiel #8
0
 def endDirectory(self):
     control.content(syshandle, 'addons')
     control.directory(syshandle, cacheToDisc=True)
Beispiel #9
0
def endDirectory():
    control.directory(int(sys.argv[1]), cacheToDisc=True)