Esempio n. 1
0
    def addItem(self, title, content):
        try:
            control.playlist.clear()

            items = control.window.getProperty(self.itemProperty)
            items = json.loads(items)

            if items == []: raise Exception()

            meta = control.window.getProperty(self.metaProperty)
            meta = json.loads(meta)

            infoMenu = control.lang(30502).encode('utf-8')

            downloads = True if control.setting(
                'downloads') == 'true' and not control.setting(
                    'movie.download.path') == '' else False

            #if 'tvshowtitle' in meta and 'season' in meta and 'episode' in meta:
            #    name = '%s S%02dE%02d' % (title, int(meta['season']), int(meta['episode']))
            #el
            if 'year' in meta:
                name = '%s (%s)' % (title, meta['year'])
            else:
                name = title

            systitle = urllib.quote_plus(title.encode('utf-8'))

            sysname = urllib.quote_plus(name.encode('utf-8'))

            poster = meta['poster'] if 'poster' in meta else '0'
            banner = meta['banner'] if 'banner' in meta else '0'
            thumb = meta['thumb'] if 'thumb' in meta else poster
            fanart = meta['fanart'] if 'fanart' in meta else '0'

            if poster == '0': poster = control.addonPoster()
            if banner == '0' and poster == '0': banner = control.addonBanner()
            elif banner == '0': banner = poster
            if thumb == '0' and fanart == '0': thumb = control.addonFanart()
            elif thumb == '0': thumb = fanart
            if control.setting('fanart') == 'true' and not fanart == '0': pass
            else: fanart = control.addonFanart()

            for i in range(len(items)):
                try:
                    parts = int(items[i]['parts'])
                except:
                    parts = 1

                label = items[i]['label']

                syssource = urllib.quote_plus(json.dumps([items[i]]))

                sysurl = '%s?action=playItem&title=%s&source=%s&content=%s' % (
                    sysaddon, systitle, syssource, content)

                item = control.item(label=label)

                cm = []
                cm.append((control.lang(30504).encode('utf-8'),
                           'RunPlugin(%s?action=queueItem)' % sysaddon))
                if content != 'live':
                    if downloads == True and parts <= 1:
                        sysimage = urllib.quote_plus(poster.encode('utf-8'))
                        cm.append((control.lang(30505).encode(
                            'utf-8'
                        ), 'RunPlugin(%s?action=download&name=%s&image=%s&source=%s)'
                                   %
                                   (sysaddon, systitle, sysimage, syssource)))
                item.setArt({
                    'icon': thumb,
                    'thumb': thumb,
                    'poster': poster,
                    'tvshow.poster': poster,
                    'season.poster': poster,
                    'banner': banner,
                    'tvshow.banner': banner,
                    'season.banner': banner
                })

                if not fanart == None: item.setProperty('Fanart_Image', fanart)

                item.addContextMenuItems(cm)
                item.setInfo(type='Video', infoLabels=meta)

                control.addItem(handle=syshandle,
                                url=sysurl,
                                listitem=item,
                                isFolder=False)

            control.directory(syshandle, cacheToDisc=True)
        except Exception as e:
            logger.error(e.message)
            control.infoDialog(control.lang(30501).encode('utf-8'))
Esempio n. 2
0
    def episodeDirectory(self,
                         items,
                         provider=None,
                         confViewMode='list',
                         estViewMode='widelist'):
        if items == None or len(items) == 0: return

        isFolder = True if control.setting('host_select') == '1' else False
        isPlayable = 'true' if not 'plugin' in control.infoLabel(
            'Container.PluginName') else 'false'

        playbackMenu = control.lang(30271).encode('utf-8') if control.setting(
            'host_select') == '2' else control.lang(30270).encode('utf-8')

        cacheToDisc = False

        addonPoster, addonBanner = control.addonPoster(), control.addonBanner()
        addonFanart, settingFanart = control.addonFanart(), control.setting(
            'fanart')

        indicators = playcount.getTVShowIndicators(refresh=True)

        try:
            multi = [i['tvshowtitle'] for i in items]
        except Exception as e:
            logger.error(e)
            multi = []

        multi = len([x for y, x in enumerate(multi) if x not in multi[:y]])
        multi = True if multi > 1 else False

        sysaction = '' if items[0].get('action') == None else items[0].get(
            'action')

        for i in items:
            try:
                try:
                    if i['title'] == '0':
                        label = '%sx%02d . %s %s' % (i['season'],
                                                     int(i['episode']),
                                                     'Episode', i['episode'])
                    elif i['season'] == '0':
                        label = '%s' % (i['episode'])
                    else:
                        label = '%sx%02d . %s' % (i['season'], int(
                            i['episode']), i['title'])
                except:
                    label = i['title']
                if multi == True:
                    label = '%s - %s' % (i['tvshowtitle'], label)

                systitle = sysname = urllib.quote_plus(
                    i['tvshowtitle'].encode('utf-8'))
                episodetitle, episodename = urllib.quote_plus(
                    i['title'].encode('utf-8'),
                    safe=':/'), urllib.quote_plus(i['name'].encode('utf-8'),
                                                  safe=':/')
                syspremiered = urllib.quote_plus(i['premiered'])
                imdb, tvdb, year, season, episode = i['imdb'], i['tvdb'], i[
                    'year'], i['season'], i['episode']

                poster, banner, fanart, thumb = i['poster'], i['banner'], i[
                    'fanart'], i['thumb']
                if poster == '0': poster = addonPoster
                if banner == '0' and poster == '0': banner = addonBanner
                elif banner == '0': banner = poster
                if thumb == '0' and fanart == '0': thumb = addonFanart
                elif thumb == '0': thumb = fanart

                meta = dict((k, v) for k, v in i.iteritems() if not v == '0')
                meta.update({
                    'trailer':
                    '%s?action=trailer&name=%s' % (sysaddon, sysname)
                })
                if i['duration'] == '0': meta.update({'duration': '60'})
                try:
                    meta.update({'duration': str(int(meta['duration']) * 60)})
                except:
                    pass
                sysmeta = urllib.quote_plus(json.dumps(meta))

                url = '%s?action=play&name=%s&title=%s&year=%s&imdb=%s&tvdb=%s&season=%s&episode=%s&tvshowtitle=%s&date=%s&meta=%s&t=%s' % (
                    sysaddon, episodename, episodetitle, year, imdb, tvdb,
                    season, episode, systitle, syspremiered, sysmeta,
                    self.systime)
                sysurl = urllib.quote_plus(url)

                if sysaction == 'episodes':
                    url = '%s?action=episodes&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s&season=%s&episode=%s' % (
                        sysaddon, systitle, year, imdb, tvdb, season, episode)
                    isFolder = True
                    cacheToDisc = True

                cm = []

                if isFolder == False:
                    cm.append((control.lang(30261).encode('utf-8'),
                               'RunPlugin(%s?action=queueItem)' % sysaddon))

                cm.append(
                    (control.lang(30272).encode('utf-8'), 'Action(Info)'))

                if multi == True:
                    cm.append((control.lang(30274).encode(
                        'utf-8'
                    ), 'ActivateWindow(Videos,%s?action=seasons&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s,return)'
                               % (sysaddon, systitle, year, imdb, tvdb)))

                cm.append((playbackMenu,
                           'RunPlugin(%s?action=alterSources&url=%s&meta=%s)' %
                           (sysaddon, sysurl, sysmeta)))

                item = control.item(label=label,
                                    iconImage=thumb,
                                    thumbnailImage=thumb)

                try:
                    item.setArt({
                        'poster': poster,
                        'tvshow.poster': poster,
                        'season.poster': poster,
                        'banner': banner,
                        'tvshow.banner': banner,
                        'season.banner': banner
                    })
                except:
                    pass

                if settingFanart == 'true' and not fanart == '0':
                    item.setProperty('Fanart_Image', fanart)
                elif not addonFanart == None:
                    item.setProperty('Fanart_Image', addonFanart)

                item.setInfo(type='Video', infoLabels=meta)
                item.setProperty('Video', 'true')
                item.setProperty('IsPlayable', isPlayable)
                item.setProperty('resumetime', str(0))
                item.setProperty('totaltime', str(1))
                item.addContextMenuItems(cm)

                control.addItem(handle=syshandle,
                                url=url,
                                listitem=item,
                                isFolder=False)
            except Exception as e:
                logger.error(e)
                pass

        try:
            url = items[0]['next']
            if url == '': raise Exception()
            url = '%s?action=episodes&tvshowtitle=%s&url=%s&provider=%s' % (
                sysaddon, systitle, urllib.quote_plus(url), provider)
            addonNext = control.addonNext()
            item = control.item(label=control.lang(30213).encode('utf-8'),
                                iconImage=addonNext,
                                thumbnailImage=addonNext)
            item.addContextMenuItems([])
            if not addonFanart == None:
                item.setProperty('Fanart_Image', addonFanart)
            control.addItem(handle=syshandle,
                            url=url,
                            listitem=item,
                            isFolder=True)
        except:
            pass

        content = 'episodes'
        control.content(syshandle, content)
        control.directory(syshandle, cacheToDisc=cacheToDisc)
        views.setView(
            content, {
                'skin.confluence':
                control.viewMode['confluence'][confViewMode],
                'skin.estuary': control.viewMode['esturary'][estViewMode]
            })
Esempio n. 3
0
    def movieDirectory(self, items, lang=None):
        if items == None or len(items) == 0:
            control.infoDialog(control.lang(30518).encode('utf-8'))
            return

        indicators = playcount.getMovieIndicators()

        isPlayable = 'true' if not 'plugin' in control.infoLabel(
            'Container.PluginName') else 'false'

        playbackMenu = control.lang(30204).encode('utf-8') if control.setting(
            'host_select') == '2' else control.lang(30203).encode('utf-8')

        cacheToDisc = False if not action == 'movieSearch' else True

        addonPoster, addonBanner = control.addonPoster(), control.addonBanner()
        addonFanart, settingFanart = control.addonFanart(), control.setting(
            'fanart')

        for i in items:
            try:
                label = '%s (%s)' % (i['title'], i['year'])
                imdb, title, year, trailer = i['imdb'], i['title'], i[
                    'year'], i.get('trailer')
                sysname = urllib.quote_plus('%s (%s)' % (title, year))
                systitle = urllib.quote_plus(title)

                poster, banner, fanart = i['poster'], i['banner'], i['fanart']
                if poster == '0': poster = addonPoster
                if banner == '0' and poster == '0': banner = addonBanner
                elif banner == '0': banner = poster

                meta = dict((k, v) for k, v in i.iteritems() if not v == '0')
                meta.update({
                    'trailer':
                    '%s?action=trailer&name=%s&url=%s' %
                    (sysaddon, sysname, trailer)
                })
                if i['duration'] == '0': meta.update({'duration': '120'})
                try:
                    meta.update({'duration': str(int(meta['duration']) * 60)})
                except:
                    pass
                sysmeta = urllib.quote_plus(json.dumps(meta))

                url = '%s?action=play&name=%s&title=%s&year=%s&imdb=%s&meta=%s&t=%s' % (
                    sysaddon, sysname, systitle, year, imdb, sysmeta,
                    self.systime)
                sysurl = urllib.quote_plus(url)

                cm = []

                cm.append((playbackMenu,
                           'RunPlugin(%s?action=alterSources&url=%s&meta=%s)' %
                           (sysaddon, sysurl, sysmeta)))  # AUTOPLAY

                cm.append((control.lang(30214).encode('utf-8'),
                           'RunPlugin(%s?action=trailer&name=%s&url=%s)' %
                           (sysaddon, sysname, trailer)))  # TRAILER
                cm.append((control.lang(30205).encode('utf-8'),
                           'Action(Info)'))  # MOVIEINFORMATION

                cm.append((control.lang(30212).encode('utf-8'),
                           'RunPlugin(%s?action=addView&content=movies)' %
                           sysaddon))  # SET MOVIES VIEW

                try:
                    overlay = int(playcount.getMovieOverlay(indicators, imdb))
                    #logger.debug('imdb : %s Overlay : %s' % (imdb, overlay), __name__)
                    if overlay == 7:
                        cm.append((control.lang(30206).encode(
                            'utf-8'
                        ), 'RunPlugin(%s?action=moviePlaycount&imdb=%s&query=6)'
                                   % (sysaddon, imdb)))
                        meta.update({'playcount': 1, 'overlay': 7})
                    else:
                        cm.append((control.lang(30207).encode(
                            'utf-8'
                        ), 'RunPlugin(%s?action=moviePlaycount&imdb=%s&query=7)'
                                   % (sysaddon, imdb)))
                        meta.update({'playcount': 0, 'overlay': 6})
                except Exception as e:
                    logger.error(e, __name__)
                    pass

                item = control.item(label=label,
                                    iconImage=poster,
                                    thumbnailImage=poster)

                try:
                    item.setArt({'poster': poster, 'banner': banner})
                except:
                    pass

                if settingFanart == 'true' and not fanart == '0':
                    item.setProperty('Fanart_Image', fanart)
                elif not addonFanart == None:
                    item.setProperty('Fanart_Image', addonFanart)

                item.setInfo(type='Video', infoLabels=meta)
                item.setProperty('Video', 'true')
                item.setProperty('IsPlayable', isPlayable)
                item.addContextMenuItems(cm)
                control.addItem(handle=syshandle,
                                url=url,
                                listitem=item,
                                isFolder=False)
            except Exception as e:
                logger.error(e, __name__)
                pass
        try:
            url = items[0]['next']
            if url == '': raise Exception()
            url = '%s?action=movies&url=%s' % (sysaddon,
                                               urllib.quote_plus(url))
            addonNext = control.addonNext()
            item = control.item(label=control.lang(30213).encode('utf-8'),
                                iconImage=addonNext,
                                thumbnailImage=addonNext)
            item.addContextMenuItems([])
            if not addonFanart == None:
                item.setProperty('Fanart_Image', addonFanart)
            control.addItem(handle=syshandle,
                            url=url,
                            listitem=item,
                            isFolder=True)
        except Exception as e:
            logger.error(e, __name__)
            pass

        content = 'movies'
        control.content(syshandle, content)
        control.directory(syshandle, cacheToDisc=cacheToDisc)
        views.setView(
            content, {
                'skin.confluence':
                control.viewMode['confluence']['thumbnails'],
                'skin.estuary': control.viewMode['esturary']['list']
            })
Esempio n. 4
0
    def tvshowDirectory(self,
                        items,
                        confViewMode='list',
                        estViewMode='widelist'):
        if items == None or len(items) == 0: return

        isFolder = True if control.setting('host_select') == '1' else False

        addonPoster, addonBanner = control.addonPoster(), control.addonBanner()
        addonFanart, settingFanart = control.addonFanart(), control.setting(
            'fanart')

        for i in items:
            try:
                label = i['name']
                systitle = sysname = urllib.quote_plus(
                    i['title'].encode('utf-8'), safe=':/')
                imdb, tvdb, year = i['imdb'], i['tvdb'], i['year']
                try:
                    sysurl, sysprovider = urllib.quote_plus(
                        i['url']), i['provider']
                except:
                    pass

                poster, banner, fanart = i['poster'], i['banner'], i['fanart']
                if poster == '0': poster = addonPoster
                if banner == '0' and poster == '0': banner = addonBanner
                elif banner == '0': banner = poster

                meta = dict((k, v) for k, v in i.iteritems() if not v == '0')
                meta.update({
                    'trailer':
                    '%s?action=trailer&name=%s' % (sysaddon, sysname)
                })
                if i['duration'] == '0': meta.update({'duration': '60'})
                try:
                    meta.update({'duration': str(int(meta['duration']) * 60)})
                except:
                    pass

                action = 'episodes'
                url = '%s?action=%s&provider=%s&url=%s&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s' % (
                    sysaddon, action, sysprovider, sysurl, systitle, year,
                    imdb, tvdb)

                cm = []

                if isFolder == False:
                    cm.append((control.lang(30232).encode('utf-8'),
                               'RunPlugin(%s?action=queueItem)' % sysaddon))

                cm.append(
                    (control.lang(30233).encode('utf-8'), 'Action(Info)'))

                cm.append((control.lang(30234).encode(
                    'utf-8'
                ), 'RunPlugin(%s?action=tvPlaycount&name=%s&year=%s&imdb=%s&tvdb=%s&query=7)'
                           % (sysaddon, systitle, year, imdb, tvdb)))
                cm.append((control.lang(30235).encode(
                    'utf-8'
                ), 'RunPlugin(%s?action=tvPlaycount&name=%s&year=%s&imdb=%s&tvdb=%s&query=6)'
                           % (sysaddon, systitle, year, imdb, tvdb)))

                cm.append((control.lang(30240).encode('utf-8'),
                           'RunPlugin(%s?action=addView&content=tvshows)' %
                           sysaddon))

                item = control.item(label=label,
                                    iconImage=poster,
                                    thumbnailImage=poster)

                try:
                    item.setArt({
                        'poster': poster,
                        'tvshow.poster': poster,
                        'season.poster': poster,
                        'banner': banner,
                        'tvshow.banner': banner,
                        'season.banner': banner
                    })
                except:
                    pass

                if settingFanart == 'true' and not fanart == '0':
                    item.setProperty('Fanart_Image', fanart)
                elif not addonFanart == None:
                    item.setProperty('Fanart_Image', addonFanart)

                item.setInfo(type='Video', infoLabels=meta)
                item.setProperty('Video', 'true')
                item.addContextMenuItems(cm)
                control.addItem(handle=syshandle,
                                url=url,
                                listitem=item,
                                isFolder=True)

            except Exception as e:
                logger.error(e, __name__)
                pass

        content = 'tvshows'
        control.content(syshandle, content)
        control.directory(syshandle, cacheToDisc=True)
        views.setView(
            content, {
                'skin.confluence':
                control.viewMode['confluence'][confViewMode],
                'skin.estuary': control.viewMode['esturary'][estViewMode]
            })