Пример #1
0
	def groupDirectory(self, items):
		if items == None or len(items) == 0:
			interface.Loader.hide()
			interface.Dialog.notification(title = 32007, message = 33049, icon = interface.Dialog.IconInformation)
			sys.exit()

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

		for i in items:
			try:
				name = i
				url = self.parameterize('%s?action=channelsRetrieve&group=%s' % (sysaddon, name.lower()))

				item = control.item(label = name.replace(' ', '').upper())

				iconIcon, iconThumb, iconPoster, iconBanner = interface.Icon.pathAll(icon = 'networks.png', default = 'DefaultNetwork.png')
				item.setArt({'icon': iconIcon, 'thumb': iconThumb, 'poster': iconPoster, 'banner': iconBanner})
				if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart)

				item.addContextMenuItems([interface.Context(mode = interface.Context.ModeGeneric, type = self.type, kids = self.kids, link = url, title = name, create = True).menu()])
				control.addItem(handle = syshandle, url = url, listitem = item, isFolder = True)
			except:
				pass

		control.content(syshandle, 'files')
		control.directory(syshandle, cacheToDisc = True)
Пример #2
0
	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})
Пример #3
0
    def channelDirectory(self, items):
        if items == None or len(items) == 0:
            interface.Loader.hide()
            interface.Dialog.notification(
                title=32007,
                message=33049,
                icon=interface.Dialog.IconInformation)
            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.theme.fanart')

        indicators = playcount.getMovieIndicators()
        isPlayable = 'true' if not 'plugin' in control.infoLabel(
            'Container.PluginName') else 'false'
        ratingsOwn = tools.Settings.getInteger('interface.ratings.type') == 1
        context = interface.Context.enabled()

        for i in items:
            try:
                title = i['title']
                imdb, tmdb, year = i['imdb'], i['tmdb'], i['year']
                label = '[B]%s[/B][CR]%s (%s)' % (i['channel'].upper(), title,
                                                  year)
                name = '%s (%s)' % (title, year)
                sysname = urllib.quote_plus(name)
                systitle = urllib.quote_plus(title)

                meta = dict((k, v) for k, v in i.iteritems() if not v == '0')
                meta.update({'mediatype': 'movie'})
                meta.update({
                    'trailer':
                    self.parameterize(
                        '%s?action=streamsVideo&video=trailer&title=%s&year=%s&imdb=%s'
                        % (sysaddon, systitle, year, imdb))
                })
                meta.update({'playcount': 0, 'overlay': 6})
                try:
                    meta.update(
                        {'genre': cleangenre.lang(meta['genre'], self.lang)})
                except:
                    pass

                # 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

                sysmeta = urllib.quote_plus(json.dumps(meta))
                url = self.parameterize(
                    '%s?action=scrape&title=%s&year=%s&imdb=%s&metadata=%s' %
                    (sysaddon, systitle, year, imdb, sysmeta))

                meta.update(
                    tools.Rater.extract(meta)
                )  # Update again, in case the old metadata was retrieved from cache, but the settings changed.

                watched = int(playcount.getMovieOverlay(indicators, imdb)) == 7
                if watched: meta.update({'playcount': 1, 'overlay': 7})
                else: meta.update({'playcount': 0, 'overlay': 6})
                meta.update(
                    {'watched': int(watched)}
                )  # Kodi's documentation says this value is deprecate. However, without this value, Kodi adds the watched checkmark over the remaining episode count.

                item = control.item(label=label)

                poster = '0'
                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})
                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.setProperty('IsPlayable', isPlayable)
                item.setInfo(type='Video',
                             infoLabels=tools.Media.metadataClean(meta))
                if context:
                    item.addContextMenuItems([
                        interface.Context(mode=interface.Context.ModeItem,
                                          type=self.type,
                                          kids=self.kids,
                                          create=True,
                                          queue=True,
                                          watched=watched,
                                          refresh=True,
                                          metadata=meta,
                                          art=art,
                                          label=label,
                                          link=url,
                                          title=title,
                                          year=year,
                                          imdb=imdb,
                                          tmdb=tmdb).menu()
                    ])
                control.addItem(handle=syshandle,
                                url=url,
                                listitem=item,
                                isFolder=False)
            except:
                pass

        control.content(syshandle, 'files')
        control.directory(syshandle, cacheToDisc=True)