예제 #1
0
    def seasonDirectory(self, items):
        if items is None or len(items) == 0:
            control.idle()
            control.notification(title=32054, message=33049, icon='INFO')
            sys.exit()

        sysaddon = sys.argv[0]
        syshandle = int(sys.argv[1])

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

        traktCredentials = trakt.getTraktCredentialsInfo()

        if trakt.getTraktIndicatorsInfo() is True:
            watchedMenu = control.lang(32068).encode('utf-8')
            unwatchedMenu = control.lang(32069).encode('utf-8')
        else:
            watchedMenu = control.lang(32066).encode('utf-8')
            unwatchedMenu = control.lang(32067).encode('utf-8')

        traktManagerMenu = control.lang(32070).encode('utf-8')
        playlistManagerMenu = control.lang(35522).encode('utf-8')
        queueMenu = control.lang(32065).encode('utf-8')
        showPlaylistMenu = control.lang(35517).encode('utf-8')
        clearPlaylistMenu = control.lang(35516).encode('utf-8')
        labelMenu = control.lang(32055).encode('utf-8')
        playRandom = control.lang(32535).encode('utf-8')
        addToLibrary = control.lang(32551).encode('utf-8')

        try:
            multi = [i['tvshowtitle'] for i in items]
        except:
            multi = []
        multi = len([x for y, x in enumerate(multi) if x not in multi[:y]])
        multi = True if multi > 1 else False

        for i in items:
            try:
                imdb, tvdb, year, season = i['imdb'], i['tvdb'], i['year'], i[
                    'season']
                title = i['tvshowtitle']

                label = '%s %s' % (labelMenu, i['season'])

                if self.season_special is False and control.setting(
                        'tv.specials') == 'true':
                    self.season_special = True if int(season) == 0 else False

                try:
                    if i['unaired'] == 'true':
                        label = '[COLOR %s][I]%s[/I][/COLOR]' % (
                            self.unairedcolor, label)
                except:
                    pass

                systitle = sysname = urllib.quote_plus(title)

                meta = dict((k, v) for k, v in i.iteritems() if not v == '0')
                meta.update({
                    'code': imdb,
                    'imdbnumber': imdb,
                    'imdb_id': imdb
                })
                meta.update({'tvdb_id': tvdb})
                meta.update({'mediatype': 'tvshow'})
                meta.update({
                    'trailer':
                    '%s?action=trailer&name=%s' % (sysaddon, sysname)
                })

                try:
                    plot = meta['plot']
                    index = plot.rfind('See full summary')
                    if index >= 0: plot = plot[:index]
                    plot = plot.strip()
                    if re.match('[a-zA-Z\d]$', plot): plot += ' ...'
                    meta['plot'] = plot
                except:
                    pass

                try:
                    meta.update({'duration': str(int(meta['duration']) * 60)})
                except:
                    pass
                try:
                    meta.update(
                        {'genre': cleangenre.lang(meta['genre'], self.lang)})
                except:
                    pass
                try:
                    meta.update({'tvshowtitle': i['label']})
                except:
                    pass

                try:
                    # Year is the shows year, not the seasons year. Extract the correct year frpm the premier date.
                    yearNew = i['premiered']
                    yearNew = re.findall('(\d{4})', yearNew)[0]
                    yearNew = yearNew.encode('utf-8')
                    meta.update({'year': yearNew})
                except:
                    pass

                # First check thumbs, since they typically contains the seasons poster. The normal poster contains the show poster.
                poster = '0'
                if poster == '0' and 'thumb3' in i: poster = i['thumb3']
                if poster == '0' and 'thumb2' in i: poster = i['thumb2']
                if poster == '0' and 'thumb' in i: poster = i['thumb']
                if poster == '0' and 'poster3' in i: poster = i['poster3']
                if poster == '0' and 'poster2' in i: poster = i['poster2']
                if poster == '0' and 'poster' in i: poster = i['poster']

                icon = '0'
                if icon == '0' and 'icon3' in i: icon = i['icon3']
                if icon == '0' and 'icon2' in i: icon = i['icon2']
                if icon == '0' and 'icon' in i: icon = i['icon']

                thumb = '0'
                if thumb == '0' and 'thumb3' in i: thumb = i['thumb3']
                if thumb == '0' and 'thumb2' in i: thumb = i['thumb2']
                if thumb == '0' and 'thumb' in i: thumb = i['thumb']

                banner = '0'
                if banner == '0' and 'banner3' in i: banner = i['banner3']
                if banner == '0' and 'banner2' in i: banner = i['banner2']
                if banner == '0' and 'banner' in i: banner = i['banner']

                fanart = '0'
                if settingFanart:
                    if fanart == '0' and 'fanart3' in i: fanart = i['fanart3']
                    if fanart == '0' and 'fanart2' in i: fanart = i['fanart2']
                    if fanart == '0' and 'fanart' in i: fanart = i['fanart']

                clearlogo = '0'
                if clearlogo == '0' and 'clearlogo' in i:
                    clearlogo = i['clearlogo']

                clearart = '0'
                if clearart == '0' and 'clearart' in i:
                    clearart = i['clearart']

                if poster == '0': poster = addonPoster
                if icon == '0': icon = poster
                if thumb == '0': thumb = poster
                if banner == '0': banner = addonBanner
                if fanart == '0': fanart = addonFanart

                art = {}
                if not poster == '0' and not poster is None:
                    art.update({
                        'poster': poster,
                        'tvshow.poster': poster,
                        'season.poster': poster
                    })
                if not fanart == '0' and not fanart is None:
                    art.update({'fanart': fanart})
                if not icon == '0' and not icon is None:
                    art.update({'icon': icon})
                if not thumb == '0' and not thumb is None:
                    art.update({'thumb': thumb})
                if not banner == '0' and not banner is None:
                    art.update({'banner': banner})
                if not clearlogo == '0' and not clearlogo is None:
                    art.update({'clearlogo': clearlogo})
                if not clearart == '0' and not clearart is None:
                    art.update({'clearart': clearart})

####-Context Menu and Overlays-####
                cm = []

                if traktCredentials is True:
                    cm.append((
                        traktManagerMenu,
                        'RunPlugin(%s?action=traktManager&name=%s&imdb=%s&tvdb=%s&season=%s)'
                        % (sysaddon, sysname, imdb, tvdb, season)))

                try:
                    indicators = playcount.getSeasonIndicators(imdb)
                    overlay = int(
                        playcount.getSeasonOverlay(indicators, imdb, tvdb,
                                                   season))
                    watched = overlay == 7
                    if watched:
                        meta.update({'playcount': 1, 'overlay': 7})
                        cm.append((
                            unwatchedMenu,
                            'RunPlugin(%s?action=tvPlaycount&name=%s&imdb=%s&tvdb=%s&season=%s&query=6)'
                            % (sysaddon, systitle, imdb, tvdb, season)))
                    else:
                        meta.update({'playcount': 0, 'overlay': 6})
                        cm.append((
                            watchedMenu,
                            'RunPlugin(%s?action=tvPlaycount&name=%s&imdb=%s&tvdb=%s&season=%s&query=7)'
                            % (sysaddon, systitle, imdb, tvdb, season)))
                except:
                    pass

                sysmeta = urllib.quote_plus(json.dumps(meta))
                sysart = urllib.quote_plus(json.dumps(art))
                url = '%s?action=episodes&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s&season=%s' % (
                    sysaddon, systitle, year, imdb, tvdb, season)
                sysurl = urllib.quote_plus(url)

                cm.append((
                    playRandom,
                    'RunPlugin(%s?action=random&rtype=episode&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s&season=%s)'
                    % (sysaddon, urllib.quote_plus(systitle),
                       urllib.quote_plus(year), urllib.quote_plus(imdb),
                       urllib.quote_plus(tvdb), urllib.quote_plus(season))))
                # cm.append((playlistManagerMenu, 'RunPlugin(%s?action=playlistManager&name=%s&url=%s&meta=%s&art=%s)' % (sysaddon, systitle, sysurl, sysmeta, sysart)))
                cm.append(
                    (queueMenu, 'RunPlugin(%s?action=queueItem&name=%s)' %
                     (sysaddon, systitle)))
                cm.append((showPlaylistMenu,
                           'RunPlugin(%s?action=showPlaylist)' % sysaddon))
                cm.append((clearPlaylistMenu,
                           'RunPlugin(%s?action=clearPlaylist)' % sysaddon))

                cm.append((
                    addToLibrary,
                    'RunPlugin(%s?action=tvshowToLibrary&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s)'
                    % (sysaddon, systitle, year, imdb, tvdb)))
                cm.append(('[COLOR red]Venom Settings[/COLOR]',
                           'RunPlugin(%s?action=openSettings&query=(0,0))' %
                           sysaddon))
                ####################################

                item = control.item(label=label)

                unwatchedEnabled = True
                unwatchedLimit = False

                if unwatchedEnabled:
                    count = playcount.getSeasonCount(imdb, season,
                                                     self.season_special,
                                                     unwatchedLimit)
                    if count:
                        item.setProperty('TotalEpisodes', str(count['total']))
                        item.setProperty('WatchedEpisodes',
                                         str(count['watched']))
                        item.setProperty('UnWatchedEpisodes',
                                         str(count['unwatched']))

                total_seasons = trakt.getSeasons(imdb, full=False)
                if not total_seasons is None:
                    total_seasons = [i['number'] for i in total_seasons]
                    total_seasons = len(total_seasons)
                    if control.setting(
                            'tv.specials'
                    ) == 'false' or self.season_special is False:
                        total_seasons = total_seasons - 1
                    item.setProperty('TotalSeasons', str(total_seasons))

                if 'episodeIDS' in i:
                    item.setUniqueIDs(i['episodeIDS'])
                if 'cast' in i:
                    item.setCast(i['cast'])

                # if not fanart == '0' and not fanart is None:
                # item.setProperty('Fanart_Image', fanart)

                item.setArt(art)
                item.setInfo(type='video',
                             infoLabels=control.metadataClean(meta))
                item.addContextMenuItems(cm)
                video_streaminfo = {'codec': 'h264'}
                item.addStreamInfo('video', video_streaminfo)
                control.addItem(handle=syshandle,
                                url=url,
                                listitem=item,
                                isFolder=True)
            except:
                pass

        try:
            control.property(syshandle, 'showplot', items[0]['plot'])
        except:
            pass

        control.content(syshandle, 'seasons')
        control.directory(syshandle, cacheToDisc=True)
        views.setView('seasons', {'skin.estuary': 55, 'skin.confluence': 500})
예제 #2
0
 def seasonDirectory(self, items):
     if not items:  # with reuselanguageinvoker on an empty directory must be loaded, do not use sys.exit()
         control.hide()
         control.notification(title=32054, message=33049)
     sysaddon, syshandle = argv[0], int(argv[1])
     is_widget = 'plugin' not in control.infoLabel('Container.PluginName')
     settingFanart = control.setting('fanart') == 'true'
     addonPoster, addonFanart, addonBanner = control.addonPoster(
     ), control.addonFanart(), control.addonBanner()
     try:
         indicators = playcount.getSeasonIndicators(items[0]['imdb'],
                                                    refresh=True)
     except:
         indicators = None
     unwatchedEnabled = control.setting(
         'tvshows.unwatched.enabled') == 'true'
     if trakt.getTraktIndicatorsInfo():
         watchedMenu, unwatchedMenu = control.lang(32068), control.lang(
             32069)
     else:
         watchedMenu, unwatchedMenu = control.lang(32066), control.lang(
             32067)
     traktManagerMenu, queueMenu = control.lang(32070), control.lang(32065)
     showPlaylistMenu, clearPlaylistMenu = control.lang(
         35517), control.lang(35516)
     labelMenu, playRandom = control.lang(32055), control.lang(32535)
     addToLibrary = control.lang(32551)
     try:
         multi = [i['tvshowtitle'] for i in items]
     except:
         multi = []
     multi = True if len(
         [x for y, x in enumerate(multi)
          if x not in multi[:y]]) > 1 else False
     for i in items:
         try:
             imdb, tmdb, tvdb, year, season = i.get('imdb', ''), i.get(
                 'tmdb', ''), i.get('tvdb', ''), i.get('year',
                                                       ''), i.get('season')
             title = i.get('tvshowtitle')
             label = '%s %s' % (labelMenu, i.get('season'))
             if not self.season_special and self.showspecials:
                 self.season_special = True if int(season) == 0 else False
             try:
                 if i['unaired'] == 'true':
                     label = '[COLOR %s][I]%s[/I][/COLOR]' % (
                         self.unairedcolor, label)
             except:
                 pass
             systitle = quote_plus(title)
             meta = dict((k, v) for k, v in control.iteritems(i)
                         if v is not None and v != '')
             # setting mediatype to "season" causes "Infomation" and "play trailer" to not be available in some skins
             meta.update(
                 {
                     'code': imdb,
                     'imdbnumber': imdb,
                     'mediatype': 'season',
                     'tag': [imdb, tmdb]
                 }
             )  # "tag" and "tagline" for movies only, but works in my skin mod so leave
             try:
                 meta.update(
                     {'genre': cleangenre.lang(meta['genre'], self.lang)})
             except:
                 pass
             # First check thumbs, since they typically contains the seasons poster. The normal poster contains the show poster.
             poster = meta.get('thumb') or meta.get('poster3') or meta.get(
                 'poster2') or meta.get('poster') or addonPoster
             season_poster = meta.get('season_poster') or poster
             landscape = meta.get('landscape')
             fanart = ''
             if settingFanart:
                 fanart = meta.get('fanart3') or meta.get(
                     'fanart2') or meta.get(
                         'fanart') or landscape or addonFanart
             thumb = season_poster
             icon = meta.get('icon') or poster
             banner = meta.get('banner3') or meta.get(
                 'banner2') or meta.get('banner') or addonBanner
             art = {}
             art.update({
                 'poster': season_poster,
                 'tvshow.poster': poster,
                 'season.poster': season_poster,
                 'fanart': fanart,
                 'icon': icon,
                 'thumb': thumb,
                 'banner': banner,
                 'clearlogo': meta.get('clearlogo'),
                 'clearart': meta.get('clearart'),
                 'landscape': landscape
             })
             for k in ('poster2', 'poster3', 'fanart2', 'fanart3',
                       'banner2', 'banner3'):
                 meta.pop(k, None)
             meta.update({
                 'poster': poster,
                 'fanart': fanart,
                 'banner': banner,
                 'thumb': thumb,
                 'icon': icon
             })
             ####-Context Menu and Overlays-####
             cm = []
             if self.traktCredentials:
                 cm.append((
                     traktManagerMenu,
                     'RunPlugin(%s?action=tools_traktManager&name=%s&imdb=%s&tvdb=%s&season=%s)'
                     % (sysaddon, systitle, imdb, tvdb, season)))
             try:
                 overlay = int(
                     playcount.getSeasonOverlay(indicators, imdb, tvdb,
                                                season))
                 watched = (overlay == 5)
                 if watched:
                     meta.update({'playcount': 1, 'overlay': 5})
                     cm.append((
                         unwatchedMenu,
                         'RunPlugin(%s?action=playcount_TVShow&name=%s&imdb=%s&tvdb=%s&season=%s&query=4)'
                         % (sysaddon, systitle, imdb, tvdb, season)))
                 else:
                     meta.update({'playcount': 0, 'overlay': 4})
                     cm.append((
                         watchedMenu,
                         'RunPlugin(%s?action=playcount_TVShow&name=%s&imdb=%s&tvdb=%s&season=%s&query=5)'
                         % (sysaddon, systitle, imdb, tvdb, season)))
             except:
                 pass
             sysmeta = quote_plus(jsdumps(meta))
             cm.append((
                 playRandom,
                 'RunPlugin(%s?action=random&rtype=episode&tvshowtitle=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s&meta=%s&season=%s)'
                 % (sysaddon, systitle, year, imdb, tmdb, tvdb, sysmeta,
                    season)))
             cm.append((queueMenu,
                        'RunPlugin(%s?action=playlist_QueueItem&name=%s)' %
                        (sysaddon, systitle)))
             cm.append((showPlaylistMenu,
                        'RunPlugin(%s?action=playlist_Show)' % sysaddon))
             cm.append((clearPlaylistMenu,
                        'RunPlugin(%s?action=playlist_Clear)' % sysaddon))
             cm.append((
                 addToLibrary,
                 'RunPlugin(%s?action=library_tvshowToLibrary&tvshowtitle=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s)'
                 % (sysaddon, systitle, year, imdb, tmdb, tvdb)))
             cm.append(
                 ('[COLOR red]Venom Settings[/COLOR]',
                  'RunPlugin(%s?action=tools_openSettings)' % sysaddon))
             ####################################
             url = '%s?action=episodes&tvshowtitle=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s&meta=%s&season=%s' % (
                 sysaddon, systitle, year, imdb, tmdb, tvdb, sysmeta,
                 season)
             try:
                 item = control.item(label=label, offscreen=True)
             except:
                 item = control.item(label=label)
             if 'castandart' in i: item.setCast(i['castandart'])
             item.setArt(art)
             if unwatchedEnabled:
                 try:
                     count = playcount.getSeasonCount(
                         imdb, season, self.season_special
                     )  # self.season_special is just a flag to set if a season special exists and we are set to show it
                     if count:
                         item.setProperties({
                             'WatchedEpisodes':
                             str(count['watched']),
                             'UnWatchedEpisodes':
                             str(count['unwatched'])
                         })
                     else:
                         item.setProperties(
                             {
                                 'WatchedEpisodes':
                                 '0',
                                 'UnWatchedEpisodes':
                                 str(
                                     meta.get('counts',
                                              {}).get(str(season), ''))
                             }
                         )  # temp use TMDb's season-episode count for threads not finished....next load counts will update with trakt data
                 except:
                     pass
             try:
                 item.setProperties({
                     'TotalSeasons':
                     str(meta.get('total_seasons', '')),
                     'TotalEpisodes':
                     str(meta.get('total_episodes', ''))
                 })
             except:
                 pass  #da hell with 17 users
             if is_widget: item.setProperty('isVenom_widget', 'true')
             try:  # Year is the shows year, not the seasons year. Extract year from premier date for InfoLabels to have "season_year".
                 season_year = re.findall(r'(\d{4})',
                                          i.get('premiered', ''))[0]
                 meta.update({'year': season_year})
             except:
                 pass
             item.setUniqueIDs({'imdb': imdb, 'tmdb': tmdb, 'tvdb': tvdb})
             item.setProperty('IsPlayable', 'false')
             item.setInfo(type='video',
                          infoLabels=control.metadataClean(meta))
             item.addContextMenuItems(cm)
             control.addItem(handle=syshandle,
                             url=url,
                             listitem=item,
                             isFolder=True)
         except:
             log_utils.error()
     try:
         control.property(syshandle, 'showplot', items[0]['plot'])
     except:
         pass
     control.content(syshandle, 'seasons')
     control.directory(syshandle, cacheToDisc=True)
     views.setView('seasons', {'skin.estuary': 55, 'skin.confluence': 500})
예제 #3
0
    def seasonDirectory(self, items):
        if not items:
            control.hide()
            control.notification(title=32054, message=33049)
            sys.exit()

        sysaddon = sys.argv[0]
        syshandle = int(sys.argv[1])
        is_widget = 'plugin' not in control.infoLabel('Container.PluginName')
        settingFanart = control.setting('fanart')
        addonPoster = control.addonPoster()
        addonFanart = control.addonFanart()
        addonBanner = control.addonBanner()

        try:
            indicators = playcount.getSeasonIndicators(items[0]['imdb'],
                                                       refresh=True)
        except:
            indicators = None
        unwatchedEnabled = control.setting(
            'tvshows.unwatched.enabled') == 'true'

        if trakt.getTraktIndicatorsInfo():
            watchedMenu = control.lang(32068)
            unwatchedMenu = control.lang(32069)
        else:
            watchedMenu = control.lang(32066)
            unwatchedMenu = control.lang(32067)

        traktManagerMenu = control.lang(32070)
        queueMenu = control.lang(32065)
        showPlaylistMenu = control.lang(35517)
        clearPlaylistMenu = control.lang(35516)
        labelMenu = control.lang(32055)
        playRandom = control.lang(32535)
        addToLibrary = control.lang(32551)

        try:
            multi = [i['tvshowtitle'] for i in items]
        except:
            multi = []
        multi = len([x for y, x in enumerate(multi) if x not in multi[:y]])
        multi = True if multi > 1 else False

        if self.disable_fanarttv != 'true':
            tvdb = [i['tvdb'] for i in items][0]
            from resources.lib.indexers import fanarttv
            extended_art = cache.get(fanarttv.get_tvshow_art, 168, tvdb)
        else:
            extended_art = None

        for i in items:
            try:
                imdb, tmdb, tvdb, year, season = i.get('imdb', '0'), i.get(
                    'tmdb', '0'), i.get('tvdb', '0'), i.get('year',
                                                            '0'), i['season']
                title = i['tvshowtitle']
                label = '%s %s' % (labelMenu, i['season'])

                if not self.season_special and control.setting(
                        'tv.specials') == 'true':
                    self.season_special = True if int(season) == 0 else False
                try:
                    if i['unaired'] == 'true':
                        label = '[COLOR %s][I]%s[/I][/COLOR]' % (
                            self.unairedcolor, label)
                except:
                    pass

                systitle = quote_plus(title)
                meta = dict((k, v) for k, v in i.iteritems() if v != '0')
                meta.update({
                    'code': imdb,
                    'imdbnumber': imdb,
                    'mediatype': 'tvshow',
                    'tag': [imdb, tvdb]
                })

                # Some descriptions have a link at the end that. Remove it.
                try:
                    plot = meta['plot']
                    index = plot.rfind('See full summary')
                    if index >= 0: plot = plot[:index]
                    plot = plot.strip()
                    if re.match(r'[a-zA-Z\d]$', plot): plot += ' ...'
                    meta['plot'] = plot
                except:
                    pass

                try:
                    meta.update({'duration': str(int(meta['duration']) * 60)})
                except:
                    pass
                try:
                    meta.update(
                        {'genre': cleangenre.lang(meta['genre'], self.lang)})
                except:
                    pass
                try:
                    meta.update({'tvshowtitle': i['label']})
                except:
                    pass

                try:
                    # Year is the shows year, not the seasons year. Extract the correct year from the premier date.
                    yearNew = re.findall(r'(\d{4})', i['premiered'])[0]
                    yearNew = yearNew.encode('utf-8')
                    meta.update({'year': yearNew})
                except:
                    pass

                # First check thumbs, since they typically contains the seasons poster. The normal poster contains the show poster.
                poster = meta.get('thumb') or meta.get('poster3') or meta.get(
                    'poster2') or poster1 or addonPoster
                fanart = ''
                if settingFanart:
                    fanart = meta.get('fanart3') or meta.get(
                        'fanart2') or meta.get('fanart') or addonFanart
                thumb = meta.get('thumb') or poster
                icon = meta.get('icon') or poster
                banner = meta.get('banner3') or meta.get(
                    'banner2') or meta.get('banner') or addonBanner
                if extended_art:
                    clearlogo = extended_art.get('clearlogo')
                    clearart = extended_art.get('clearart')
                else:
                    clearlogo = '0'
                    clearart = '0'
                art = {}
                art.update({
                    'poster': poster,
                    'tvshow.poster': poster,
                    'season.poster': poster,
                    'fanart': fanart,
                    'icon': icon,
                    'thumb': thumb,
                    'banner': banner,
                    'clearlogo': clearlogo,
                    'clearart': clearart
                })

                ####-Context Menu and Overlays-####
                cm = []
                if self.traktCredentials:
                    cm.append((
                        traktManagerMenu,
                        'RunPlugin(%s?action=tools_traktManager&name=%s&imdb=%s&tvdb=%s&season=%s)'
                        % (sysaddon, systitle, imdb, tvdb, season)))

                try:
                    overlay = int(
                        playcount.getSeasonOverlay(indicators, imdb, tvdb,
                                                   season))
                    watched = overlay == 7
                    if watched:
                        meta.update({'playcount': 1, 'overlay': 7})
                        cm.append((
                            unwatchedMenu,
                            'RunPlugin(%s?action=playcount_TVShow&name=%s&imdb=%s&tvdb=%s&season=%s&query=6)'
                            % (sysaddon, systitle, imdb, tvdb, season)))
                    else:
                        meta.update({'playcount': 0, 'overlay': 6})
                        cm.append((
                            watchedMenu,
                            'RunPlugin(%s?action=playcount_TVShow&name=%s&imdb=%s&tvdb=%s&season=%s&query=7)'
                            % (sysaddon, systitle, imdb, tvdb, season)))
                except:
                    pass

                url = '%s?action=episodes&tvshowtitle=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s&season=%s' % (
                    sysaddon, systitle, year, imdb, tmdb, tvdb, season)
                cm.append((
                    playRandom,
                    'RunPlugin(%s?action=random&rtype=episode&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s&season=%s)'
                    % (sysaddon, systitle, year, imdb, tvdb, season)))

                cm.append((queueMenu,
                           'RunPlugin(%s?action=playlist_QueueItem&name=%s)' %
                           (sysaddon, systitle)))
                cm.append((showPlaylistMenu,
                           'RunPlugin(%s?action=playlist_Show)' % sysaddon))
                cm.append((clearPlaylistMenu,
                           'RunPlugin(%s?action=playlist_Clear)' % sysaddon))
                cm.append((
                    addToLibrary,
                    'RunPlugin(%s?action=library_tvshowToLibrary&tvshowtitle=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s)'
                    % (sysaddon, systitle, year, imdb, tmdb, tvdb)))
                cm.append(
                    ('[COLOR red]Venom Settings[/COLOR]',
                     'RunPlugin(%s?action=tools_openSettings)' % sysaddon))
                ####################################

                if not i.get('trailer'):
                    meta.update({
                        'trailer':
                        '%s?action=trailer&type=%s&name=%s&year=%s&imdb=%s' %
                        (sysaddon, 'show', quote_plus(title), year, imdb)
                    })

                item = control.item(label=label)
                if 'castandart' in i: item.setCast(i['castandart'])
                if 'episodeIDS' in i: item.setUniqueIDs(i['episodeIDS'])
                if unwatchedEnabled:
                    count = playcount.getSeasonCount(imdb, season,
                                                     self.season_special)
                    if count:
                        item.setProperty('TotalEpisodes', str(count['total']))
                        item.setProperty('WatchedEpisodes',
                                         str(count['watched']))
                        item.setProperty('UnWatchedEpisodes',
                                         str(count['unwatched']))

                if 'total_seasons' in meta:
                    item.setProperty('TotalSeasons',
                                     str(meta.get('total_seasons')))

                item.setArt(art)
                item.setProperty('IsPlayable', 'false')
                if is_widget:
                    item.setProperty('isVenom_widget', 'true')
                item.setInfo(type='video',
                             infoLabels=control.metadataClean(meta))
                item.addContextMenuItems(cm)
                video_streaminfo = {'codec': 'h264'}
                item.addStreamInfo('video', video_streaminfo)
                control.addItem(handle=syshandle,
                                url=url,
                                listitem=item,
                                isFolder=True)
            except:
                log_utils.error()

        try:
            control.property(syshandle, 'showplot', items[0]['plot'])
        except:
            pass

        control.content(syshandle, 'seasons')
        control.directory(syshandle, cacheToDisc=True)
        views.setView('seasons', {'skin.estuary': 55, 'skin.confluence': 500})
예제 #4
0
	def seasonDirectory(self, items):
		if items is None or len(items) == 0:
			control.hide()
			control.notification(title = 32054, message = 33049, icon = 'INFO', sound=notificationSound)
			sys.exit()

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

		try:
			indicators = playcount.getSeasonIndicators(items[0]['imdb'])
		except :
			pass

		unwatchedEnabled = control.setting('tvshows.unwatched.enabled')
		unwatchedLimit = False
		seasoncountEnabled = control.setting('tvshows.seasoncount.enabled')

		if trakt.getTraktIndicatorsInfo() is True:
			watchedMenu = control.lang(32068).encode('utf-8')
			unwatchedMenu = control.lang(32069).encode('utf-8')
		else:
			watchedMenu = control.lang(32066).encode('utf-8')
			unwatchedMenu = control.lang(32067).encode('utf-8')

		traktManagerMenu = control.lang(32070).encode('utf-8')
		# playlistManagerMenu = control.lang(35522).encode('utf-8')
		queueMenu = control.lang(32065).encode('utf-8')
		showPlaylistMenu = control.lang(35517).encode('utf-8')
		clearPlaylistMenu = control.lang(35516).encode('utf-8')
		labelMenu = control.lang(32055).encode('utf-8')
		playRandom = control.lang(32535).encode('utf-8')
		addToLibrary = control.lang(32551).encode('utf-8')

		try:
			multi = [i['tvshowtitle'] for i in items]
		except:
			multi = []
		multi = len([x for y,x in enumerate(multi) if x not in multi[:y]])
		multi = True if multi > 1 else False

		for i in items:
			try:
				imdb, tmdb, tvdb, year, season = i.get('imdb', '0'), i.get('tmdb', '0'), i.get('tvdb', '0'), i.get('year', '0'), i['season']
				title = i['tvshowtitle']
				label = '%s %s' % (labelMenu, i['season'])

				if self.season_special is False and control.setting('tv.specials') == 'true':
					self.season_special = True if int(season) == 0 else False

				try:
					if i['unaired'] == 'true':
						label = '[COLOR %s][I]%s[/I][/COLOR]' % (self.unairedcolor, label)
				except:
					pass

				systitle = urllib.quote_plus(title)

				meta = dict((k, v) for k, v in i.iteritems() if v != '0')
				meta.update({'code': imdb, 'imdbnumber': imdb})
				meta.update({'mediatype': 'tvshow'})
				meta.update({'tag': [imdb, tvdb]})

				# Some descriptions have a link at the end that. Remove it.
				try:
					plot = meta['plot']
					index = plot.rfind('See full summary')
					if index >= 0: plot = plot[:index]
					plot = plot.strip()
					if re.match('[a-zA-Z\d]$', plot): plot += ' ...'
					meta['plot'] = plot
				except: pass

				try: meta.update({'duration': str(int(meta['duration']) * 60)})
				except: pass
				try: meta.update({'genre': cleangenre.lang(meta['genre'], self.lang)})
				except: pass
				try: meta.update({'tvshowtitle': i['label']})
				except: pass

				try:
					# Year is the shows year, not the seasons year. Extract the correct year frpm the premier date.
					yearNew = i['premiered']
					yearNew = re.findall('(\d{4})', yearNew)[0]
					yearNew = yearNew.encode('utf-8')
					meta.update({'year': yearNew})
				except:
					pass

				# First check thumbs, since they typically contains the seasons poster. The normal poster contains the show poster.
				poster1 = meta.get('poster')
				poster2 = meta.get('poster2')
				poster3 = meta.get('poster3')
				poster4 = meta.get('thumb')
				poster = poster4 or poster3 or poster2 or poster1 or addonPoster

				fanart = ''
				if settingFanart:
					fanart1 = meta.get('fanart')
					fanart2 = meta.get('fanart2')
					fanart3 = meta.get('fanart3')
					fanart = fanart3 or fanart2 or fanart1 or addonFanart

				# landscape = meta.get('landscape')
				thumb = meta.get('thumb') or poster
				icon = meta.get('icon') or poster

				banner1 = meta.get('banner')
				banner2 = meta.get('banner2')
				banner3 = meta.get('banner3')
				banner = banner3 or banner2 or banner1 or addonBanner

				clearlogo = meta.get('clearlogo')
				clearart = meta.get('clearart')

				art = {}
				art.update({'poster': poster, 'tvshow.poster': poster, 'season.poster': poster, 'fanart': fanart, 'icon': icon,
									'thumb': thumb, 'banner': banner, 'clearlogo': clearlogo, 'clearart': clearart})

####-Context Menu and Overlays-####
				cm = []
				if self.traktCredentials is True:
					cm.append((traktManagerMenu, 'RunPlugin(%s?action=traktManager&name=%s&imdb=%s&tvdb=%s&season=%s)' % (sysaddon, systitle, imdb, tvdb, season)))

				try:
					overlay = int(playcount.getSeasonOverlay(indicators, imdb, tvdb, season))
					watched = overlay == 7
					if watched:
						meta.update({'playcount': 1, 'overlay': 7})
						cm.append((unwatchedMenu, 'RunPlugin(%s?action=tvPlaycount&name=%s&imdb=%s&tvdb=%s&season=%s&query=6)' % (sysaddon, systitle, imdb, tvdb, season)))
					else: 
						meta.update({'playcount': 0, 'overlay': 6})
						cm.append((watchedMenu, 'RunPlugin(%s?action=tvPlaycount&name=%s&imdb=%s&tvdb=%s&season=%s&query=7)' % (sysaddon, systitle, imdb, tvdb, season)))
				except:
					pass

				# sysmeta = urllib.quote_plus(json.dumps(meta))
				# sysart = urllib.quote_plus(json.dumps(art))
				url = '%s?action=episodes&tvshowtitle=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s&season=%s' % (sysaddon, systitle, year, imdb, tmdb, tvdb, season)
				# sysurl = urllib.quote_plus(url)

				cm.append((playRandom, 'RunPlugin(%s?action=random&rtype=episode&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s&season=%s)' % (
									sysaddon, systitle, year, imdb, tvdb, season)))

				# cm.append((playlistManagerMenu, 'RunPlugin(%s?action=playlistManager&name=%s&url=%s&meta=%s&art=%s)' % (sysaddon, systitle, sysurl, sysmeta, sysart)))
				cm.append((queueMenu, 'RunPlugin(%s?action=queueItem&name=%s)' % (sysaddon, systitle)))
				cm.append((showPlaylistMenu, 'RunPlugin(%s?action=showPlaylist)' % sysaddon))
				cm.append((clearPlaylistMenu, 'RunPlugin(%s?action=clearPlaylist)' % sysaddon))

				if control.setting('library.service.update') == 'true':
					cm.append((addToLibrary, 'RunPlugin(%s?action=tvshowToLibrary&tvshowtitle=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s)' % (sysaddon, systitle, year, imdb, tmdb, tvdb)))
				cm.append((control.lang(32610).encode('utf-8'), 'RunPlugin(%s?action=clearAllCache&opensettings=false)' % sysaddon))
				cm.append(('[COLOR red]Venom Settings[/COLOR]', 'RunPlugin(%s?action=openSettings)' % sysaddon))
####################################

				if not i.get('trailer'):
					meta.update({'trailer': '%s?action=trailer&type=%s&name=%s&year=%s&imdb=%s' % (sysaddon, 'show', urllib.quote_plus(title), year, imdb)})

				item = control.item(label = label)
				if 'castandart' in i:
					item.setCast(i['castandart'])

				if 'episodeIDS' in i:
					item.setUniqueIDs(i['episodeIDS'])

				if unwatchedEnabled == 'true':
					count = playcount.getSeasonCount(imdb, season, self.season_special, unwatchedLimit)
					if count:
						item.setProperty('TotalEpisodes', str(count['total']))
						item.setProperty('WatchedEpisodes', str(count['watched']))
						item.setProperty('UnWatchedEpisodes', str(count['unwatched']))

				if seasoncountEnabled == 'true' and self.traktCredentials is True:
					total_seasons = trakt.getSeasons(imdb, full=False)
					if total_seasons is not None:
						total_seasons = [i['number'] for i in total_seasons]
						season_special = True if 0 in total_seasons else False
						total_seasons = len(total_seasons)
						if control.setting('tv.specials') == 'false' and season_special is True:
							total_seasons = total_seasons - 1
						item.setProperty('TotalSeasons', str(total_seasons))

				item.setArt(art)
				item.setProperty('IsPlayable', 'false')
				if is_widget:
					item.setProperty('isVenom_widget', 'true')
				item.setInfo(type='video', infoLabels=control.metadataClean(meta))
				item.addContextMenuItems(cm)
				video_streaminfo = {'codec': 'h264'}
				item.addStreamInfo('video', video_streaminfo)
				control.addItem(handle=syshandle, url=url, listitem=item, isFolder=True)
			except:
				log_utils.error()
				pass

		try:
			control.property(syshandle, 'showplot', items[0]['plot'])
		except:
			pass

		control.content(syshandle, 'seasons')
		control.directory(syshandle, cacheToDisc=True)
		views.setView('seasons', {'skin.estuary': 55, 'skin.confluence': 500})
예제 #5
0
파일: seasons.py 프로젝트: bopopescu/repo-1
	def seasonDirectory(self, items):
		if isinstance(items, dict) and 'value' in items:
			items = items['value']
		if isinstance(items, basestring):
			try: items = tools.Converter.jsonFrom(items)
			except: pass

		if items == None or len(items) == 0:
			interface.Loader.hide()
			interface.Dialog.notification(title = 32054, message = 33049, icon = interface.Dialog.IconInformation)
			sys.exit()

		sysaddon = sys.argv[0]
		syshandle = int(sys.argv[1])
		media = tools.Media()

		addonPoster, addonBanner = control.addonPoster(), control.addonBanner()
		addonFanart, settingFanart = control.addonFanart(), tools.Settings.getBoolean('interface.fanart')

		try: indicators =  playcount.getSeasonIndicators(items[0]['imdb'])
		except: indicators = None

		unwatchedEnabled = tools.Settings.getBoolean('interface.tvshows.unwatched.enabled')
		unwatchedLimit = tools.Settings.getBoolean('interface.tvshows.unwatched.limit')

		try: multi = [i['tvshowtitle'] for i in items]
		except: multi = []
		multi = len([x for y,x in enumerate(multi) if x not in multi[:y]])
		multi = True if multi > 1 else False

		for i in items:
			try:
				imdb, tvdb, year, season = i['imdb'], i['tvdb'], i['year'], i['season']
				title = i['tvshowtitle']
				label = None
				try: label = media.title(tools.Media.TypeSeason, season = season)
				except: pass
				if label == None: label = season
				if multi == True and not label in title and not title in label: label = '%s - %s' % (title, label)

				systitle = sysname = urllib.quote_plus(title)

				meta = dict((k,v) for k, v in i.iteritems() if not v == '0')
				meta.update({'mediatype': 'tvshow'})
				meta.update({'trailer': '%s?action=streamsTrailer&title=%s&imdb=%s' % (sysaddon, sysname, imdb)})

				# Gaia
				# Remove default time, since this might mislead users. Rather show no time.
				#if not 'duration' in i: meta.update({'duration': '60'})
				#elif i['duration'] == '0': meta.update({'duration': '60'})

				# Gaia
				# Some descriptions have a link at the end that. Remove it.
				try:
					plot = meta['plot']
					index = plot.rfind('See full summary')
					if index >= 0: plot = plot[:index]
					plot = plot.strip()
					if re.match('[a-zA-Z\d]$', plot): plot += ' ...'
					meta['plot'] = plot
				except: pass

				try: meta.update({'duration': str(int(meta['duration']) * 60)})
				except: pass
				try: meta.update({'genre': cleangenre.lang(meta['genre'], self.lang)})
				except: pass
				try: meta.update({'tvshowtitle': i['label']})
				except: pass
				try:
					# Year is the shows year, not the seasons year. Extract the correct year frpm the premier date.
					yearNew = i['premiered']
					yearNew = re.findall('(\d{4})', yearNew)[0]
					yearNew = yearNew.encode('utf-8')
					meta.update({'year': yearNew})
				except:
					pass

				sysmeta = urllib.quote_plus(json.dumps(meta))
				url = self.parameterize('%s?action=episodesRetrieve&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s&season=%s' % (sysaddon, systitle, year, imdb, tvdb, season))

				item = control.item(label = label)

				try:
					overlay = int(playcount.getSeasonOverlay(indicators, imdb, tvdb, season))
					watched = overlay == 7
					if watched: meta.update({'playcount': 1, 'overlay': 7})
					else: meta.update({'playcount': 0, 'overlay': 6})
					if unwatchedEnabled and not watched:
						count = playcount.getSeasonCount(imdb, season, unwatchedLimit)
						if count:
							item.setProperty('TotalEpisodes', str(count['total']))
							item.setProperty('WatchedEpisodes', str(count['watched']))
							item.setProperty('UnWatchedEpisodes', str(count['unwatched']))
				except: pass

				# First check thumbs, since they typically contains the seasons poster. The normal poster contains the show poster.
				poster = '0'
				if poster == '0' and 'thumb3' in i: poster = i['thumb3']
				if poster == '0' and 'thumb2' in i: poster = i['thumb2']
				if poster == '0' and 'thumb' in i: poster = i['thumb']
				if poster == '0' and 'poster3' in i: poster = i['poster3']
				if poster == '0' and 'poster2' in i: poster = i['poster2']
				if poster == '0' and 'poster' in i: poster = i['poster']

				icon = '0'
				if icon == '0' and 'icon3' in i: icon = i['icon3']
				if icon == '0' and 'icon2' in i: icon = i['icon2']
				if icon == '0' and 'icon' in i: icon = i['icon']

				thumb = '0'
				if thumb == '0' and 'thumb3' in i: thumb = i['thumb3']
				if thumb == '0' and 'thumb2' in i: thumb = i['thumb2']
				if thumb == '0' and 'thumb' in i: thumb = i['thumb']

				banner = '0'
				if banner == '0' and 'banner3' in i: banner = i['banner3']
				if banner == '0' and 'banner2' in i: banner = i['banner2']
				if banner == '0' and 'banner' in i: banner = i['banner']

				fanart = '0'
				if settingFanart:
					if fanart == '0' and 'fanart3' in i: fanart = i['fanart3']
					if fanart == '0' and 'fanart2' in i: fanart = i['fanart2']
					if fanart == '0' and 'fanart' in i: fanart = i['fanart']

				clearlogo = '0'
				if clearlogo == '0' and 'clearlogo' in i: clearlogo = i['clearlogo']

				clearart = '0'
				if clearart == '0' and 'clearart' in i: clearart = i['clearart']

				if poster == '0': poster = addonPoster
				if icon == '0': icon = poster
				if thumb == '0': thumb = poster
				if banner == '0': banner = addonBanner
				if fanart == '0': fanart = addonFanart

				art = {}
				if not poster == '0' and not poster == None: art.update({'poster' : poster, 'tvshow.poster' : poster, 'season.poster' : poster})
				if not icon == '0' and not icon == None: art.update({'icon' : icon})
				if not thumb == '0' and not thumb == None: art.update({'thumb' : thumb})
				if not banner == '0' and not banner == None: art.update({'banner' : banner})
				if not clearlogo == '0' and not clearlogo == None: art.update({'clearlogo' : clearlogo})
				if not clearart == '0' and not clearart == None: art.update({'clearart' : clearart})
				if not fanart == '0' and not fanart == None: item.setProperty('Fanart_Image', fanart)

				item.setArt(art)
				item.setInfo(type = 'Video', infoLabels = tools.Media.metadataClean(meta))
				item.addContextMenuItems([interface.Context(mode = interface.Context.ModeItem, type = self.type, kids = self.kids, create = True, watched = watched, season = season, metadata = meta, art = art, label = label, link = url, trailer = title, title = title, year = year, imdb = imdb, tvdb = tvdb).menu()])
				control.addItem(handle = syshandle, url = url, listitem = item, isFolder = True)
			except:
				pass

		try: control.property(syshandle, 'showplot', items[0]['plot'])
		except: pass

		control.content(syshandle, 'seasons')
		control.directory(syshandle, cacheToDisc = True)
		views.setView('seasons', {'skin.estuary': 55, 'skin.confluence': 500})
예제 #6
0
    def seasonDirectory(self, items):
        if items == None or len(items) == 0:
            control.idle()
            sys.exit()

        sysaddon = sys.argv[0]

        syshandle = int(sys.argv[1])

        addonPoster, addonBanner = control.addonPoster(), control.addonBanner()

        addonFanart, settingFanart = control.addonFanart(
        ), tools.Settings.getBoolean('interface.fanart')

        traktCredentials = trakt.getTraktCredentialsInfo()

        try:
            isOld = False
            control.item().getArt('type')
        except:
            isOld = True

        try:
            indicators = playcount.getSeasonIndicators(items[0]['imdb'])
        except:
            pass

        traktHas = trakt.getTraktIndicatorsInfo() == True
        watchedMenu = control.lang(32068).encode(
            'utf-8') if traktHas else control.lang(32066).encode('utf-8')
        unwatchedMenu = control.lang(32069).encode(
            'utf-8') if traktHas else control.lang(32067).encode('utf-8')

        unwatchedEnabled = tools.Settings.getBoolean(
            'interface.tvshows.unwatched.enabled')
        unwatchedLimit = tools.Settings.getBoolean(
            'interface.tvshows.unwatched.limit')

        queueMenu = control.lang(32065).encode('utf-8')

        traktManagerMenu = control.lang(32070).encode('utf-8')

        media = tools.Media()

        try:
            multi = [i['tvshowtitle'] for i in items]
        except:
            multi = []
        multi = len([x for y, x in enumerate(multi) if x not in multi[:y]])
        multi = True if multi > 1 else False

        for i in items:
            try:
                label = None
                try:
                    label = media.title(tools.Media.TypeSeason,
                                        season=i['season'])
                except:
                    pass
                if label == None:
                    label = i['season']

                if multi == True and not label in i['tvshowtitle'] and not i[
                        'tvshowtitle'] in label:
                    label = '%s - %s' % (i['tvshowtitle'], label)

                systitle = sysname = urllib.quote_plus(i['tvshowtitle'])

                imdb, tvdb, year, season = i['imdb'], i['tvdb'], i['year'], i[
                    'season']

                meta = dict((k, v) for k, v in i.iteritems() if not v == '0')
                meta.update({'mediatype': 'tvshow'})
                meta.update({
                    'trailer':
                    '%s?action=trailer&name=%s' % (sysaddon, sysname)
                })

                # Bubbles
                # Remove default time, since this might mislead users. Rather show no time.
                #if not 'duration' in i: meta.update({'duration': '60'})
                #elif i['duration'] == '0': meta.update({'duration': '60'})

                try:
                    meta.update({'duration': str(int(meta['duration']) * 60)})
                except:
                    pass
                try:
                    meta.update(
                        {'genre': cleangenre.lang(meta['genre'], self.lang)})
                except:
                    pass
                try:
                    meta.update({'tvshowtitle': i['label']})
                except:
                    pass
                try:
                    # Year is the shows year, not the seasons year. Extract the correct year frpm the premier date.
                    yearNew = i['premiered']
                    yearNew = re.findall('(\d{4})', yearNew)[0]
                    yearNew = yearNew.encode('utf-8')
                    meta.update({'year': yearNew})
                except:
                    pass

                try:
                    if season in indicators:
                        meta.update({'playcount': 1, 'overlay': 7})
                        overlay = 7
                    else:
                        meta.update({'playcount': 0, 'overlay': 6})
                        overlay = 6
                except:
                    overlay = None

                url = self.parameterize(
                    '%s?action=episodes&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s&season=%s'
                    % (sysaddon, systitle, year, imdb, tvdb, season))

                cm = []

                cm.append(
                    (queueMenu, 'RunPlugin(%s?action=queueItem)' % sysaddon))

                if not traktHas:
                    link = self.parameterize(
                        '%s?action=tvPlaycount&name=%s&imdb=%s&tvdb=%s&season=%s&query=7'
                        % (sysaddon, systitle, imdb, tvdb, season))
                    cm.append((watchedMenu, 'RunPlugin(%s)' % link))

                    link = self.parameterize(
                        '%s?action=tvPlaycount&name=%s&imdb=%s&tvdb=%s&season=%s&query=6'
                        % (sysaddon, systitle, imdb, tvdb, season))
                    cm.append((unwatchedMenu, 'RunPlugin(%s)' % link))

                if traktCredentials == True:
                    link = self.parameterize(
                        '%s?action=traktManager&tvdb=%s&season=%s' %
                        (sysaddon, tvdb, season))
                    cm.append((traktManagerMenu, 'RunPlugin(%s)' % link))

                if not self.kidsOnly() and control.setting(
                        'downloads.manual.enabled') == 'true':
                    cm.append(
                        (control.lang(33585).encode('utf-8'),
                         'RunPlugin(%s?action=downloadsManager)' % (sysaddon)))

                if isOld == True:
                    cm.append(
                        (control.lang2(19033).encode('utf-8'), 'Action(Info)'))

                item = control.item(label=label)

                if unwatchedEnabled and not overlay == None and not overlay == 7:
                    try:
                        count = playcount.getSeasonCount(
                            imdb, season, unwatchedLimit)
                        if count:
                            item.setProperty('TotalEpisodes',
                                             str(count['total']))
                            item.setProperty('WatchedEpisodes',
                                             str(count['watched']))
                            item.setProperty('UnWatchedEpisodes',
                                             str(count['unwatched']))
                    except:
                        pass

                art = {}

                # First check thumbs, since they typically contains the seasons poster. The normal poster contains the show poster.
                poster = '0'
                if poster == '0' and 'poster3' in i: poster = i['thumb3']
                if poster == '0' and 'poster2' in i: poster = i['thumb2']
                if poster == '0' and 'poster' in i: poster = i['thumb']
                if poster == '0' and 'poster3' in i: poster = i['poster3']
                if poster == '0' and 'poster2' in i: poster = i['poster2']
                if poster == '0' and 'poster' in i: poster = i['poster']

                icon = '0'
                if icon == '0' and 'icon3' in i: icon = i['icon3']
                if icon == '0' and 'icon2' in i: icon = i['icon2']
                if icon == '0' and 'icon' in i: icon = i['icon']

                thumb = '0'
                if thumb == '0' and 'thumb3' in i: thumb = i['thumb3']
                if thumb == '0' and 'thumb2' in i: thumb = i['thumb2']
                if thumb == '0' and 'thumb' in i: thumb = i['thumb']

                banner = '0'
                if banner == '0' and 'banner3' in i: banner = i['banner3']
                if banner == '0' and 'banner2' in i: banner = i['banner2']
                if banner == '0' and 'banner' in i: banner = i['banner']

                fanart = '0'
                if settingFanart:
                    if fanart == '0' and 'fanart3' in i: fanart = i['fanart3']
                    if fanart == '0' and 'fanart2' in i: fanart = i['fanart2']
                    if fanart == '0' and 'fanart' in i: fanart = i['fanart']

                clearlogo = '0'
                if clearlogo == '0' and 'clearlogo' in i:
                    clearlogo = i['clearlogo']

                clearart = '0'
                if clearart == '0' and 'clearart' in i:
                    clearart = i['clearart']

                if poster == '0': poster = addonPoster
                if icon == '0': icon = poster
                if thumb == '0': thumb = poster
                if banner == '0': banner = addonBanner
                if fanart == '0': fanart = addonFanart

                if not poster == '0' and not poster == None:
                    art.update({
                        'poster': poster,
                        'tvshow.poster': poster,
                        'season.poster': poster
                    })
                if not icon == '0' and not icon == None:
                    art.update({'icon': icon})
                if not thumb == '0' and not thumb == None:
                    art.update({'thumb': thumb})
                if not banner == '0' and not banner == None:
                    art.update({'banner': banner})
                if not clearlogo == '0' and not clearlogo == None:
                    art.update({'clearlogo': clearlogo})
                if not clearart == '0' and not clearart == None:
                    art.update({'clearart': clearart})
                if not fanart == '0' and not fanart == None:
                    item.setProperty('Fanart_Image', fanart)

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

                control.addItem(handle=syshandle,
                                url=url,
                                listitem=item,
                                isFolder=True)
            except:
                pass

        try:
            control.property(syshandle, 'showplot', items[0]['plot'])
        except:
            pass

        control.content(syshandle, 'seasons')
        control.directory(syshandle, cacheToDisc=True)
        views.setView('seasons', {'skin.estuary': 55, 'skin.confluence': 500})
예제 #7
0
    def seasonDirectory(self, items):
        from sys import argv  # some functions like ActivateWindow() throw invalid handle less this is imported here.
        if not items:  # with reuselanguageinvoker on an empty directory must be loaded, do not use sys.exit()
            control.hide()
            control.notification(title=32054, message=33049)
        sysaddon, syshandle = argv[0], int(argv[1])
        is_widget = 'plugin' not in control.infoLabel('Container.PluginName')
        settingFanart = getSetting('fanart') == 'true'
        addonPoster, addonFanart, addonBanner = control.addonPoster(
        ), control.addonFanart(), control.addonBanner()
        try:
            indicators = getSeasonIndicators(
                items[0]['imdb'])  # refresh not needed now due to service sync
        except:
            indicators = None
        if trakt.getTraktIndicatorsInfo():
            watchedMenu, unwatchedMenu = getLS(32068), getLS(32069)
        else:
            watchedMenu, unwatchedMenu = getLS(32066), getLS(32067)
        traktManagerMenu, queueMenu = getLS(32070), getLS(32065)
        showPlaylistMenu, clearPlaylistMenu = getLS(35517), getLS(35516)
        labelMenu, playRandom = getLS(32055), getLS(32535)
        addToLibrary = getLS(32551)
        try:
            multi = [i['tvshowtitle'] for i in items]
        except:
            multi = []
        multi = True if len(
            [x for y, x in enumerate(multi)
             if x not in multi[:y]]) > 1 else False
        for i in items:
            try:
                title, imdb, tmdb, tvdb, year, season = i.get(
                    'tvshowtitle'), i.get('imdb',
                                          ''), i.get('tmdb', ''), i.get(
                                              'tvdb',
                                              ''), i.get('year',
                                                         ''), i.get('season')
                label = '%s %s' % (labelMenu, season)
                try:
                    if i['unaired'] == 'true':
                        label = '[COLOR %s][I]%s[/I][/COLOR]' % (
                            self.unairedcolor, label)
                except:
                    pass
                systitle = quote_plus(title)
                meta = dict((k, v) for k, v in iter(i.items())
                            if v is not None and v != '')
                # setting mediatype to "season" causes "Infomation" and "play trailer" to not be available in some skins
                meta.update(
                    {
                        'code': imdb,
                        'imdbnumber': imdb,
                        'mediatype': 'tvshow',
                        'tag': [imdb, tmdb]
                    }
                )  # "tag" and "tagline" for movies only, but works in my skin mod so leave
                try:
                    meta.update(
                        {'genre': cleangenre.lang(meta['genre'], self.lang)})
                except:
                    pass

                poster = meta.get(
                    'tvshow.poster') or addonPoster  # tvshow.poster
                if self.prefer_tmdbArt:
                    season_poster = meta.get('season_poster') or meta.get(
                        'season_poster2') or poster
                else:
                    season_poster = meta.get('season_poster2') or meta.get(
                        'season_poster') or poster
                fanart = ''
                if settingFanart: fanart = meta.get('fanart') or addonFanart
                icon = meta.get('icon') or poster
                banner = meta.get('banner') or addonBanner
                art = {}
                art.update({
                    'poster': season_poster,
                    'tvshow.poster': poster,
                    'season.poster': season_poster,
                    'fanart': fanart,
                    'icon': icon,
                    'thumb': season_poster,
                    'banner': banner,
                    'clearlogo': meta.get('clearlogo', ''),
                    'tvshow.clearlogo': meta.get('clearlogo', ''),
                    'clearart': meta.get('clearart', ''),
                    'tvshow.clearart': meta.get('clearart', ''),
                    'landscape': meta.get('landscape')
                })
                # for k in ('poster2', 'poster3', 'fanart2', 'fanart3', 'banner2', 'banner3'): meta.pop(k, None)
                meta.update({
                    'poster': poster,
                    'fanart': fanart,
                    'banner': banner,
                    'thumb': season_poster,
                    'season_poster': season_poster,
                    'icon': icon
                })
                ####-Context Menu and Overlays-####
                cm = []
                try:
                    overlay = int(
                        getSeasonOverlay(indicators, imdb, tvdb, season))
                    watched = (overlay == 5)
                    if self.traktCredentials:
                        cm.append((
                            traktManagerMenu,
                            'RunPlugin(%s?action=tools_traktManager&name=%s&imdb=%s&tvdb=%s&season=%s&watched=%s)'
                            %
                            (sysaddon, systitle, imdb, tvdb, season, watched)))
                    if watched:
                        meta.update({'playcount': 1, 'overlay': 5})
                        cm.append((
                            unwatchedMenu,
                            'RunPlugin(%s?action=playcount_TVShow&name=%s&imdb=%s&tvdb=%s&season=%s&query=4)'
                            % (sysaddon, systitle, imdb, tvdb, season)))
                    else:
                        meta.update({'playcount': 0, 'overlay': 4})
                        cm.append((
                            watchedMenu,
                            'RunPlugin(%s?action=playcount_TVShow&name=%s&imdb=%s&tvdb=%s&season=%s&query=5)'
                            % (sysaddon, systitle, imdb, tvdb, season)))
                except:
                    pass
                sysmeta = quote_plus(jsdumps(meta))
                cm.append((
                    playRandom,
                    'RunPlugin(%s?action=play_Random&rtype=episode&tvshowtitle=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s&meta=%s&season=%s)'
                    % (sysaddon, systitle, year, imdb, tmdb, tvdb, sysmeta,
                       season)))
                cm.append((queueMenu,
                           'RunPlugin(%s?action=playlist_QueueItem&name=%s)' %
                           (sysaddon, systitle)))
                cm.append((showPlaylistMenu,
                           'RunPlugin(%s?action=playlist_Show)' % sysaddon))
                cm.append((clearPlaylistMenu,
                           'RunPlugin(%s?action=playlist_Clear)' % sysaddon))
                cm.append((
                    addToLibrary,
                    'RunPlugin(%s?action=library_tvshowToLibrary&tvshowtitle=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s)'
                    % (sysaddon, systitle, year, imdb, tmdb, tvdb)))
                cm.append(
                    ('[COLOR red]Venom Settings[/COLOR]',
                     'RunPlugin(%s?action=tools_openSettings)' % sysaddon))
                ####################################
                url = '%s?action=episodes&tvshowtitle=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s&meta=%s&season=%s' % (
                    sysaddon, systitle, year, imdb, tmdb, tvdb, sysmeta,
                    season)
                item = control.item(label=label, offscreen=True)
                if 'castandart' in i: item.setCast(i['castandart'])
                item.setArt(art)
                try:
                    count = getSeasonCount(imdb, season)
                    if count:
                        item.setProperties({
                            'WatchedEpisodes':
                            str(count['watched']),
                            'UnWatchedEpisodes':
                            str(count['unwatched'])
                        })
                        item.setProperties({
                            'TotalSeasons':
                            str(meta.get('total_seasons', '')),
                            'TotalEpisodes':
                            str(count['total'])
                        })
                    else:
                        if meta.get('status') != 'Returning Series' or (
                                meta.get('status') == 'Returning Series'
                                and meta.get('last_episode_to_air', {}).get(
                                    'season_number') > int(season)):
                            item.setProperties({
                                'WatchedEpisodes':
                                '0',
                                'UnWatchedEpisodes':
                                str(
                                    meta.get('counts',
                                             {}).get(str(season), ''))
                            })
                            item.setProperties({
                                'TotalSeasons':
                                str(meta.get('total_seasons', '')),
                                'TotalEpisodes':
                                str(meta.get('total_episodes', ''))
                            })
                        else:
                            if meta.get(
                                    'last_episode_to_air',
                                {}).get('season_number') == int(season):
                                item.setProperties({
                                    'WatchedEpisodes':
                                    '0',
                                    'UnWatchedEpisodes':
                                    str(
                                        meta.get('last_episode_to_air',
                                                 {}).get('episode_number'))
                                })
                                item.setProperties({
                                    'TotalSeasons':
                                    str(meta.get('total_seasons', '')),
                                    'TotalEpisodes':
                                    str(
                                        meta.get('last_episode_to_air',
                                                 {}).get('episode_number'))
                                })
                            else:
                                item.setProperties({
                                    'WatchedEpisodes': '0',
                                    'UnWatchedEpisodes': '0'
                                })
                                item.setProperties({
                                    'TotalSeasons':
                                    str(meta.get('total_seasons', '')),
                                    'TotalEpisodes':
                                    '0'
                                })
                except:
                    pass
                if is_widget: item.setProperty('isVenom_widget', 'true')
                try:  # Year is the shows year, not the seasons year. Extract year from premier date for InfoLabels to have "season_year".
                    season_year = re.findall(r'(\d{4})',
                                             i.get('premiered', ''))[0]
                    meta.update({'year': season_year})
                except:
                    pass
                item.setUniqueIDs({'imdb': imdb, 'tmdb': tmdb, 'tvdb': tvdb})
                item.setProperty('IsPlayable', 'false')
                item.setInfo(type='video',
                             infoLabels=control.metadataClean(meta))
                item.addContextMenuItems(cm)
                control.addItem(handle=syshandle,
                                url=url,
                                listitem=item,
                                isFolder=True)
            except:
                from resources.lib.modules import log_utils
                log_utils.error()
        try:
            control.property(syshandle, 'showplot', items[0]['plot'])
        except:
            pass
        control.content(syshandle, 'seasons')
        control.directory(
            syshandle, cacheToDisc=False
        )  # disable cacheToDisc so unwatched counts loads fresh data counts if changes made
        views.setView('seasons', {'skin.estuary': 55, 'skin.confluence': 500})
예제 #8
0
	def seasonDirectory(self, items):
		if items == None or len(items) == 0: control.idle() ; sys.exit()

		sysaddon = sys.argv[0]

		syshandle = int(sys.argv[1])

		addonPoster, addonBanner = control.addonPoster(), control.addonBanner()

		addonFanart, settingFanart = control.addonFanart(), tools.Settings.getBoolean('interface.fanart')

		traktCredentials = trakt.getTraktCredentialsInfo()

		try: isOld = False ; control.item().getArt('type')
		except: isOld = True

		try: indicators = playcount.getSeasonIndicators(items[0]['imdb'])
		except: pass

		traktHas = trakt.getTraktIndicatorsInfo() == True
		watchedMenu = control.lang(32068).encode('utf-8') if traktHas else control.lang(32066).encode('utf-8')
		unwatchedMenu = control.lang(32069).encode('utf-8') if traktHas else control.lang(32067).encode('utf-8')

		unwatchedEnabled = tools.Settings.getBoolean('interface.tvshows.unwatched.enabled')
		unwatchedLimit = tools.Settings.getBoolean('interface.tvshows.unwatched.limit')

		queueMenu = control.lang(32065).encode('utf-8')

		traktManagerMenu = control.lang(32070).encode('utf-8')

		media = tools.Media()

		try: multi = [i['tvshowtitle'] for i in items]
		except: multi = []
		multi = len([x for y,x in enumerate(multi) if x not in multi[:y]])
		multi = True if multi > 1 else False

		for i in items:
			try:
				label = None
				try:
					label = media.title(tools.Media.TypeSeason, season = i['season'])
				except: pass
				if label == None:
					label = i['season']

				if multi == True and not label in i['tvshowtitle'] and not i['tvshowtitle'] in label:
					label = '%s - %s' % (i['tvshowtitle'], label)

				systitle = sysname = urllib.quote_plus(i['tvshowtitle'])

				imdb, tvdb, year, season = i['imdb'], i['tvdb'], i['year'], i['season']

				meta = dict((k,v) for k, v in i.iteritems() if not v == '0')
				meta.update({'mediatype': 'tvshow'})
				meta.update({'trailer': '%s?action=trailer&name=%s' % (sysaddon, sysname)})

				# Bubbles
				# Remove default time, since this might mislead users. Rather show no time.
				#if not 'duration' in i: meta.update({'duration': '60'})
				#elif i['duration'] == '0': meta.update({'duration': '60'})

				try: meta.update({'duration': str(int(meta['duration']) * 60)})
				except: pass
				try: meta.update({'genre': cleangenre.lang(meta['genre'], self.lang)})
				except: pass
				try: meta.update({'tvshowtitle': i['label']})
				except: pass
				try:
					# Year is the shows year, not the seasons year. Extract the correct year frpm the premier date.
					yearNew = i['premiered']
					yearNew = re.findall('(\d{4})', yearNew)[0]
					yearNew = yearNew.encode('utf-8')
					meta.update({'year': yearNew})
				except:
					pass

				try:
					if season in indicators:
						meta.update({'playcount': 1, 'overlay': 7})
						overlay = 7
					else:
						meta.update({'playcount': 0, 'overlay': 6})
						overlay = 6
				except:
					overlay = None


				url = self.parameterize('%s?action=episodes&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s&season=%s' % (sysaddon, systitle, year, imdb, tvdb, season))


				cm = []

				cm.append((queueMenu, 'RunPlugin(%s?action=queueItem)' % sysaddon))

				if not traktHas:
					link = self.parameterize('%s?action=tvPlaycount&name=%s&imdb=%s&tvdb=%s&season=%s&query=7' % (sysaddon, systitle, imdb, tvdb, season))
					cm.append((watchedMenu, 'RunPlugin(%s)' % link))

					link = self.parameterize('%s?action=tvPlaycount&name=%s&imdb=%s&tvdb=%s&season=%s&query=6' % (sysaddon, systitle, imdb, tvdb, season))
					cm.append((unwatchedMenu, 'RunPlugin(%s)' % link))

				if traktCredentials == True:
					link = self.parameterize('%s?action=traktManager&tvdb=%s&season=%s' % (sysaddon, tvdb, season))
					cm.append((traktManagerMenu, 'RunPlugin(%s)' % link))

				if not self.kidsOnly() and control.setting('downloads.manual.enabled') == 'true':
					cm.append((control.lang(33585).encode('utf-8'), 'RunPlugin(%s?action=downloadsManager)' % (sysaddon)))

				if isOld == True:
					cm.append((control.lang2(19033).encode('utf-8'), 'Action(Info)'))


				item = control.item(label=label)

				if unwatchedEnabled and not overlay == None and not overlay == 7:
					try:
						count = playcount.getSeasonCount(imdb, season, unwatchedLimit)
						if count:
							item.setProperty('TotalEpisodes', str(count['total']))
							item.setProperty('WatchedEpisodes', str(count['watched']))
							item.setProperty('UnWatchedEpisodes', str(count['unwatched']))
					except:
						pass

				art = {}

				# First check thumbs, since they typically contains the seasons poster. The normal poster contains the show poster.
				poster = '0'
				if poster == '0' and 'poster3' in i: poster = i['thumb3']
				if poster == '0' and 'poster2' in i: poster = i['thumb2']
				if poster == '0' and 'poster' in i: poster = i['thumb']
				if poster == '0' and 'poster3' in i: poster = i['poster3']
				if poster == '0' and 'poster2' in i: poster = i['poster2']
				if poster == '0' and 'poster' in i: poster = i['poster']

				icon = '0'
				if icon == '0' and 'icon3' in i: icon = i['icon3']
				if icon == '0' and 'icon2' in i: icon = i['icon2']
				if icon == '0' and 'icon' in i: icon = i['icon']

				thumb = '0'
				if thumb == '0' and 'thumb3' in i: thumb = i['thumb3']
				if thumb == '0' and 'thumb2' in i: thumb = i['thumb2']
				if thumb == '0' and 'thumb' in i: thumb = i['thumb']

				banner = '0'
				if banner == '0' and 'banner3' in i: banner = i['banner3']
				if banner == '0' and 'banner2' in i: banner = i['banner2']
				if banner == '0' and 'banner' in i: banner = i['banner']

				fanart = '0'
				if settingFanart:
					if fanart == '0' and 'fanart3' in i: fanart = i['fanart3']
					if fanart == '0' and 'fanart2' in i: fanart = i['fanart2']
					if fanart == '0' and 'fanart' in i: fanart = i['fanart']

				clearlogo = '0'
				if clearlogo == '0' and 'clearlogo' in i: clearlogo = i['clearlogo']

				clearart = '0'
				if clearart == '0' and 'clearart' in i: clearart = i['clearart']

				if poster == '0': poster = addonPoster
				if icon == '0': icon = poster
				if thumb == '0': thumb = poster
				if banner == '0': banner = addonBanner
				if fanart == '0': fanart = addonFanart

				if not poster == '0' and not poster == None: art.update({'poster' : poster, 'tvshow.poster' : poster, 'season.poster' : poster})
				if not icon == '0' and not icon == None: art.update({'icon' : icon})
				if not thumb == '0' and not thumb == None: art.update({'thumb' : thumb})
				if not banner == '0' and not banner == None: art.update({'banner' : banner})
				if not clearlogo == '0' and not clearlogo == None: art.update({'clearlogo' : clearlogo})
				if not clearart == '0' and not clearart == None: art.update({'clearart' : clearart})
				if not fanart == '0' and not fanart == None: item.setProperty('Fanart_Image', fanart)

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

				control.addItem(handle=syshandle, url=url, listitem=item, isFolder=True)
			except:
				pass

		try: control.property(syshandle, 'showplot', items[0]['plot'])
		except: pass

		control.content(syshandle, 'seasons')
		control.directory(syshandle, cacheToDisc=True)
		views.setView('seasons', {'skin.estuary': 55, 'skin.confluence': 500})