def addDirectoryItem(self, name, query, thumb, icon, context=None, isAction=True, isFolder=True): try: name = control.lang(name).encode('utf-8') except: pass url = '%s?action=%s' % (sysaddon, query) if isAction == True else query if not 'http' in thumb: thumb = os.path.join(artPath, thumb) if not artPath == None else icon cm = [] if not context == None: cm.append((control.lang(context[0]).encode('utf-8'), 'RunPlugin(%s?action=%s)' % (sysaddon, context[1]))) item = control.item(label=name, iconImage=thumb, thumbnailImage=thumb) item.addContextMenuItems(cm, replaceItems=False) if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=isFolder)
def addDirectory(self, items): if items == None or len(items) == 0: return sysaddon = sys.argv[0] addonFanart = control.addonFanart() addonThumb = control.addonThumb() artPath = control.artPath() for i in items: try: try: name = control.lang(i['name']).encode('utf-8') except: name = i['name'] if not artPath == None: thumb = os.path.join(artPath, i['image']) else: thumb = addonThumb url = '%s?action=%s' % (sysaddon, i['action']) try: url += '&url=%s' % urllib.quote_plus(i['url']) except: pass item = control.item(label=name, iconImage=thumb, thumbnailImage=thumb) item.addContextMenuItems([], replaceItems=False) if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=True) except: pass control.directory(int(sys.argv[1]), cacheToDisc=True)
def addCategoryItem(name, action, image, isFolder=True): u = sys.argv[0]+"?action="+str(action) image = control.addonInfo('path') + '/art/' + image item = control.item(name, iconImage=image, thumbnailImage=image) item.addContextMenuItems([], replaceItems=False) item.setProperty('Fanart_Image', control.addonInfo('fanart')) control.addItem(handle=int(sys.argv[1]),url=u,listitem=item,isFolder=isFolder)
def views(self): try: control.idle() items = [(control.lang(32001).encode('utf-8'), 'movies'), (control.lang(32002).encode('utf-8'), 'tvshows'), (control.lang(32054).encode('utf-8'), 'seasons'), (control.lang(32038).encode('utf-8'), 'episodes')] select = control.selectDialog([i[0] for i in items], control.lang(32049).encode('utf-8')) if select == -1: return content = items[select][1] title = control.lang(32059).encode('utf-8') url = '%s?action=addView&content=%s' % (sys.argv[0], content) poster, banner, fanart = control.addonPoster(), control.addonBanner(), control.addonFanart() item = control.item(label=title) item.setInfo(type='Video', infoLabels={'title': title}) item.setArt({'icon': poster, 'thumb': poster, 'poster': poster, 'banner': banner}) item.setProperty('Fanart_Image', fanart) control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=False) control.content(int(sys.argv[1]), content) control.directory(int(sys.argv[1]), cacheToDisc=True) from resources.lib.libraries import views views.setView(content, {}) except: return
def addDirectory(self, items): if items == None or len(items) == 0: return sysaddon = sys.argv[0] addonFanart = control.addonFanart() addonThumb = control.addonThumb() artPath = control.artPath() for i in items: try: try: name = control.lang(i['name']).encode('utf-8') except: name = i['name'] if i['image'].startswith('http://'): thumb = i['image'] elif not artPath == None: thumb = os.path.join(artPath, i['image']) else: thumb = addonThumb url = '%s?action=%s' % (sysaddon, i['action']) try: url += '&url=%s' % urllib.quote_plus(i['url']) except: pass cm = [] #try: cm.append((control.lang(30239).encode('utf-8'), 'RunPlugin(%s?action=tvshowsToLibrary&url=%s)' % (sysaddon, urllib.quote_plus(i['context'])))) #except: pass item = control.item(label=name, iconImage=thumb, thumbnailImage=thumb) item.addContextMenuItems(cm, replaceItems=False) if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=True) except: pass views.setView('tvshows', {'skin.confluence': control.viewMode['mediainfo1']}) control.directory(int(sys.argv[1]), cacheToDisc=True)
def addDirectoryItem(name, action, thumb, image, fanart, url='0'): if thumb == '0': thumb = image u = '%s?action=%s&url=%s&image=%s&fanart=%s' % (sys.argv[0], str(action), urllib.quote_plus(url), urllib.quote_plus(thumb), urllib.quote_plus(fanart)) item = control.item(name, iconImage=thumb, thumbnailImage=thumb) item.addContextMenuItems([], replaceItems=False) item.setProperty('Fanart_Image', fanart) control.addItem(handle=int(sys.argv[1]),url=u,listitem=item,isFolder=True)
def listEpisodes(self, showid, page, image): url = self.episodes_link % (showid) try: result = client.request(url) except: pass result = re.compile('(.+?)]').findall(result)[0] + ']' shows = json.loads(result) self.list.append({'name': '[UPPERCASE][COLOR orange]Try again if a show does not play![/COLOR][/UPPERCASE]', 'url': '', 'image': ''}) # episodes per page for show in shows: if 'Not Show' == show['item_title']: continue name = show['date_added'] + ' ' + show['item_title'] u = self.player_link % (show['media_id'], show['media_item_id']) self.list.append({'name': name, 'url': urllib.quote_plus(u), 'image': image}) for episode in self.list: name = episode['name'] url = episode['url'] image = episode['image'] action = 'sourcePage2' query = '?action=%s&image=%s&url=%s&name=%s' % (action, image, url, name) url = '%s%s' % (sysaddon, query) item = control.item(name, iconImage=image, thumbnailImage=image) if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) item.setInfo(type="Video", infoLabels={"Title": name, "OriginalTitle": name}) control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=False) control.content(int(sys.argv[1]), 'movies') if control.skin == 'skin.confluence': control.execute('Container.SetViewMode(50)') control.directory(int(sys.argv[1]), cacheToDisc=True)
def listShows(self, catid, page): limatch = [] url = self.shows_link % (catid) try: result = client.request(url) except: pass pageContent = ''.join(result.splitlines()).replace('\'','"') pages = re.compile('id="a_page_(.+?)" href').findall(pageContent) if str(page) in pages: pageUrl = self.shows_ajax_link % (catid, str(page)) result = client.request(pageUrl) limatch+=re.compile('<figure>(.+?)</a></li>').findall(result) for li_content in limatch: show = re.compile('<a href=".+?id=(.+?)"><img src="(.+?)" alt="(.+?)" w').findall(li_content) #print show title = show[0][2].decode('iso-8859-11') showid = show[0][0] image = show[0][1] self.list.append({'name': title, 'showid': showid, 'image': image}) for show in self.list: name = show['name'].encode('utf-8') showid = show['showid'] image = show['image'] action = 'listEpisodes' query = '?action=%s&name=%s&catid=%s&showid=%s&image=%s' % (action, name, catid, showid, image) url = '%s%s' % (sysaddon, query) item = control.item(name, iconImage=image, thumbnailImage=image) if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) item.setInfo(type="Video", infoLabels={"Title": name, "OriginalTitle": name}) control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=True) nextPage = int(page) + 1 if nextPage <= len(pages): if 'first' in pages: pages.remove('first') if 'pre' in pages: pages.remove('pre') if 'next' in pages: pages.remove('next') if 'last' in pages: pages.remove('last') for page in pages: action = 'listShows' pageNumber = int(page) + 1 query = '?action=%s&page=%d&name=%s&catid=%s' % (action, int(page), 'Page ' + str(pageNumber), catid) url = '%s%s' % (sysaddon, query) item = control.item('Page ' + str(pageNumber), iconImage='', thumbnailImage='') if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) item.setInfo(type="Video", infoLabels={"Title": 'Page ' + str(pageNumber), "OriginalTitle": 'Page ' + str(pageNumber)}) control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=True) control.content(int(sys.argv[1]), 'movies') if control.skin == 'skin.confluence': control.execute('Container.SetViewMode(500)') control.directory(int(sys.argv[1]), cacheToDisc=True)
def addDirectoryItem(name, url, action, image, image2, fanart, content, data, tvshow='0', totalItems=0, isFolder=True): if not str(image).lower().startswith('http'): image = control.addonInfo('icon') if not str(image2).lower().startswith('http'): image2 = control.addonInfo('icon') if not str(fanart).lower().startswith('http'): fanart = control.addonInfo('fanart') if content in ['movies', 'episodes']: playable = 'true' else: playable = 'false' sysaddon = sys.argv[0] if url.startswith('$base64'): import base64 ; url = base64.b64decode(re.compile('\$base64\[(.+?)\]$').findall(url)[0]) u = '%s?name=%s&url=%s&tvdb=&imdb=&source=GVideo&provider=Mpie&content=%s&action=playItem' % (sysaddon, urllib.quote_plus(name), urllib.quote_plus(url), str(content)) cm = [] if content == 'movies': cm.append((control.lang(30708).encode('utf-8'), 'XBMC.Action(Info)')) elif content in ['tvshows', 'seasons']: cm.append((control.lang(30709).encode('utf-8'), 'XBMC.Action(Info)')) elif content == 'episodes': cm.append((control.lang(30710).encode('utf-8'), 'XBMC.Action(Info)')) if content == 'movies' and not isFolder == True: downloadFile = name try: downloadFile = '%s (%s)' % (data['title'], data['year']) except: pass cm.append((control.lang(30722).encode('utf-8'), 'RunPlugin(%s?action=addDownload&name=%s&url=%s&image=%s)' % (sysaddon, urllib.quote_plus(downloadFile), urllib.quote_plus(url), urllib.quote_plus(image)))) elif content == 'episodes' and not isFolder == True: downloadFile = name try: downloadFile = '%s S%02dE%02d' % (data['tvshowtitle'], int(data['season']), int(data['episode'])) except: pass cm.append((control.lang(30722).encode('utf-8'), 'RunPlugin(%s?action=addDownload&name=%s&url=%s&image=%s)' % (sysaddon, urllib.quote_plus(downloadFile), urllib.quote_plus(url), urllib.quote_plus(image)))) if content == 'movies': cm.append((control.lang(30711).encode('utf-8'), 'RunPlugin(%s?action=addView&content=movies)' % sysaddon)) elif content == 'tvshows': cm.append((control.lang(30712).encode('utf-8'), 'RunPlugin(%s?action=addView&content=tvshows)' % sysaddon)) elif content == 'seasons': cm.append((control.lang(30713).encode('utf-8'), 'RunPlugin(%s?action=addView&content=seasons)' % sysaddon)) elif content == 'episodes': cm.append((control.lang(30714).encode('utf-8'), 'RunPlugin(%s?action=addView&content=episodes)' % sysaddon)) item = control.item(name, iconImage='DefaultFolder.png', thumbnailImage=image) try: item.setArt({'poster': image2, 'tvshow.poster': image2, 'season.poster': image2, 'banner': image, 'tvshow.banner': image, 'season.banner': image}) except: pass item.addContextMenuItems(cm, replaceItems=False) item.setProperty('Fanart_Image', fanart) if playable == 'true': item.setProperty('IsPlayable', 'true') item.setInfo(type='Video', infoLabels=data) control.addItem(handle=int(sys.argv[1]),url=u,listitem=item,totalItems=totalItems,isFolder=isFolder)
def channelDirectory(self, items): if items == None or len(items) == 0: return playbackMenu = control.lang(30292).encode('utf-8') if control.setting('autoplay') == 'true' else control.lang(30291).encode('utf-8') addonPoster, addonBanner = control.addonPoster(), control.addonBanner() addonFanart = control.addonFanart() sysaddon = sys.argv[0] for i in items: try: label = "[B]%s[/B] : %s" % (i['channel'].upper(), i['name']) sysname = urllib.quote_plus(i['name']) systitle = urllib.quote_plus(i['title']) imdb, tmdb, year = i['imdb'], '0', i['year'] poster, banner = i['poster'], i['poster'] if poster == '0': poster = addonPoster if banner == '0' and poster == '0': banner = addonBanner elif banner == '0': banner = poster meta = dict((k,v) for k, v in i.iteritems() if not v == '0') meta.update({'trailer': '%s?action=trailer&name=%s' % (sysaddon, sysname)}) if i['duration'] == '0': meta.update({'duration': '120'}) try: meta.update({'duration': str(int(meta['duration']) * 60)}) except: pass sysmeta = urllib.quote_plus(json.dumps(meta)) url = '%s?action=play&name=%s&title=%s&year=%s&imdb=%s&tmdb=%s&meta=%s&t=%s' % (sysaddon, sysname, systitle, year, imdb, tmdb, sysmeta, self.systime) sysurl = urllib.quote_plus(url) cm = [] cm.append((playbackMenu, 'RunPlugin(%s?action=alterSources&url=%s&meta=%s)' % (sysaddon, sysurl, sysmeta))) cm.append((control.lang(30293).encode('utf-8'), 'Action(Info)')) cm.append((control.lang(30294).encode('utf-8'), 'RunPlugin(%s?action=refresh)' % (sysaddon))) cm.append((control.lang(30295).encode('utf-8'), 'RunPlugin(%s?action=openSettings)' % (sysaddon))) cm.append((control.lang(30296).encode('utf-8'), 'RunPlugin(%s?action=openPlaylist)' % (sysaddon))) item = control.item(label=label, iconImage=poster, thumbnailImage=poster) try: item.setArt({'poster': poster, 'banner': banner}) except: pass if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) item.setInfo(type='Video', infoLabels = meta) item.setProperty('Video', 'true') #item.setProperty('IsPlayable', 'true') item.addContextMenuItems(cm, replaceItems=True) control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=False) except: pass control.content(int(sys.argv[1]), 'movies') control.directory(int(sys.argv[1]), cacheToDisc=True)
def addCategoryItem(name, action, image, isFolder=True): u = '%s?action=%s' % (sys.argv[0], str(action)) image = control.addonInfo('path') + '/resources/media/phstreams/' + image item = control.item(name, iconImage=image, thumbnailImage=image) item.addContextMenuItems([], replaceItems=False) item.setProperty('Fanart_Image', control.addonInfo('fanart')) control.addItem(handle=int(sys.argv[1]), url=u, listitem=item, isFolder=isFolder)
def addDirectoryItem(self, name, query, thumb, icon, context=None, isAction=True, isFolder=True): try: name = control.lang(name).encode('utf-8') except: pass url = '%s?action=%s' % (sysaddon, query) if isAction == True else query thumb = os.path.join(artPath, thumb) if not artPath == None else icon cm = [] if not context == None: cm.append((control.lang(context[0]).encode('utf-8'), 'RunPlugin(%s?action=%s)' % (sysaddon, context[1]))) item = control.item(label=name, iconImage=thumb, thumbnailImage=thumb) item.addContextMenuItems(cm, replaceItems=False) if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=isFolder)
def addDirectoryItem(name, url, action, image, fanart, isFolder=True): if image == '0': image = addonIcon if fanart == '0': fanart = addonFanart u = '%s?name=%s&url=%s&image=%s&fanart=%s&action=%s' % (sys.argv[0], urllib.quote_plus(name), urllib.quote_plus(url), urllib.quote_plus(image), urllib.quote_plus(fanart), str(action)) item = control.item(name, iconImage=image, thumbnailImage=image) item.setInfo(type='Video', infoLabels = {'title': name}) item.addContextMenuItems([], replaceItems=False) item.setProperty('Fanart_Image', fanart) if not isFolder == True: item.setProperty('IsPlayable', 'true') control.addItem(handle=int(sys.argv[1]),url=u,listitem=item,isFolder=isFolder)
def addDirectoryItem(name, action, thumb, image, fanart, url='0'): if thumb == '0': thumb = image u = '%s?action=%s&url=%s&image=%s&fanart=%s' % ( sys.argv[0], str(action), urllib.quote_plus(url), urllib.quote_plus(thumb), urllib.quote_plus(fanart)) item = control.item(name, iconImage=thumb, thumbnailImage=thumb) item.addContextMenuItems([], replaceItems=False) item.setProperty('Fanart_Image', fanart) control.addItem(handle=int(sys.argv[1]), url=u, listitem=item, isFolder=True)
def channelDirectory(self, items): if items == None or len(items) == 0: return addonPoster, addonBanner = control.addonPoster(), control.addonBanner() addonFanart = control.addonFanart() sysaddon = sys.argv[0] for i in items: try: label = "%s" % (i['name']) sysname = urllib.quote_plus(i['name']) poster, banner, direct = i['poster'], i['poster'], i['direct'] try :provider=i['provider'] except:provider=None if poster == '0': poster = addonPoster if banner == '0' and poster == '0': banner = addonBanner elif banner == '0': banner = poster url = i['url'] if not direct: content = 'live' meta = {"poster":poster, "iconImage":poster} source = {"provider":provider, "url":url, "quality":'HD', "label":'Resolving %s' % label, "source":provider, "meta":json.dumps(meta)} syssource = urllib.quote_plus(json.dumps([source])) url = 'action=playItem&content=%s&name=%s&source=%s' % (content, sysname, syssource) url = '%s?%s' % (sysaddon, url) item = control.item(label=label, iconImage=poster, thumbnailImage=poster) try: item.setArt({'poster': poster, 'banner': banner}) except: pass if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) item.setProperty('Video', 'true') item.setProperty("IsPlayable", "true") item.addContextMenuItems([], replaceItems=True) control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=False) except: pass control.content(int(sys.argv[1]), 'video') control.directory(int(sys.argv[1]), cacheToDisc=False) views.setView('movies', {'skin.confluence': 500})
def addSimpleDirectory(self, items): if not items: return sysaddon = sys.argv[0] handle = int(sys.argv[1]) thumb = control.addonThumb() for i in items: query = i['title'] url = '%s?action=tvSearch&query=%s' % (sysaddon, urllib.quote_plus(query)) item = control.item(label=query, iconImage=thumb, thumbnailImage=thumb) control.addItem(handle=handle, url=url, listitem=item, isFolder=True) control.directory(handle, cacheToDisc=True)
def addCategoryItem(name, action, image, fanart, url='0'): u = '%s?action=%s&url=%s&image=%s&fanart=%s' % ( sys.argv[0], str(action), urllib.quote_plus(url), urllib.quote_plus(image), urllib.quote_plus(fanart)) item = control.item(name, iconImage=mediaPath + image, thumbnailImage=mediaPath + image) item.addContextMenuItems([], replaceItems=False) item.setProperty('Fanart_Image', mediaPath + fanart) control.addItem(handle=int(sys.argv[1]), url=u, listitem=item, isFolder=True)
def listBollywood(self, url, page): try: html = client.request(url + 'page/' + str(page)) except: pass result = client.parseDOM(html, 'article', attrs={'id': 'posts'}) result = [(client.parseDOM(i, 'a', ret='href'), client.parseDOM(i, 'img', ret='src'), client.parseDOM(i, 'a')) for i in result] result = [(i[0][0], i[1][0], i[2][1]) for i in result if len(i[0]) > 0 and len(i[1]) > 0 and len(i[2][1]) > 0] for movie in result: uri = movie[0] image = movie[1] name = movie[2] action = 'resolveBollywoodUrl' query = '%s?action=%s&name=%s&url=%s&image=%s' % (sysaddon, action, name, uri, image) item = control.item(name, iconImage=image, thumbnailImage=image) item.setInfo(type="Video", infoLabels={ "Title": name, "OriginalTitle": name }) control.addItem(handle=int(sys.argv[1]), url=query, listitem=item, isFolder=True) pageNum = int(page) + 1 query = '%s?action=%s&url=%s&page=%s' % (sysaddon, 'listBollywood', url, pageNum) print query item = control.item('Next page', iconImage='', thumbnailImage='') item.setInfo(type="Video", infoLabels={ "Title": 'Page ' + str(page), "OriginalTitle": 'Page ' + str(page) }) control.addItem(handle=int(sys.argv[1]), url=query, listitem=item, isFolder=True) control.content(int(sys.argv[1]), 'movies') if control.skin == 'skin.confluence': control.execute('Container.SetViewMode(500)') control.directory(int(sys.argv[1]), cacheToDisc=True)
def addDirectoryItem(name, url, thumb, image, fanart): if not thumb == '0': image = thumb u = '%s?action=radioResolve&name=%s&url=%s&image=%s&fanart=%s' % (sys.argv[0], urllib.quote_plus(name), urllib.quote_plus(url), urllib.quote_plus(image), urllib.quote_plus(fanart)) if not image.startswith('http://'): image = mediaPath+image meta = {'title': name, 'album': name, 'artist': name, 'comment': name} item = control.item(name, iconImage=image, thumbnailImage=image) item.setInfo(type='Music', infoLabels = meta) item.addContextMenuItems([], replaceItems=False) item.setProperty('Fanart_Image', mediaPath+fanart) #item.setProperty('IsPlayable', 'true') control.addItem(handle=int(sys.argv[1]),url=u,listitem=item,isFolder=False)
def listEpisodes(self, catid, showid, page, image): url = self.episodes_link % (page, showid) try: result = client.request(url) except: pass link = ''.join(result.splitlines()).replace('\'','"') link = ''.join(link.splitlines()).replace('<i class="icon-new"></i>','') episodematch = re.compile('<table class="program-archive">(.+?)</table>').findall(link) episodes = re.compile('<a href="(.+?)" >(.+?)</a>.+?</td>\t\t\t\t\t\t\t<td> \t\t\t\t\t\t\t\t<a href="(.+?)" ><img').findall(episodematch[0]) programMeta = re.compile('<div class="program-meta">(.+?)</div>').findall(link) image = re.compile('<img src="(.+?)" alt').findall(programMeta[0])[0] # episodes per page for episode in episodes: name = episode[1].decode('iso-8859-11') u = 'http://www.seesantv.com/seesantv_2014/' + episode[0] + '&bitrate=high' self.list.append({'name': name, 'url': urllib.quote_plus(u), 'image': image}) for episode in self.list: name = episode['name'].encode('utf-8') url = episode['url'] image = episode['image'] action = 'sourcePage' query = '?action=%s&image=%s&url=%s&name=%s' % (action, image, url, urllib.quote_plus(name)) url = '%s%s' % (sysaddon, query) item = control.item(name, iconImage=image, thumbnailImage=image) if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) item.setInfo(type="Video", infoLabels={"Title": name, "OriginalTitle": name}) control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=False) # Pagination paginator = re.compile('<div class="page_list" align="center">(.+?)</ul>').findall(link)[0] pages = re.compile('>(\d+)</a>').findall(paginator) nextPage = int(page) + 1 if nextPage < len(pages): action = 'listEpisodes' query = '?action=%s&page=%d&name=%s&catid=%s&showid=%s&image=%s' % (action, nextPage, 'Next Page', catid, showid, image) url = '%s%s' % (sysaddon, query) item = control.item('Next Page', iconImage=image, thumbnailImage=image) if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) item.setInfo(type="Video", infoLabels={"Title": 'Next Page', "OriginalTitle": 'Next Page'}) control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=True) control.content(int(sys.argv[1]), 'movies') if control.skin == 'skin.confluence': control.execute('Container.SetViewMode(50)') control.directory(int(sys.argv[1]), cacheToDisc=True)
def addDirectoryItem(self, name, query, thumb, icon, context=None, queue=False, isAction=True, isFolder=True): try: name = control.lang(name).encode('utf-8') except: pass url = '%s?action=%s' % (sysaddon, query) if isAction == True else query if "http" not in thumb: thumb = os.path.join(artPath, thumb) if not artPath == None else icon cm = [] if queue == True: cm.append((queueMenu, 'RunPlugin(%s?action=queueItem)' % sysaddon)) if not context == None: cm.append( (control.lang(context[0]).encode('utf-8'), 'RunPlugin(%s?action=%s)' % (sysaddon, context[1]))) item = control.item(label=name) item.addContextMenuItems(cm) item.setArt({'icon': icon, 'thumb': thumb}) if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) control.addItem(handle=syshandle, url=url, listitem=item, isFolder=isFolder)
def downloader(): thumb = control.addonThumb() ; fanart = control.addonFanart() status = control.window.getProperty(property + '.status') if not downloadPath == '': item = control.item('[COLOR FF00b8ff]Downloads[/COLOR]', iconImage=thumb, thumbnailImage=thumb) item.addContextMenuItems([], replaceItems=True) item.setProperty('fanart_image', fanart) control.addItem(handle=int(sys.argv[1]), url=downloadPath, listitem=item, isFolder=True) if status == 'downloading': item = control.item('[COLOR red]Stop Downloads[/COLOR]', iconImage=thumb, thumbnailImage=thumb) item.addContextMenuItems([], replaceItems=True) item.setProperty('fanart_image', fanart) control.addItem(handle=int(sys.argv[1]), url=sys.argv[0]+'?mode=stopDownload', listitem=item, isFolder=True) else: item = control.item('[COLOR FF00b8ff]Start Downloads[/COLOR]', iconImage=thumb, thumbnailImage=thumb) item.addContextMenuItems([], replaceItems=True) item.setProperty('fanart_image', fanart) control.addItem(handle=int(sys.argv[1]), url=sys.argv[0]+'?mode=startDownload', listitem=item, isFolder=True) if status == 'downloading': item = control.item('[COLOR gold]Download Status[/COLOR]', iconImage=thumb, thumbnailImage=thumb) item.addContextMenuItems([], replaceItems=True) item.setProperty('Fanart_Image', fanart) control.addItem(handle=int(sys.argv[1]), url=sys.argv[0]+'?mode=statusDownload', listitem=item, isFolder=True) def download(): return [] result = cache.get(download, 600000000, table='rel_dl') for i in result: try: cm = [] cm.append(('Remove from Queue', 'RunPlugin(%s?mode=removeDownload&url=%s)' % (sys.argv[0], urllib.quote_plus(i['url'])))) item = control.item(i['name'], iconImage=i['image'], thumbnailImage=i['image']) item.addContextMenuItems(cm, replaceItems=True) item.setProperty('fanart_image', fanart) item.setProperty('Video', 'true') item.setProperty('IsPlayable', 'true') control.addItem(handle=int(sys.argv[1]), url=i['url'], listitem=item) except: pass control.directory(int(sys.argv[1]), cacheToDisc=True)
def addDirectoryItem(name, url, thumb, image, fanart): if not thumb == '0': image = thumb u = '%s?action=radioResolve&name=%s&url=%s&image=%s&fanart=%s' % ( sys.argv[0], urllib.quote_plus(name), urllib.quote_plus(url), urllib.quote_plus(image), urllib.quote_plus(fanart)) if not image.startswith('http://'): image = mediaPath + image meta = {'title': name, 'album': name, 'artist': name, 'comment': name} item = control.item(name, iconImage=image, thumbnailImage=image) item.setInfo(type='Music', infoLabels=meta) item.addContextMenuItems([], replaceItems=False) item.setProperty('Fanart_Image', mediaPath + fanart) #item.setProperty('IsPlayable', 'true') control.addItem(handle=int(sys.argv[1]), url=u, listitem=item, isFolder=False)
def listShows(self, catid, page, limit, channel): url = self.shows_link % (page, limit, channel, catid) try: result = client.request(url) except: pass data = json.loads(result) paginationInfo = data['pagination'] shows = data['data'] for show in shows: title = show['media_title'] showid = show['media_id'] image = self.cdn % (show['image_file']) self.list.append({'name': title, 'showid': showid, 'image': image}) for show in self.list: name = show['name'] showid = show['showid'] image = show['image'] action = 'listEpisodes2' query = '?action=%s&name=%s&showid=%s&image=%s&page=1' % (action, name, showid, image) url = '%s%s' % (sysaddon, query) item = control.item(name, iconImage=image, thumbnailImage=image) if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) item.setInfo(type="Video", infoLabels={"Title": name, "OriginalTitle": name}) control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=True) nextPage = int(page) + 1 if nextPage <= paginationInfo['totalPages']: for page in range(1, paginationInfo['totalPages']): action = 'listShows2' query = '?action=%s&page=%d&name=%s&catid=%s&limit=%s&channel=%s' % (action, page, 'Page ' + str(page), catid, limit, channel) url = '%s%s' % (sysaddon, query) item = control.item('Page ' + str(page), iconImage='', thumbnailImage='') if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) item.setInfo(type="Video", infoLabels={"Title": 'Page ' + str(page), "OriginalTitle": 'Page ' + str(page)}) control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=True) control.content(int(sys.argv[1]), 'movies') if control.skin == 'skin.confluence': control.execute('Container.SetViewMode(500)') control.directory(int(sys.argv[1]), cacheToDisc=True)
def channelDirectory(self, items): if items == None or len(items) == 0: return addonPoster, addonBanner = control.addonPoster(), control.addonBanner() addonFanart = control.addonFanart() sysaddon = sys.argv[0] for i in items: try: label = "%s" % (i['name']) sysname = urllib.quote_plus(i['name']) poster, banner = i['poster'], i['poster'] if poster == '0': poster = addonPoster if banner == '0' and poster == '0': banner = addonBanner elif banner == '0': banner = poster url = i['url'] item = control.item(label=label, iconImage=poster, thumbnailImage=poster) try: item.setArt({'poster': poster, 'banner': banner}) except: pass if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) item.setProperty('Video', 'true') item.addContextMenuItems([], replaceItems=True) control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=False) except: pass control.content(int(sys.argv[1]), 'video') control.directory(int(sys.argv[1]), cacheToDisc=False) views.setView('movies', {'skin.confluence': 500})
def addDirectoryItem(self, name, url, mode, thumbnail, page=1, isFolder=True, query='', **kwargs): u = self.generateActionUrl(url, mode, name, thumbnail, page, query) liz = control.item(label=name, iconImage="DefaultFolder.png", thumbnailImage=thumbnail) liz.setInfo(type="Video", infoLabels={"Title": name}) for k, v in kwargs.iteritems(): if k == 'listProperties': for listPropertyKey, listPropertyValue in v.iteritems(): liz.setProperty(listPropertyKey, listPropertyValue) if k == 'listInfos': for listInfoKey, listInfoValue in v.iteritems(): liz.setInfo(listInfoKey, listInfoValue) if k == 'listArts': liz.setArt(v) if k == 'listCasts': try: liz.setCast(v) except: pass if k == 'contextMenu': menuItems = [] for label, action in v.iteritems(): menuItems.append((label, action)) if len(menuItems) > 0: liz.addContextMenuItems(menuItems) return control.addItem(handle=thisPlugin, url=u, listitem=liz, isFolder=isFolder)
from resources.lib.libraries import libtools libtools.libtvshows().range(url) elif action == 'updateLibrary': from resources.lib.libraries import libtools libtools.libepisodes().update(query) elif action == 'service': from resources.lib.libraries import libtools libtools.libepisodes().service() elif action == 'resolve': from resources.lib.sources import sources from resources.lib.libraries import control url = sources().sourcesResolve(url, provider) control.addItem(handle=int(sys.argv[1]), url=url, listitem=control.item(name)) control.directory(int(sys.argv[1])) elif action == 'download': from resources.lib.sources import sources from resources.lib.libraries import simpledownloader url = sources().sourcesResolve(url, provider) simpledownloader.download(name, image, url) elif action == 'play': from resources.lib.sources import sources sources().play(name, title, year, imdb, tmdb, tvdb, tvrage, season, episode, tvshowtitle, alter, date, meta, url) elif action == 'sources': from resources.lib.sources import sources sources().addItem(name, title, year, imdb, tmdb, tvdb, tvrage, season, episode, tvshowtitle, alter, date, meta)
def episodeDirectory(self, items, provider=None): if items == None or len(items) == 0: return isFolder = True if control.setting('autoplay') == 'false' and control.setting('host_select') == '1' else False isFolder = False if control.window.getProperty('PseudoTVRunning') == 'True' else isFolder playbackMenu = control.lang(30271).encode('utf-8') if control.setting('autoplay') == 'true' else control.lang(30270).encode('utf-8') cacheToDisc = False addonPoster, addonBanner = control.addonPoster(), control.addonBanner() addonFanart, settingFanart = control.addonFanart(), control.setting('fanart') sysaddon = sys.argv[0] 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 try: sysaction = items[0]['action'] except: sysaction = '' for i in items: try: try : if i['title'] == '0': label = '%sx%02d . %s %s' % (i['season'], int(i['episode']), 'Episode', i['episode']) else: label = '%sx%02d . %s' % (i['season'], int(i['episode']), i['title']) except: label = i['title'] if multi == True: label = '%s - %s' % (i['tvshowtitle'], label) systitle = sysname = urllib.quote_plus(i['tvshowtitle']) episodetitle, episodename = urllib.quote_plus(i['title']), urllib.quote_plus(i['name']) syspremiered = urllib.quote_plus(i['premiered']) imdb, tmdb, tvdb, tvrage, year, season, episode, alter = i['imdb'], i['tmdb'], i['tvdb'], i['tvrage'], i['year'], i['season'], i['episode'], i['alter'] poster, banner, fanart, thumb = i['poster'], i['banner'], i['fanart'], i['thumb'] if poster == '0': poster = addonPoster if banner == '0' and poster == '0': banner = addonBanner elif banner == '0': banner = poster if thumb == '0' and fanart == '0': thumb = addonFanart elif thumb == '0': thumb = fanart meta = dict((k,v) for k, v in i.iteritems() if not v == '0') meta.update({'trailer': '%s?action=trailer&name=%s' % (sysaddon, sysname)}) if i['duration'] == '0': meta.update({'duration': '60'}) try: meta.update({'duration': str(int(meta['duration']) * 60)}) except: pass sysmeta = urllib.quote_plus(json.dumps(meta)) url = '%s?action=play&name=%s&title=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s&tvrage=%s&season=%s&episode=%s&tvshowtitle=%s&alter=%s&date=%s&meta=%s&t=%s' % (sysaddon, episodename, episodetitle, year, imdb, tmdb, tvdb, tvrage, season, episode, systitle, alter, syspremiered, sysmeta, self.systime) sysurl = urllib.quote_plus(url) if isFolder == True: url = '%s?action=sources&name=%s&title=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s&tvrage=%s&season=%s&episode=%s&tvshowtitle=%s&alter=%s&date=%s&meta=%s&provider=%s' % (sysaddon, episodename, episodetitle, year, imdb, tmdb, tvdb, tvrage, season, episode, systitle, alter, syspremiered, sysmeta, provider) if sysaction == 'episodes': url = '%s?action=episodes&tvshowtitle=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s&tvrage=%s&season=%s&episode=%s' % (sysaddon, systitle, year, imdb, tmdb, tvdb, tvrage, season, episode) isFolder = True ; cacheToDisc = True cm = [] cm.append((playbackMenu, 'RunPlugin(%s?action=alterSources&url=%s&meta=%s)' % (sysaddon, sysurl, sysmeta))) if isFolder == False: cm.append((control.lang(30261).encode('utf-8'), 'RunPlugin(%s?action=queueItem)' % sysaddon)) cm.append((control.lang(30272).encode('utf-8'), 'Action(Info)')) if multi == True: cm.append((control.lang(30274).encode('utf-8'), 'ActivateWindow(Videos,%s?action=seasons&tvshowtitle=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s&tvrage=%s,return)' % (sysaddon, systitle, year, imdb, tmdb, tvdb, tvrage))) cm.append((control.lang(30263).encode('utf-8'), 'RunPlugin(%s?action=episodePlaycount&imdb=%s&tvdb=%s&season=%s&episode=%s&query=7)' % (sysaddon, imdb, tvdb, season, episode))) cm.append((control.lang(30264).encode('utf-8'), 'RunPlugin(%s?action=episodePlaycount&imdb=%s&tvdb=%s&season=%s&episode=%s&query=6)' % (sysaddon, imdb, tvdb, season, episode))) #cm.append((control.lang(30268).encode('utf-8'), 'RunPlugin(%s?action=tvshowToLibrary&tvshowtitle=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s&tvrage=%s)' % (sysaddon, systitle, year, imdb, tmdb, tvdb, tvrage))) cm.append((control.lang(30273).encode('utf-8'), 'RunPlugin(%s?action=addView&content=episodes)' % sysaddon)) item = control.item(label=label, iconImage=thumb, thumbnailImage=thumb) try: item.setArt({'poster': poster, 'tvshow.poster': poster, 'season.poster': poster, 'banner': banner, 'tvshow.banner': banner, 'season.banner': banner}) except: pass if settingFanart == 'true' and not fanart == '0': item.setProperty('Fanart_Image', fanart) elif not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) item.setInfo(type='Video', infoLabels = meta) item.setProperty('Video', 'true') #item.setProperty('IsPlayable', 'true') item.setProperty('resumetime',str(0)) item.setProperty('totaltime',str(1)) item.addContextMenuItems(cm, replaceItems=True) control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=isFolder) except: client.printException('episodeDirectory') pass try: url = items[0]['next'] if url == '': raise Exception() url = '%s?action=episodes&tvshowtitle=%s&url=%s&provider=%s' % (sysaddon, systitle, urllib.quote_plus(url), provider) addonNext = control.addonNext() item = control.item(label=control.lang(30213).encode('utf-8'), iconImage=addonNext, thumbnailImage=addonNext) item.addContextMenuItems([], replaceItems=False) if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=True) except: client.printException('movies.movieDirectory(provider=%s, item=next)' % (provider)) pass control.content(int(sys.argv[1]), 'episodes') control.directory(int(sys.argv[1]), cacheToDisc=cacheToDisc) views.setView('episodes', {'skin.confluence': 504})
def seasonDirectory(self, items): if items == None or len(items) == 0: return isFolder = True if control.setting('autoplay') == 'false' and control.setting('host_select') == '1' else False isFolder = False if control.window.getProperty('PseudoTVRunning') == 'True' else isFolder addonPoster, addonBanner = control.addonPoster(), control.addonBanner() addonFanart, settingFanart = control.addonFanart(), control.setting('fanart') sysaddon = sys.argv[0] for i in items: try: label = '%s %s' % ('Season', i['season']) systitle = sysname = urllib.quote_plus(i['tvshowtitle']) imdb, tmdb, tvdb, tvrage, year, season = i['imdb'], i['tmdb'], i['tvdb'], i['tvrage'], i['year'], i['season'] poster, banner, fanart, thumb = i['poster'], i['banner'], i['fanart'], i['thumb'] if poster == '0': poster = addonPoster if banner == '0' and poster == '0': banner = addonBanner elif banner == '0': banner = poster if thumb == '0' and poster == '0': thumb = addonPoster elif thumb == '0': thumb = poster meta = dict((k,v) for k, v in i.iteritems() if not v == '0') meta.update({'trailer': '%s?action=trailer&name=%s' % (sysaddon, sysname)}) if i['duration'] == '0': meta.update({'duration': '60'}) try: meta.update({'duration': str(int(meta['duration']) * 60)}) except: pass sysmeta = urllib.quote_plus(json.dumps(meta)) url = '%s?action=episodes&tvshowtitle=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s&tvrage=%s&season=%s' % (sysaddon, systitle, year, imdb, tmdb, tvdb, tvrage, season) cm = [] if isFolder == False: cm.append((control.lang(30261).encode('utf-8'), 'RunPlugin(%s?action=queueItem)' % sysaddon)) cm.append((control.lang(30262).encode('utf-8'), 'Action(Info)')) cm.append((control.lang(30263).encode('utf-8'), 'RunPlugin(%s?action=tvPlaycount&name=%s&year=%s&imdb=%s&tvdb=%s&season=%s&query=7)' % (sysaddon, systitle, year, imdb, tvdb, season))) cm.append((control.lang(30264).encode('utf-8'), 'RunPlugin(%s?action=tvPlaycount&name=%s&year=%s&imdb=%s&tvdb=%s&season=%s&query=6)' % (sysaddon, systitle, year, imdb, tvdb, season))) #cm.append((control.lang(30267).encode('utf-8'), 'RunPlugin(%s?action=deleteFavourite&meta=%s&content=tvshows)' % (sysaddon, sysmeta))) #cm.append((control.lang(30268).encode('utf-8'), 'RunPlugin(%s?action=tvshowToLibrary&tvshowtitle=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s&tvrage=%s)' % (sysaddon, systitle, year, imdb, tmdb, tvdb, tvrage))) cm.append((control.lang(30269).encode('utf-8'), 'RunPlugin(%s?action=addView&content=seasons)' % sysaddon)) item = control.item(label=label, iconImage=thumb, thumbnailImage=thumb) try: item.setArt({'poster': thumb, 'tvshow.poster': poster, 'season.poster': thumb, 'banner': banner, 'tvshow.banner': banner, 'season.banner': banner}) except: pass if settingFanart == 'true' and not fanart == '0': item.setProperty('Fanart_Image', fanart) elif not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) item.setInfo(type='Video', infoLabels = meta) item.setProperty('Video', 'true') item.addContextMenuItems(cm, replaceItems=True) control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=True) except: pass try: control.property(int(sys.argv[1]), 'showplot', items[0]['plot']) except: pass control.content(int(sys.argv[1]), 'seasons') control.directory(int(sys.argv[1]), cacheToDisc=True) views.setView('seasons', {'skin.confluence': 500})
def channelDirectory(self, items): if items == None or len(items) == 0: return playbackMenu = ( control.lang(30292).encode("utf-8") if control.setting("autoplay") == "true" else control.lang(30291).encode("utf-8") ) addonPoster, addonBanner = control.addonPoster(), control.addonBanner() addonFanart = control.addonFanart() sysaddon = sys.argv[0] for i in items: try: label = "[B]%s[/B] : %s" % (i["channel"].upper(), i["name"]) sysname = urllib.quote_plus(i["name"]) systitle = urllib.quote_plus(i["title"]) imdb, tmdb, year = i["imdb"], "0", i["year"] poster, banner = i["poster"], i["poster"] if poster == "0": poster = addonPoster if banner == "0" and poster == "0": banner = addonBanner elif banner == "0": banner = poster meta = dict((k, v) for k, v in i.iteritems() if not v == "0") meta.update({"trailer": "%s?action=trailer&name=%s" % (sysaddon, sysname)}) if i["duration"] == "0": meta.update({"duration": "120"}) try: meta.update({"duration": str(int(meta["duration"]) * 60)}) except: pass sysmeta = urllib.quote_plus(json.dumps(meta)) url = "%s?action=play&name=%s&title=%s&year=%s&imdb=%s&tmdb=%s&t=%s" % ( sysaddon, sysname, systitle, year, imdb, tmdb, self.systime, ) sysurl = urllib.quote_plus(url) cm = [] cm.append( (playbackMenu, "RunPlugin(%s?action=alterSources&url=%s&meta=%s)" % (sysaddon, sysurl, sysmeta)) ) cm.append((control.lang(30293).encode("utf-8"), "Action(Info)")) cm.append((control.lang(30294).encode("utf-8"), "RunPlugin(%s?action=refresh)" % (sysaddon))) cm.append((control.lang(30295).encode("utf-8"), "RunPlugin(%s?action=openSettings)" % (sysaddon))) cm.append((control.lang(30296).encode("utf-8"), "RunPlugin(%s?action=openPlaylist)" % (sysaddon))) item = control.item(label=label, iconImage=poster, thumbnailImage=poster) try: item.setArt({"poster": poster, "banner": banner}) except: pass if not addonFanart == None: item.setProperty("Fanart_Image", addonFanart) item.setInfo(type="Video", infoLabels=meta) item.setProperty("Video", "true") item.setProperty("IsPlayable", "true") item.addContextMenuItems(cm, replaceItems=True) control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=False) except: pass control.content(int(sys.argv[1]), "movies") control.directory(int(sys.argv[1]), cacheToDisc=True)
def tvshowDirectory(self, items): if items == None or len(items) == 0: return isFolder = True if control.setting('autoplay') == 'false' and control.setting('host_select') == '1' else False isFolder = False if control.window.getProperty('PseudoTVRunning') == 'True' else isFolder traktMode = False if trakt.getTraktCredentials() == False else True addonPoster, addonBanner = control.addonPoster(), control.addonBanner() addonFanart, settingFanart = control.addonFanart(), control.setting('fanart') sysaddon = sys.argv[0] try: favitems = favourites.getFavourites('tvshows') favitems = [i[0] for i in favitems] except: pass try: if traktMode == False: raise Exception() indicators = trakt.syncTVShows(timeout=720) indicators = json.loads(indicators) except: pass for i in items: try: label = i['name'] systitle = sysname = urllib.quote_plus(i['title']) sysimage = urllib.quote_plus(i['poster']) imdb, tmdb, tvdb, tvrage, year = i['imdb'], i['tmdb'], i['tvdb'], i['tvrage'], i['year'] poster, banner, fanart = i['poster'], i['banner'], i['fanart'] if poster == '0': poster = addonPoster if banner == '0' and poster == '0': banner = addonBanner elif banner == '0': banner = poster meta = dict((k,v) for k, v in i.iteritems() if not v == '0') meta.update({'trailer': '%s?action=trailer&name=%s' % (sysaddon, sysname)}) if i['duration'] == '0': meta.update({'duration': '60'}) try: meta.update({'duration': str(int(meta['duration']) * 60)}) except: pass sysmeta = urllib.quote_plus(json.dumps(meta)) url = '%s?action=seasons&tvshowtitle=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s&tvrage=%s' % (sysaddon, systitle, year, imdb, tmdb, tvdb, tvrage) try: if traktMode == False: raise Exception() match = [i for i in indicators if str(i['show']['ids']['tvdb']) == tvdb][0] num_1 = 0 for i in range(0, len(match['seasons'])): num_1 += len(match['seasons'][i]['episodes']) num_2 = int(match['show']['aired_episodes']) if num_1 >= num_2: meta.update({'playcount': 1, 'overlay': 7}) except: pass cm = [] if isFolder == False: cm.append((control.lang(30232).encode('utf-8'), 'RunPlugin(%s?action=queueItem)' % sysaddon)) cm.append((control.lang(30233).encode('utf-8'), 'Action(Info)')) if not action == 'tvSearch': cm.append((control.lang(30234).encode('utf-8'), 'RunPlugin(%s?action=tvPlaycount&name=%s&year=%s&imdb=%s&tvdb=%s&query=7)' % (sysaddon, systitle, year, imdb, tvdb))) cm.append((control.lang(30235).encode('utf-8'), 'RunPlugin(%s?action=tvPlaycount&name=%s&year=%s&imdb=%s&tvdb=%s&query=6)' % (sysaddon, systitle, year, imdb, tvdb))) if traktMode == True: cm.append((control.lang(30236).encode('utf-8'), 'RunPlugin(%s?action=traktManager&name=%s&tvdb=%s&content=tvshow)' % (sysaddon, sysname, tvdb))) if action == 'tvFavourites': cm.append((control.lang(30238).encode('utf-8'), 'RunPlugin(%s?action=deleteFavourite&meta=%s&content=tvshows)' % (sysaddon, sysmeta))) elif action.startswith('tvSearch'): cm.append((control.lang(30237).encode('utf-8'), 'RunPlugin(%s?action=addFavourite&meta=%s&query=0&content=tvshows)' % (sysaddon, sysmeta))) else: if not imdb in favitems: cm.append((control.lang(30237).encode('utf-8'), 'RunPlugin(%s?action=addFavourite&meta=%s&content=tvshows)' % (sysaddon, sysmeta))) else: cm.append((control.lang(30238).encode('utf-8'), 'RunPlugin(%s?action=deleteFavourite&meta=%s&content=tvshows)' % (sysaddon, sysmeta))) cm.append((control.lang(30239).encode('utf-8'), 'RunPlugin(%s?action=tvshowToLibrary&tvshowtitle=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s&tvrage=%s)' % (sysaddon, systitle, year, imdb, tmdb, tvdb, tvrage))) cm.append((control.lang(30240).encode('utf-8'), 'RunPlugin(%s?action=addView&content=tvshows)' % sysaddon)) item = control.item(label=label, iconImage=poster, thumbnailImage=poster) try: item.setArt({'poster': poster, 'tvshow.poster': poster, 'season.poster': poster, 'banner': banner, 'tvshow.banner': banner, 'season.banner': banner}) except: pass if settingFanart == 'true' and not fanart == '0': item.setProperty('Fanart_Image', fanart) elif not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) item.setInfo(type='Video', infoLabels = meta) item.setProperty('Video', 'true') item.addContextMenuItems(cm, replaceItems=True) control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=True) except: pass try: url = items[0]['next'] if url == '': raise Exception() url = '%s?action=tvshows&url=%s' % (sysaddon, urllib.quote_plus(url)) addonNext = control.addonNext() item = control.item(label=control.lang(30241).encode('utf-8'), iconImage=addonNext, thumbnailImage=addonNext) item.addContextMenuItems([], replaceItems=False) if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=True) except: pass control.content(int(sys.argv[1]), 'tvshows') control.directory(int(sys.argv[1]), cacheToDisc=True) views.setView('tvshows', {'skin.confluence': 500})
def tvshowDirectory(self, items): if items == None or len(items) == 0: return isFolder = True if control.setting('autoplay') == 'false' and control.setting('host_select') == '1' else False isFolder = False if control.window.getProperty('PseudoTVRunning') == 'True' else isFolder traktMode = False if trakt.getTraktCredentials() == False else True addonPoster, addonBanner = control.addonPoster(), control.addonBanner() addonFanart, settingFanart = control.addonFanart(), control.setting('fanart') sysaddon = sys.argv[0] try: favitems = favourites.getFavourites('tvshows') favitems = [i[0] for i in favitems] except: pass try: if traktMode == False: raise Exception() indicators = trakt.syncTVShows(timeout=720) indicators = json.loads(indicators) except: pass for i in items: try: label = i['name'] systitle = sysname = urllib.quote_plus(i['title']) sysimage = urllib.quote_plus(i['poster']) imdb, tmdb, tvdb, tvrage, year = i['imdb'], i['tmdb'], i['tvdb'], i['tvrage'], i['year'] poster, banner, fanart = i['poster'], i['banner'], i['fanart'] if poster == '0': poster = addonPoster if banner == '0' and poster == '0': banner = addonBanner elif banner == '0': banner = poster meta = dict((k,v) for k, v in i.iteritems() if not v == '0') meta.update({'trailer': '%s?action=trailer&name=%s' % (sysaddon, sysname)}) if i['duration'] == '0': meta.update({'duration': '60'}) try: meta.update({'duration': str(int(meta['duration']) * 60)}) except: pass sysmeta = urllib.quote_plus(json.dumps(meta)) url = '%s?action=seasons&tvshowtitle=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s&tvrage=%s' % (sysaddon, systitle, year, imdb, tmdb, tvdb, tvrage) try: if traktMode == False: raise Exception() match = [i for i in indicators if str(i['show']['ids']['tvdb']) == tvdb][0] num_1 = 0 for i in range(0, len(match['seasons'])): num_1 += len(match['seasons'][i]['episodes']) num_2 = int(match['show']['aired_episodes']) if num_1 >= num_2: meta.update({'playcount': 1, 'overlay': 7}) except: pass cm = [] if isFolder == False: cm.append((control.lang(30232).encode('utf-8'), 'RunPlugin(%s?action=queueItem)' % sysaddon)) cm.append((control.lang(30233).encode('utf-8'), 'Action(Info)')) if not action == 'tvSearch': cm.append((control.lang(30234).encode('utf-8'), 'RunPlugin(%s?action=tvPlaycount&name=%s&year=%s&imdb=%s&tvdb=%s&query=7)' % (sysaddon, systitle, year, imdb, tvdb))) cm.append((control.lang(30235).encode('utf-8'), 'RunPlugin(%s?action=tvPlaycount&name=%s&year=%s&imdb=%s&tvdb=%s&query=6)' % (sysaddon, systitle, year, imdb, tvdb))) if traktMode == True: cm.append((control.lang(30236).encode('utf-8'), 'RunPlugin(%s?action=traktManager&name=%s&tvdb=%s&content=tvshow)' % (sysaddon, sysname, tvdb))) if action == 'tvFavourites': cm.append((control.lang(30238).encode('utf-8'), 'RunPlugin(%s?action=deleteFavourite&meta=%s&content=tvshows)' % (sysaddon, sysmeta))) elif action.startswith('tvSearch'): cm.append((control.lang(30237).encode('utf-8'), 'RunPlugin(%s?action=addFavourite&meta=%s&query=0&content=tvshows)' % (sysaddon, sysmeta))) else: if not imdb in favitems and not tvdb in favitems: cm.append((control.lang(30237).encode('utf-8'), 'RunPlugin(%s?action=addFavourite&meta=%s&content=tvshows)' % (sysaddon, sysmeta))) else: cm.append((control.lang(30238).encode('utf-8'), 'RunPlugin(%s?action=deleteFavourite&meta=%s&content=tvshows)' % (sysaddon, sysmeta))) cm.append((control.lang(30239).encode('utf-8'), 'RunPlugin(%s?action=tvshowToLibrary&tvshowtitle=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s&tvrage=%s)' % (sysaddon, systitle, year, imdb, tmdb, tvdb, tvrage))) cm.append((control.lang(30240).encode('utf-8'), 'RunPlugin(%s?action=addView&content=tvshows)' % sysaddon)) item = control.item(label=label, iconImage=poster, thumbnailImage=poster) try: item.setArt({'poster': poster, 'tvshow.poster': poster, 'season.poster': poster, 'banner': banner, 'tvshow.banner': banner, 'season.banner': banner}) except: pass if settingFanart == 'true' and not fanart == '0': item.setProperty('Fanart_Image', fanart) elif not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) item.setInfo(type='Video', infoLabels = meta) item.setProperty('Video', 'true') item.addContextMenuItems(cm, replaceItems=True) control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=True) except: pass try: url = items[0]['next'] if url == '': raise Exception() url = '%s?action=tvshows&url=%s' % (sysaddon, urllib.quote_plus(url)) addonNext = control.addonNext() item = control.item(label=control.lang(30241).encode('utf-8'), iconImage=addonNext, thumbnailImage=addonNext) item.addContextMenuItems([], replaceItems=False) if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=True) except: pass control.content(int(sys.argv[1]), 'tvshows') control.directory(int(sys.argv[1]), cacheToDisc=True) views.setView('tvshows', {'skin.confluence': 500})
def channelDirectory(self, items): if items == None or len(items) == 0: return addonPoster, addonBanner = control.addonPoster(), control.addonBanner() addonFanart = control.addonFanart() sysaddon = sys.argv[0] for i in items: try: label = "%s" % (i['name']) sysname = urllib.quote_plus(i['name']) poster, banner, direct = i['poster'], i['poster'], i['direct'] try: provider = i['provider'] except: provider = None if poster == '0': poster = addonPoster if banner == '0' and poster == '0': banner = addonBanner elif banner == '0': banner = poster url = i['url'] if not direct: content = 'live' meta = {"poster": poster, "iconImage": poster} source = { "provider": provider, "url": url, "quality": 'HD', "label": 'Resolving %s' % label, "source": provider, "meta": json.dumps(meta) } syssource = urllib.quote_plus(json.dumps([source])) url = 'action=playItem&content=%s&name=%s&source=%s' % ( content, sysname, syssource) url = '%s?%s' % (sysaddon, url) item = control.item(label=label, iconImage=poster, thumbnailImage=poster) try: item.setArt({'poster': poster, 'banner': banner}) except: pass if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) item.setProperty('Video', 'true') item.setProperty("IsPlayable", "true") item.addContextMenuItems([], replaceItems=True) control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=False) except: pass control.content(int(sys.argv[1]), 'video') control.directory(int(sys.argv[1]), cacheToDisc=False) views.setView('movies', {'skin.confluence': 500})
def addItem(self, name, title, year, imdb, tmdb, tvdb, tvrage, season, episode, tvshowtitle, alter, date, meta): try: if imdb == '0': imdb = '0000000' imdb = 'tt' + re.sub('[^0-9]', '', str(imdb)) content = 'movie' if tvshowtitle == None else 'episode' self.sources = self.getSources(name, title, year, imdb, tmdb, tvdb, tvrage, season, episode, tvshowtitle, alter, date) if self.sources == []: raise Exception() self.sources = self.sourcesFilter() meta = json.loads(meta) infoMenu = control.lang(30502).encode( 'utf-8') if content == 'movie' else control.lang(30503).encode( 'utf-8') poster = meta['poster'] if 'poster' in meta else '0' banner = meta['banner'] if 'banner' in meta else '0' thumb = meta['thumb'] if 'thumb' in meta else poster fanart = meta['fanart'] if 'fanart' in meta else '0' if poster == '0': poster = control.addonPoster() if banner == '0' and poster == '0': banner = control.addonBanner() elif banner == '0': banner = poster if thumb == '0' and fanart == '0': thumb = control.addonFanart() elif thumb == '0': thumb = fanart if control.setting('fanart') == 'true' and not fanart == '0': pass else: fanart = control.addonFanart() sysaddon = sys.argv[0] for i in self.sources: try: url, label, provider = i['url'], i['label'], i['provider'] sysname, sysurl, sysimage, sysprovider = urllib.quote_plus( name), urllib.quote_plus(url), urllib.quote_plus( poster), urllib.quote_plus(provider) syssource = urllib.quote_plus(json.dumps([i])) query = 'action=playItem&content=%s&name=%s&imdb=%s&tvdb=%s&source=%s' % ( content, sysname, imdb, tvdb, syssource) cm = [] cm.append((control.lang(30504).encode('utf-8'), 'RunPlugin(%s?action=queueItem)' % sysaddon)) cm.append(( control.lang(30505).encode('utf-8'), 'RunPlugin(%s?action=download&name=%s&image=%s&url=%s&provider=%s)' % (sysaddon, sysname, sysimage, sysurl, sysprovider))) cm.append((infoMenu, 'Action(Info)')) cm.append((control.lang(30506).encode('utf-8'), 'RunPlugin(%s?action=refresh)' % sysaddon)) cm.append((control.lang(30507).encode('utf-8'), 'RunPlugin(%s?action=openSettings)' % sysaddon)) cm.append((control.lang(30508).encode('utf-8'), 'RunPlugin(%s?action=openPlaylist)' % sysaddon)) item = control.item(label=label, iconImage='DefaultVideo.png', thumbnailImage=thumb) try: item.setArt({ 'poster': poster, 'tvshow.poster': poster, 'season.poster': poster, 'banner': banner, 'tvshow.banner': banner, 'season.banner': banner }) except: pass item.setInfo(type='Video', infoLabels=meta) if not fanart == None: item.setProperty('Fanart_Image', fanart) item.setProperty('Video', 'true') item.setProperty('IsPlayable', 'true') item.addContextMenuItems(cm, replaceItems=True) control.addItem(handle=int(sys.argv[1]), url='%s?%s' % (sysaddon, query), listitem=item, isFolder=False) except: pass control.directory(int(sys.argv[1]), cacheToDisc=True) except: control.infoDialog(control.lang(30501).encode('utf-8')) pass
def addItem(self, name, title, year, imdb, tmdb, tvdb, tvrage, season, episode, tvshowtitle, alter, date, meta): try: if imdb == '0': imdb = '0000000' imdb = 'tt' + re.sub('[^0-9]', '', str(imdb)) content = 'movie' if tvshowtitle == None else 'episode' self.sources = self.getSources(name, title, year, imdb, tmdb, tvdb, tvrage, season, episode, tvshowtitle, alter, date, meta) if self.sources == []: raise Exception() self.progressDialog = control.progressDialog self.progressDialog.create(control.addonInfo('name'), '') self.progressDialog.update(0, control.lang(30515).encode('utf-8'), str(' ')) self.sources = self.sourcesFilter() if self.sources == []: raise Exception() infoMenu = control.lang(30502).encode('utf-8') if content == 'movie' else control.lang(30503).encode('utf-8') downloads = True if control.setting('downloads') == 'true' and not control.setting('movie.download.path') == '' else False logger.debug('Downloads : %s' % downloads) sysmeta = urllib.quote_plus(meta) sysaddon = sys.argv[0] meta = json.loads(meta) poster = meta['poster'] if 'poster' in meta else '0' banner = meta['banner'] if 'banner' in meta else '0' thumb = meta['thumb'] if 'thumb' in meta else poster fanart = meta['fanart'] if 'fanart' in meta else '0' if poster == '0': poster = control.addonPoster() if banner == '0' and poster == '0': banner = control.addonBanner() elif banner == '0': banner = poster if thumb == '0' and fanart == '0': thumb = control.addonFanart() elif thumb == '0': thumb = fanart if control.setting('fanart') == 'true' and not fanart == '0': pass else: fanart = control.addonFanart() for i in range(len(self.sources)): try: if self.progressDialog.iscanceled(): break self.progressDialog.update(int((100 / float(len(self.sources))) * i)) url, label, provider = self.sources[i]['url'], self.sources[i]['label'], self.sources[i]['provider'] try : parts = int(self.sources[i]['parts']) logger.debug('Download : %s, Parts : %s, Label : %s' % (downloads, parts, label)) except: parts = 2 logger.debug('Downloads : %s Parts : %s' % (downloads, parts)) systitle = urllib.quote_plus('%s (%s)' % (title, year) if tvshowtitle == None or season == None or episode == None else '%s S%02dE%02d' % (tvshowtitle, int(season), int(episode))) sysname, sysurl, sysimage, sysprovider = urllib.quote_plus(name), urllib.quote_plus(url), urllib.quote_plus(poster), urllib.quote_plus(provider) syssource = urllib.quote_plus(json.dumps([self.sources[i]])) if i == 0: query = 'action=playItem&content=%s&name=%s&year=%s&imdb=%s&tvdb=%s&source=%s&meta=%s' % (content, sysname, year, imdb, tvdb, syssource, sysmeta) else: query = 'action=playItem&content=%s&name=%s&year=%s&imdb=%s&tvdb=%s&source=%s' % (content, sysname, year, imdb, tvdb, syssource) cm = [] cm.append((control.lang(30504).encode('utf-8'), 'RunPlugin(%s?action=queueItem)' % sysaddon)) if (downloads == True and parts <= 1): cm.append((control.lang(30505).encode('utf-8'), 'RunPlugin(%s?action=download&name=%s&image=%s&source=%s)' % (sysaddon, systitle, sysimage, syssource))) cm.append((infoMenu, 'Action(Info)')) cm.append((control.lang(30506).encode('utf-8'), 'RunPlugin(%s?action=refresh)' % sysaddon)) cm.append((control.lang(30507).encode('utf-8'), 'RunPlugin(%s?action=openSettings)' % sysaddon)) cm.append((control.lang(30508).encode('utf-8'), 'RunPlugin(%s?action=openPlaylist)' % sysaddon)) item = control.item(label=label, iconImage='DefaultVideo.png', thumbnailImage=thumb) try: item.setArt({'poster': poster, 'tvshow.poster': poster, 'season.poster': poster, 'banner': banner, 'tvshow.banner': banner, 'season.banner': banner}) except: pass item.setInfo(type='Video', infoLabels = meta) if not fanart == None: item.setProperty('Fanart_Image', fanart) item.setProperty('Video', 'true') #item.setProperty('IsPlayable', 'true') item.addContextMenuItems(cm, replaceItems=True) control.addItem(handle=int(sys.argv[1]), url='%s?%s' % (sysaddon, query), listitem=item, isFolder=False) except: pass control.directory(int(sys.argv[1]), cacheToDisc=True) try: self.progressDialog.close() except: pass except: control.infoDialog(control.lang(30501).encode('utf-8')) try: self.progressDialog.close() except: pass
libtools.libtvshows().range(url) elif action == 'updateLibrary': from resources.lib.libraries import libtools libtools.libepisodes().update(query) elif action == 'service': from resources.lib.libraries import libtools libtools.libepisodes().service() elif action == 'resolve': from resources.lib.sources import sources from resources.lib.libraries import control url = sources().sourcesResolve(url, provider) control.addItem(handle=int(sys.argv[1]), url=url, listitem=control.item(name)) control.directory(int(sys.argv[1])) elif action == 'download': from resources.lib.sources import sources from resources.lib.libraries import simpledownloader url = sources().sourcesResolve(url, provider) simpledownloader.download(name, image, url) elif action == 'play': from resources.lib.sources import sources sources().play(name, title, year, imdb, tmdb, tvdb, tvrage, season, episode, tvshowtitle, alter, date, meta, url) elif action == 'sources':
def addDirectoryItem(name, url, action, image, image2, fanart, audio, content, data, tvshow='0', totalItems=0, isFolder=True): if not str(image).lower().startswith('http'): image = control.addonInfo('icon') if not str(image2).lower().startswith('http'): image2 = control.addonInfo('icon') if not str(fanart).lower().startswith('http'): fanart = control.addonInfo('fanart') if content in ['movies', 'episodes']: playable = 'true' else: playable = 'false' sysaddon = sys.argv[0] u = '%s?name=%s&url=%s&audio=%s&image=%s&fanart=%s&playable=%s&tvshow=%s&content=%s&action=%s' % ( sysaddon, urllib.quote_plus(name), urllib.quote_plus(url), urllib.quote_plus(audio), urllib.quote_plus(image), urllib.quote_plus(fanart), urllib.quote_plus(playable), str(tvshow), str(content), str(action)) cm = [] if content in ['movies', 'tvshows']: data.update({ 'trailer': '%s?action=trailer&name=%s' % (sysaddon, urllib.quote_plus(name)) }) cm.append((control.lang(30707).encode('utf-8'), 'RunPlugin(%s?action=trailer&name=%s)' % (sysaddon, urllib.quote_plus(name)))) if not 'plot' in data: data.update({'plot': control.lang(30706).encode('utf-8')}) if content == 'movies': cm.append((control.lang(30708).encode('utf-8'), 'XBMC.Action(Info)')) elif content in ['tvshows', 'seasons']: cm.append((control.lang(30709).encode('utf-8'), 'XBMC.Action(Info)')) elif content == 'episodes': cm.append((control.lang(30710).encode('utf-8'), 'XBMC.Action(Info)')) if content == 'movies' and not isFolder == True: downloadFile = name try: downloadFile = '%s (%s)' % (data['title'], data['year']) except: pass cm.append((control.lang(30722).encode('utf-8'), 'RunPlugin(%s?action=addDownload&name=%s&url=%s&image=%s)' % (sysaddon, urllib.quote_plus(downloadFile), urllib.quote_plus(url), urllib.quote_plus(image)))) elif content == 'episodes' and not isFolder == True: downloadFile = name try: downloadFile = '%s S%02dE%02d' % ( data['tvshowtitle'], int(data['season']), int(data['episode'])) except: pass cm.append((control.lang(30722).encode('utf-8'), 'RunPlugin(%s?action=addDownload&name=%s&url=%s&image=%s)' % (sysaddon, urllib.quote_plus(downloadFile), urllib.quote_plus(url), urllib.quote_plus(image)))) if content == 'movies': cm.append((control.lang(30711).encode('utf-8'), 'RunPlugin(%s?action=addView&content=movies)' % sysaddon)) elif content == 'tvshows': cm.append((control.lang(30712).encode('utf-8'), 'RunPlugin(%s?action=addView&content=tvshows)' % sysaddon)) elif content == 'seasons': cm.append((control.lang(30713).encode('utf-8'), 'RunPlugin(%s?action=addView&content=seasons)' % sysaddon)) elif content == 'episodes': cm.append((control.lang(30714).encode('utf-8'), 'RunPlugin(%s?action=addView&content=episodes)' % sysaddon)) item = control.item(name, iconImage='DefaultFolder.png', thumbnailImage=image) try: item.setArt({ 'poster': image2, 'tvshow.poster': image2, 'season.poster': image2, 'banner': image, 'tvshow.banner': image, 'season.banner': image }) except: pass item.addContextMenuItems(cm, replaceItems=False) item.setProperty('Fanart_Image', fanart) if playable == 'true': item.setProperty('IsPlayable', 'true') item.setInfo(type='Video', infoLabels=data) control.addItem(handle=int(sys.argv[1]), url=u, listitem=item, totalItems=totalItems, isFolder=isFolder)
def addDirectory(self, items, content=None): if items == None or len(items) == 0: return sysaddon = sys.argv[0] sysicon = os.path.join(control.addonInfo('path'), 'resources', 'media') sysimage = control.addonInfo('icon') sysfanart = control.addonInfo('fanart') for i in items: try: try: label = control.lang(i['title']).encode('utf-8') except: label = i['title'] if 'image' in i and not i['image'] == '0': image = i['image'] elif 'icon' in i and not i['icon'] == '0': image = os.path.join(sysicon, i['icon']) else: image = sysimage fanart = i['fanart'] if 'fanart' in i and not i['fanart'] == '0' else sysfanart isFolder = False if 'isFolder' in i and not i['isFolder'] == '0' else True url = '%s?action=%s' % (sysaddon, i['action']) try: url += '&url=%s' % urllib.quote_plus(i['url']) except: pass try: url += '&tvshowtitle=%s' % urllib.quote_plus(i['tvshowtitle']) except: pass try: url += '&title=%s' % urllib.quote_plus(i['title']) except: pass try: url += '&image=%s' % urllib.quote_plus(i['image']) except: pass try: url += '&fanart=%s' % urllib.quote_plus(i['fanart']) except: pass meta = dict((k,v) for k, v in i.iteritems() if not v == '0') try: meta.update({'duration': str(int(meta['duration']) * 60)}) except: pass item = control.item(label=label, iconImage=image, thumbnailImage=image) try: item.setArt({'poster': image, 'tvshow.poster': image, 'season.poster': image, 'banner': image, 'tvshow.banner': image, 'season.banner': image}) except: pass item.setProperty('Fanart_Image', fanart) item.addContextMenuItems([]) item.setInfo(type='Video', infoLabels = meta) if isFolder == False: item.setProperty('IsPlayable', 'true') control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=isFolder) except: pass try: i = items[0] if i['next'] == '': raise Exception() url = '%s?action=%s&url=%s' % (sysaddon, i['nextaction'], urllib.quote_plus(i['next'])) icon = i['nexticon'] if 'nexticon' in i else os.path.join(sysicon, 'next.png') fanart = i['nextfanart'] if 'nextfanart' in i else sysfanart item = control.item(label=control.lang(30500).encode('utf-8'), iconImage=icon, thumbnailImage=icon) item.setProperty('Fanart_Image', fanart) control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=True) except: pass if not content == None: control.content(int(sys.argv[1]), content) #control.do_block_check(False) control.directory(int(sys.argv[1]), cacheToDisc=True)
def listShows(self, catid, page): limatch = [] url = self.shows_link % (catid) try: result = client.request(url) except: pass pageContent = ''.join(result.splitlines()).replace('\'', '"') pages = re.compile('id="a_page_(.+?)" href').findall(pageContent) if str(page) in pages: pageUrl = self.shows_ajax_link % (catid, str(page)) result = client.request(pageUrl) limatch += re.compile('<figure>(.+?)</a></li>').findall(result) for li_content in limatch: show = re.compile( '<a href=".+?id=(.+?)"><img src="(.+?)" alt="(.+?)" w' ).findall(li_content) #print show title = show[0][2].decode('iso-8859-11') showid = show[0][0] image = show[0][1] self.list.append({'name': title, 'showid': showid, 'image': image}) for show in self.list: name = show['name'].encode('utf-8') showid = show['showid'] image = show['image'] action = 'listEpisodes' query = '?action=%s&name=%s&catid=%s&showid=%s&image=%s' % ( action, name, catid, showid, image) url = '%s%s' % (sysaddon, query) item = control.item(name, iconImage=image, thumbnailImage=image) if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) item.setInfo(type="Video", infoLabels={ "Title": name, "OriginalTitle": name }) control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=True) nextPage = int(page) + 1 if nextPage <= len(pages): if 'first' in pages: pages.remove('first') if 'pre' in pages: pages.remove('pre') if 'next' in pages: pages.remove('next') if 'last' in pages: pages.remove('last') for page in pages: action = 'listShows' pageNumber = int(page) + 1 query = '?action=%s&page=%d&name=%s&catid=%s' % ( action, int(page), 'Page ' + str(pageNumber), catid) url = '%s%s' % (sysaddon, query) item = control.item('Page ' + str(pageNumber), iconImage='', thumbnailImage='') if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) item.setInfo(type="Video", infoLabels={ "Title": 'Page ' + str(pageNumber), "OriginalTitle": 'Page ' + str(pageNumber) }) control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=True) control.content(int(sys.argv[1]), 'movies') if control.skin == 'skin.confluence': control.execute('Container.SetViewMode(500)') control.directory(int(sys.argv[1]), cacheToDisc=True)
def addDirectoryItem(name, url, action, image, image2, fanart, audio, content, data, tvshow='0', totalItems=0, isFolder=True): if not str(image).lower().startswith('http'): image = control.addonInfo('icon') if not str(image2).lower().startswith('http'): image2 = control.addonInfo('icon') if not str(fanart).lower().startswith('http'): fanart = control.addonInfo('fanart') if content in ['movies', 'episodes']: playable = 'true' else: playable = 'false' sysaddon = sys.argv[0] u=sysaddon+"?name="+urllib.quote_plus(name)+"&url="+urllib.quote_plus(url)+"&audio="+urllib.quote_plus(audio)+"&image="+urllib.quote_plus(image)+"&fanart="+urllib.quote_plus(fanart)+"&playable="+urllib.quote_plus(playable)+"&tvshow="+str(tvshow)+"&content="+str(content)+"&action="+str(action) cm = [] if content in ['movies', 'tvshows']: data.update({'trailer': '%s?action=trailer&name=%s' % (sysaddon, urllib.quote_plus(name))}) cm.append(('[COLOR gold]Watch Trailer[/COLOR]', 'RunPlugin(%s?action=trailer&name=%s)' % (sysaddon, urllib.quote_plus(name)))) if not 'plot' in data: data.update({'plot': 'Discover Great Streaming Playlists!'}) if content == 'movies': cm.append(('[COLOR gold]Movie Information[/COLOR]', 'XBMC.Action(Info)')) elif content in ['tvshows', 'seasons']: cm.append(('[COLOR gold]TV Show Information[/COLOR]', 'XBMC.Action(Info)')) elif content == 'episodes': cm.append(('[COLOR gold]Episode Information[/COLOR]', 'XBMC.Action(Info)')) if content == 'movies' and not isFolder == True: downloadFile = name try: downloadFile = '%s (%s)' % (data['title'], data['year']) except: pass cm.append(('[COLOR gold]Download This File[/COLOR]', 'RunPlugin(%s?action=addDownload&name=%s&url=%s&image=%s)' % (sysaddon, urllib.quote_plus(downloadFile), urllib.quote_plus(url), urllib.quote_plus(image)))) elif content == 'episodes' and not isFolder == True: downloadFile = name try: downloadFile = '%s S%02dE%02d' % (data['tvshowtitle'], int(data['season']), int(data['episode'])) except: pass cm.append(('[COLOR gold]Download This File[/COLOR]', 'RunPlugin(%s?action=addDownload&name=%s&url=%s&image=%s)' % (sysaddon, urllib.quote_plus(downloadFile), urllib.quote_plus(url), urllib.quote_plus(image)))) if content == 'movies': cm.append(('[COLOR gold]Set Movies view[/COLOR]', 'RunPlugin(%s?action=addView&content=movies)' % sysaddon)) elif content == 'tvshows': cm.append(('[COLOR gold]Set TV Shows view[/COLOR]', 'RunPlugin(%s?action=addView&content=tvshows)' % sysaddon)) elif content == 'seasons': cm.append(('[COLOR gold]Set Seasons view[/COLOR]', 'RunPlugin(%s?action=addView&content=seasons)' % sysaddon)) elif content == 'episodes': cm.append(('[COLOR gold]Set Episodes view[/COLOR]', 'RunPlugin(%s?action=addView&content=episodes)' % sysaddon)) item = control.item(name, iconImage='DefaultFolder.png', thumbnailImage=image) try: item.setArt({'poster': image2, 'tvshow.poster': image2, 'season.poster': image2, 'banner': image, 'tvshow.banner': image, 'season.banner': image}) except: pass item.addContextMenuItems(cm, replaceItems=False) item.setProperty('Fanart_Image', fanart) if playable == 'true': item.setProperty('IsPlayable', 'true') item.setInfo(type='Video', infoLabels=data) control.addItem(handle=int(sys.argv[1]),url=u,listitem=item,totalItems=totalItems,isFolder=isFolder)
def addCategoryItem(name, action, image, fanart, url='0'): u = '%s?action=%s&url=%s&image=%s&fanart=%s' % (sys.argv[0], str(action), urllib.quote_plus(url), urllib.quote_plus(image), urllib.quote_plus(fanart)) item = control.item(name, iconImage=mediaPath+image, thumbnailImage=mediaPath+image) item.addContextMenuItems([], replaceItems=False) item.setProperty('Fanart_Image', mediaPath+fanart) control.addItem(handle=int(sys.argv[1]),url=u,listitem=item,isFolder=True)
def episodeDirectory(self, items, provider=None): if items == None or len(items) == 0: return isFolder = True if control.setting('autoplay') == 'false' and control.setting('host_select') == '1' else False isFolder = False if control.window.getProperty('PseudoTVRunning') == 'True' else isFolder playbackMenu = control.lang(30271).encode('utf-8') if control.setting('autoplay') == 'true' else control.lang(30270).encode('utf-8') cacheToDisc = False addonPoster, addonBanner = control.addonPoster(), control.addonBanner() addonFanart, settingFanart = control.addonFanart(), control.setting('fanart') sysaddon = sys.argv[0] 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 try: sysaction = items[0]['action'] except: sysaction = '' for i in items: try: try : if i['title'] == '0': label = '%sx%02d . %s %s' % (i['season'], int(i['episode']), 'Episode', i['episode']) else: label = '%sx%02d . %s' % (i['season'], int(i['episode']), i['title']) except: label = i['title'] if multi == True: label = '%s - %s' % (i['tvshowtitle'], label) systitle = sysname = urllib.quote_plus(i['tvshowtitle']) episodetitle, episodename = urllib.quote_plus(i['title']), urllib.quote_plus(i['name']) syspremiered = urllib.quote_plus(i['premiered']) imdb, tmdb, tvdb, tvrage, year, season, episode, alter = i['imdb'], i['tmdb'], i['tvdb'], i['tvrage'], i['year'], i['season'], i['episode'], i['alter'] poster, banner, fanart, thumb = i['poster'], i['banner'], i['fanart'], i['thumb'] if poster == '0': poster = addonPoster if banner == '0' and poster == '0': banner = addonBanner elif banner == '0': banner = poster if thumb == '0' and fanart == '0': thumb = addonFanart elif thumb == '0': thumb = fanart meta = dict((k,v) for k, v in i.iteritems() if not v == '0') meta.update({'trailer': '%s?action=trailer&name=%s' % (sysaddon, sysname)}) if i['duration'] == '0': meta.update({'duration': '60'}) try: meta.update({'duration': str(int(meta['duration']) * 60)}) except: pass sysmeta = urllib.quote_plus(json.dumps(meta)) url = '%s?action=play&name=%s&title=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s&tvrage=%s&season=%s&episode=%s&tvshowtitle=%s&alter=%s&date=%s&meta=%s&t=%s' % (sysaddon, episodename, episodetitle, year, imdb, tmdb, tvdb, tvrage, season, episode, systitle, alter, syspremiered, sysmeta, self.systime) sysurl = urllib.quote_plus(url) if isFolder == True: url = '%s?action=sources&name=%s&title=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s&tvrage=%s&season=%s&episode=%s&tvshowtitle=%s&alter=%s&date=%s&meta=%s&provider=%s' % (sysaddon, episodename, episodetitle, year, imdb, tmdb, tvdb, tvrage, season, episode, systitle, alter, syspremiered, sysmeta, provider) if sysaction == 'episodes': url = '%s?action=episodes&tvshowtitle=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s&tvrage=%s&season=%s&episode=%s' % (sysaddon, systitle, year, imdb, tmdb, tvdb, tvrage, season, episode) isFolder = True ; cacheToDisc = True cm = [] cm.append((playbackMenu, 'RunPlugin(%s?action=alterSources&url=%s&meta=%s)' % (sysaddon, sysurl, sysmeta))) if isFolder == False: cm.append((control.lang(30261).encode('utf-8'), 'RunPlugin(%s?action=queueItem)' % sysaddon)) cm.append((control.lang(30272).encode('utf-8'), 'Action(Info)')) if multi == True: cm.append((control.lang(30274).encode('utf-8'), 'ActivateWindow(Videos,%s?action=seasons&tvshowtitle=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s&tvrage=%s,return)' % (sysaddon, systitle, year, imdb, tmdb, tvdb, tvrage))) cm.append((control.lang(30263).encode('utf-8'), 'RunPlugin(%s?action=episodePlaycount&imdb=%s&tvdb=%s&season=%s&episode=%s&query=7)' % (sysaddon, imdb, tvdb, season, episode))) cm.append((control.lang(30264).encode('utf-8'), 'RunPlugin(%s?action=episodePlaycount&imdb=%s&tvdb=%s&season=%s&episode=%s&query=6)' % (sysaddon, imdb, tvdb, season, episode))) #cm.append((control.lang(30268).encode('utf-8'), 'RunPlugin(%s?action=tvshowToLibrary&tvshowtitle=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s&tvrage=%s)' % (sysaddon, systitle, year, imdb, tmdb, tvdb, tvrage))) cm.append((control.lang(30273).encode('utf-8'), 'RunPlugin(%s?action=addView&content=episodes)' % sysaddon)) item = control.item(label=label, iconImage=thumb, thumbnailImage=thumb) try: item.setArt({'poster': poster, 'tvshow.poster': poster, 'season.poster': poster, 'banner': banner, 'tvshow.banner': banner, 'season.banner': banner}) except: pass if settingFanart == 'true' and not fanart == '0': item.setProperty('Fanart_Image', fanart) elif not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) item.setInfo(type='Video', infoLabels = meta) item.setProperty('Video', 'true') #item.setProperty('IsPlayable', 'true') item.setProperty('resumetime',str(0)) item.setProperty('totaltime',str(1)) item.addContextMenuItems(cm, replaceItems=True) control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=isFolder) except: pass try: url = items[0]['next'] if url == '': raise Exception() url = '%s?action=episodes&tvshowtitle=%s&url=%s&provider=%s' % (sysaddon, systitle, urllib.quote_plus(url), provider) addonNext = control.addonNext() item = control.item(label=control.lang(30213).encode('utf-8'), iconImage=addonNext, thumbnailImage=addonNext) item.addContextMenuItems([], replaceItems=False) if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=True) except: pass control.content(int(sys.argv[1]), 'episodes') control.directory(int(sys.argv[1]), cacheToDisc=cacheToDisc) views.setView('episodes', {'skin.confluence': 504})
def tvshowDirectory(self, items): if items == None or len(items) == 0: return isFolder = True if control.setting( 'autoplay') == 'false' and control.setting( 'host_select') == '1' else False isFolder = False if control.window.getProperty( 'PseudoTVRunning') == 'True' else isFolder addonPoster, addonBanner = control.addonPoster(), control.addonBanner() addonFanart, settingFanart = control.addonFanart(), control.setting( 'fanart') sysaddon = sys.argv[0] for i in items: try: label = i['name'] systitle = sysname = urllib.quote_plus(i['title']) sysimage = urllib.quote_plus(i['poster']) imdb, tmdb, tvdb, tvrage, year = i['imdb'], i['tmdb'], i[ 'tvdb'], i['tvrage'], i['year'] try: sysurl, sysprovider = urllib.quote_plus( i['url']), i['provider'] except: pass poster, banner, fanart = i['poster'], i['banner'], i['fanart'] if poster == '0': poster = addonPoster if banner == '0' and poster == '0': banner = addonBanner elif banner == '0': banner = poster meta = dict((k, v) for k, v in i.iteritems() if not v == '0') meta.update({ 'trailer': '%s?action=trailer&name=%s' % (sysaddon, sysname) }) if i['duration'] == '0': meta.update({'duration': '60'}) try: meta.update({'duration': str(int(meta['duration']) * 60)}) except: pass sysmeta = urllib.quote_plus(json.dumps(meta)) action = 'episodes' #if not (tvdb == '0' or tvdb == 'None'): # action = 'seasons' url = '%s?action=%s&provider=%s&url=%s&tvshowtitle=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s&tvrage=%s' % ( sysaddon, action, sysprovider, sysurl, systitle, year, imdb, tmdb, tvdb, tvrage) cm = [] if isFolder == False: cm.append((control.lang(30232).encode('utf-8'), 'RunPlugin(%s?action=queueItem)' % sysaddon)) #cm.append((control.lang(30214).encode('utf-8'), 'RunPlugin(%s?action=trailer&name=%s)' % (sysaddon, sysname))) cm.append( (control.lang(30233).encode('utf-8'), 'Action(Info)')) if not action == 'tvSearch': cm.append((control.lang(30234).encode( 'utf-8' ), 'RunPlugin(%s?action=tvPlaycount&name=%s&year=%s&imdb=%s&tvdb=%s&query=7)' % (sysaddon, systitle, year, imdb, tvdb))) cm.append((control.lang(30235).encode( 'utf-8' ), 'RunPlugin(%s?action=tvPlaycount&name=%s&year=%s&imdb=%s&tvdb=%s&query=6)' % (sysaddon, systitle, year, imdb, tvdb))) #if action == 'tvFavourites': # cm.append((control.lang(30238).encode('utf-8'), 'RunPlugin(%s?action=deleteFavourite&meta=%s&content=tvshows)' % (sysaddon, sysmeta))) #elif action.startswith('tvSearch'): # cm.append((control.lang(30237).encode('utf-8'), 'RunPlugin(%s?action=addFavourite&meta=%s&query=0&content=tvshows)' % (sysaddon, sysmeta))) #cm.append((control.lang(30239).encode('utf-8'), 'RunPlugin(%s?action=tvshowToLibrary&tvshowtitle=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s&tvrage=%s)' % (sysaddon, systitle, year, imdb, tmdb, tvdb, tvrage))) cm.append((control.lang(30240).encode('utf-8'), 'RunPlugin(%s?action=addView&content=tvshows)' % sysaddon)) item = control.item(label=label, iconImage=poster, thumbnailImage=poster) try: item.setArt({ 'poster': poster, 'tvshow.poster': poster, 'season.poster': poster, 'banner': banner, 'tvshow.banner': banner, 'season.banner': banner }) except: pass if settingFanart == 'true' and not fanart == '0': item.setProperty('Fanart_Image', fanart) elif not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) item.setInfo(type='Video', infoLabels=meta) item.setProperty('Video', 'true') item.addContextMenuItems(cm, replaceItems=True) control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=True) except: pass control.content(int(sys.argv[1]), 'tvshows') views.setView('tvshows', {'skin.confluence': control.viewMode['mediainfo1']}) control.directory(int(sys.argv[1]), cacheToDisc=True)
def addDirectoryItem(name, url, action, image, image2, fanart, audio, content, data, tvshow='0', totalItems=0, isFolder=True): if not str(image).lower().startswith('http'): image = control.addonInfo('icon') if not str(image2).lower().startswith('http'): image2 = control.addonInfo('icon') if not str(fanart).lower().startswith('http'): fanart = control.addonInfo('fanart') if content in ['movies', 'episodes']: playable = 'true' else: playable = 'false' sysaddon = sys.argv[0] u = sysaddon + "?name=" + urllib.quote_plus( name ) + "&url=" + urllib.quote_plus(url) + "&audio=" + urllib.quote_plus( audio) + "&image=" + urllib.quote_plus( image) + "&fanart=" + urllib.quote_plus( fanart) + "&playable=" + urllib.quote_plus( playable) + "&tvshow=" + str(tvshow) + "&content=" + str( content) + "&action=" + str(action) cm = [] if content in ['movies', 'tvshows']: data.update({ 'trailer': '%s?action=trailer&name=%s' % (sysaddon, urllib.quote_plus(name)) }) cm.append(('[COLOR gold]Watch Trailer[/COLOR]', 'RunPlugin(%s?action=trailer&name=%s)' % (sysaddon, urllib.quote_plus(name)))) if not 'plot' in data: data.update({'plot': 'Discover Great Streaming Playlists!'}) if content == 'movies': cm.append( ('[COLOR gold]Movie Information[/COLOR]', 'XBMC.Action(Info)')) elif content in ['tvshows', 'seasons']: cm.append( ('[COLOR gold]TV Show Information[/COLOR]', 'XBMC.Action(Info)')) elif content == 'episodes': cm.append( ('[COLOR gold]Episode Information[/COLOR]', 'XBMC.Action(Info)')) if content == 'movies' and not isFolder == True: downloadFile = name try: downloadFile = '%s (%s)' % (data['title'], data['year']) except: pass cm.append(('[COLOR gold]Download This File[/COLOR]', 'RunPlugin(%s?action=addDownload&name=%s&url=%s&image=%s)' % (sysaddon, urllib.quote_plus(downloadFile), urllib.quote_plus(url), urllib.quote_plus(image)))) elif content == 'episodes' and not isFolder == True: downloadFile = name try: downloadFile = '%s S%02dE%02d' % ( data['tvshowtitle'], int(data['season']), int(data['episode'])) except: pass cm.append(('[COLOR gold]Download This File[/COLOR]', 'RunPlugin(%s?action=addDownload&name=%s&url=%s&image=%s)' % (sysaddon, urllib.quote_plus(downloadFile), urllib.quote_plus(url), urllib.quote_plus(image)))) if content == 'movies': cm.append(('[COLOR gold]Set Movies view[/COLOR]', 'RunPlugin(%s?action=addView&content=movies)' % sysaddon)) elif content == 'tvshows': cm.append(('[COLOR gold]Set TV Shows view[/COLOR]', 'RunPlugin(%s?action=addView&content=tvshows)' % sysaddon)) elif content == 'seasons': cm.append(('[COLOR gold]Set Seasons view[/COLOR]', 'RunPlugin(%s?action=addView&content=seasons)' % sysaddon)) elif content == 'episodes': cm.append(('[COLOR gold]Set Episodes view[/COLOR]', 'RunPlugin(%s?action=addView&content=episodes)' % sysaddon)) item = control.item(name, iconImage='DefaultFolder.png', thumbnailImage=image) try: item.setArt({ 'poster': image2, 'tvshow.poster': image2, 'season.poster': image2, 'banner': image, 'tvshow.banner': image, 'season.banner': image }) except: pass item.addContextMenuItems(cm, replaceItems=False) item.setProperty('Fanart_Image', fanart) if playable == 'true': item.setProperty('IsPlayable', 'true') item.setInfo(type='Video', infoLabels=data) control.addItem(handle=int(sys.argv[1]), url=u, listitem=item, totalItems=totalItems, isFolder=isFolder)
def movieDirectory(self, items, provider=None, lang=None): if items == None or len(items) == 0: return isFolder = True if control.setting('autoplay') == 'false' and control.setting('host_select') == '1' else False isFolder = False if control.window.getProperty('PseudoTVRunning') == 'True' else isFolder playbackMenu = control.lang(30204).encode('utf-8') if control.setting('autoplay') == 'true' else control.lang(30203).encode('utf-8') cacheToDisc = False if not action == 'movieSearch' else True addonPoster, addonBanner = control.addonPoster(), control.addonBanner() addonFanart, settingFanart = control.addonFanart(), control.setting('fanart') sysaddon = sys.argv[0] try: from metahandler import metahandlers metaget = metahandlers.MetaData(tmdb_api_key=self.tmdb_key, preparezip=False) except: pass for i in items: try: label = i['name'] sysname = urllib.quote_plus(label) systitle = urllib.quote_plus(i['title']) imdb, tmdb, year = i['imdb'], i['tmdb'], i['year'] poster, banner, fanart = i['poster'], i['banner'], i['fanart'] if poster == '0': poster = addonPoster if banner == '0' and poster == '0': banner = addonBanner elif banner == '0': banner = poster meta = dict((k,v) for k, v in i.iteritems() if not v == '0') meta.update({'trailer': '%s?action=trailer&name=%s' % (sysaddon, sysname)}) if i['duration'] == '0': meta.update({'duration': '120'}) try: meta.update({'duration': str(int(meta['duration']) * 60)}) except: pass sysmeta = urllib.quote_plus(json.dumps(meta)) url = '%s?action=play&name=%s&title=%s&year=%s&imdb=%s&tmdb=%s&meta=%s&t=%s' % (sysaddon, sysname, systitle, year, imdb, tmdb, sysmeta, self.systime) sysurl = urllib.quote_plus(url) if isFolder == True: url = '%s?action=sources&name=%s&title=%s&year=%s&imdb=%s&tmdb=%s&meta=%s' % (sysaddon, sysname, systitle, year, imdb, tmdb, sysmeta) try: playcount = metaget._get_watched('movie', imdb, '', '') if playcount == 7: meta.update({'playcount': 1, 'overlay': 7}) else: meta.update({'playcount': 0, 'overlay': 6}) except: pass cm = [] cm.append((playbackMenu, 'RunPlugin(%s?action=alterSources&url=%s&meta=%s)' % (sysaddon, sysurl, sysmeta))) cm.append((control.lang(30214).encode('utf-8'), 'RunPlugin(%s?action=trailer&name=%s)' % (sysaddon, sysname))) cm.append((control.lang(30205).encode('utf-8'), 'Action(Info)')) if not action == 'movieSearch': cm.append((control.lang(30206).encode('utf-8'), 'RunPlugin(%s?action=moviePlaycount&title=%s&year=%s&imdb=%s&query=7)' % (sysaddon, systitle, year, imdb))) cm.append((control.lang(30207).encode('utf-8'), 'RunPlugin(%s?action=moviePlaycount&title=%s&year=%s&imdb=%s&query=6)' % (sysaddon, systitle, year, imdb)))# cm.append((control.lang(30212).encode('utf-8'), 'RunPlugin(%s?action=addView&content=movies)' % sysaddon)) item = control.item(label=label, iconImage=poster, thumbnailImage=poster) try: item.setArt({'poster': poster, 'banner': banner}) except: pass if settingFanart == 'true' and not fanart == '0': item.setProperty('Fanart_Image', fanart) elif not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) item.setInfo(type='Video', infoLabels = meta) item.setProperty('Video', 'true') #item.setProperty('IsPlayable', 'true') item.addContextMenuItems(cm, replaceItems=True) control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=isFolder) except: pass try: url = items[0]['next'] if url == '': raise Exception() url = '%s?action=movies&url=%s&provider=%s&lang=%s' % (sysaddon, urllib.quote_plus(url), provider, lang) addonNext = control.addonNext() item = control.item(label=control.lang(30213).encode('utf-8'), iconImage=addonNext, thumbnailImage=addonNext) item.addContextMenuItems([], replaceItems=False) if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=True) except: pass control.content(int(sys.argv[1]), 'movies') views.setView('movies', {'skin.confluence': control.viewMode['thumbnails']}) control.directory(int(sys.argv[1]), cacheToDisc=cacheToDisc)
def addDirectLink(title, infoLabels, url, iconImg="DefaultVideo.png"): item = control.item(title, iconImage=iconImg, thumbnailImage=iconImg) item.setInfo(type="Video", infoLabels=infoLabels) control.addItem(handle=int(sys.argv[1]), url=url, listitem=item)
def tvshowDirectory(self, items): if items == None or len(items) == 0: return isFolder = True if control.setting('autoplay') == 'false' and control.setting('host_select') == '1' else False isFolder = False if control.window.getProperty('PseudoTVRunning') == 'True' else isFolder addonPoster, addonBanner = control.addonPoster(), control.addonBanner() addonFanart, settingFanart = control.addonFanart(), control.setting('fanart') sysaddon = sys.argv[0] for i in items: try: label = i['name'] systitle = sysname = urllib.quote_plus(i['title']) sysimage = urllib.quote_plus(i['poster']) imdb, tmdb, tvdb, tvrage, year = i['imdb'], i['tmdb'], i['tvdb'], i['tvrage'], i['year'] try :sysurl, sysprovider = urllib.quote_plus(i['url']), i['provider'] except:pass poster, banner, fanart = i['poster'], i['banner'], i['fanart'] if poster == '0': poster = addonPoster if banner == '0' and poster == '0': banner = addonBanner elif banner == '0': banner = poster meta = dict((k,v) for k, v in i.iteritems() if not v == '0') meta.update({'trailer': '%s?action=trailer&name=%s' % (sysaddon, sysname)}) if i['duration'] == '0': meta.update({'duration': '60'}) try: meta.update({'duration': str(int(meta['duration']) * 60)}) except: pass sysmeta = urllib.quote_plus(json.dumps(meta)) action = 'episodes' #if not (tvdb == '0' or tvdb == 'None'): # action = 'seasons' url = '%s?action=%s&provider=%s&url=%s&tvshowtitle=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s&tvrage=%s' % (sysaddon, action, sysprovider, sysurl, systitle, year, imdb, tmdb, tvdb, tvrage) cm = [] if isFolder == False: cm.append((control.lang(30232).encode('utf-8'), 'RunPlugin(%s?action=queueItem)' % sysaddon)) #cm.append((control.lang(30214).encode('utf-8'), 'RunPlugin(%s?action=trailer&name=%s)' % (sysaddon, sysname))) cm.append((control.lang(30233).encode('utf-8'), 'Action(Info)')) if not action == 'tvSearch': cm.append((control.lang(30234).encode('utf-8'), 'RunPlugin(%s?action=tvPlaycount&name=%s&year=%s&imdb=%s&tvdb=%s&query=7)' % (sysaddon, systitle, year, imdb, tvdb))) cm.append((control.lang(30235).encode('utf-8'), 'RunPlugin(%s?action=tvPlaycount&name=%s&year=%s&imdb=%s&tvdb=%s&query=6)' % (sysaddon, systitle, year, imdb, tvdb))) #if action == 'tvFavourites': # cm.append((control.lang(30238).encode('utf-8'), 'RunPlugin(%s?action=deleteFavourite&meta=%s&content=tvshows)' % (sysaddon, sysmeta))) #elif action.startswith('tvSearch'): # cm.append((control.lang(30237).encode('utf-8'), 'RunPlugin(%s?action=addFavourite&meta=%s&query=0&content=tvshows)' % (sysaddon, sysmeta))) #cm.append((control.lang(30239).encode('utf-8'), 'RunPlugin(%s?action=tvshowToLibrary&tvshowtitle=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s&tvrage=%s)' % (sysaddon, systitle, year, imdb, tmdb, tvdb, tvrage))) cm.append((control.lang(30240).encode('utf-8'), 'RunPlugin(%s?action=addView&content=tvshows)' % sysaddon)) item = control.item(label=label, iconImage=poster, thumbnailImage=poster) try: item.setArt({'poster': poster, 'tvshow.poster': poster, 'season.poster': poster, 'banner': banner, 'tvshow.banner': banner, 'season.banner': banner}) except: pass if settingFanart == 'true' and not fanart == '0': item.setProperty('Fanart_Image', fanart) elif not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) item.setInfo(type='Video', infoLabels = meta) item.setProperty('Video', 'true') item.addContextMenuItems(cm, replaceItems=True) control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=True) except: pass control.content(int(sys.argv[1]), 'tvshows') views.setView('tvshows', {'skin.confluence': control.viewMode['mediainfo1']}) control.directory(int(sys.argv[1]), cacheToDisc=True)
def addItem(self, name, title, year, imdb, tmdb, tvdb, tvrage, season, episode, tvshowtitle, alter, date, meta): try: if imdb == '0': imdb = '0000000' imdb = 'tt' + re.sub('[^0-9]', '', str(imdb)) content = 'movie' if tvshowtitle == None else 'episode' self.sources = self.getSources(name, title, year, imdb, tmdb, tvdb, tvrage, season, episode, tvshowtitle, alter, date) if self.sources == []: raise Exception() self.sources = self.sourcesFilter() meta = json.loads(meta) infoMenu = control.lang(30502).encode('utf-8') if content == 'movie' else control.lang(30503).encode('utf-8') poster = meta['poster'] if 'poster' in meta else '0' banner = meta['banner'] if 'banner' in meta else '0' thumb = meta['thumb'] if 'thumb' in meta else poster fanart = meta['fanart'] if 'fanart' in meta else '0' if poster == '0': poster = control.addonPoster() if banner == '0' and poster == '0': banner = control.addonBanner() elif banner == '0': banner = poster if thumb == '0' and fanart == '0': thumb = control.addonFanart() elif thumb == '0': thumb = fanart if control.setting('fanart') == 'true' and not fanart == '0': pass else: fanart = control.addonFanart() sysaddon = sys.argv[0] for i in self.sources: try: url, label, provider = i['url'], i['label'], i['provider'] sysname, sysurl, sysimage, sysprovider = urllib.quote_plus(name), urllib.quote_plus(url), urllib.quote_plus(poster), urllib.quote_plus(provider) syssource = urllib.quote_plus(json.dumps([i])) query = 'action=playItem&content=%s&name=%s&imdb=%s&tvdb=%s&source=%s' % (content, sysname, imdb, tvdb, syssource) cm = [] cm.append((control.lang(30504).encode('utf-8'), 'RunPlugin(%s?action=queueItem)' % sysaddon)) cm.append((control.lang(30505).encode('utf-8'), 'RunPlugin(%s?action=download&name=%s&image=%s&url=%s&provider=%s)' % (sysaddon, sysname, sysimage, sysurl, sysprovider))) cm.append((infoMenu, 'Action(Info)')) cm.append((control.lang(30506).encode('utf-8'), 'RunPlugin(%s?action=refresh)' % sysaddon)) cm.append((control.lang(30507).encode('utf-8'), 'RunPlugin(%s?action=openSettings)' % sysaddon)) cm.append((control.lang(30508).encode('utf-8'), 'RunPlugin(%s?action=openPlaylist)' % sysaddon)) item = control.item(label=label, iconImage='DefaultVideo.png', thumbnailImage=thumb) try: item.setArt({'poster': poster, 'tvshow.poster': poster, 'season.poster': poster, 'banner': banner, 'tvshow.banner': banner, 'season.banner': banner}) except: pass item.setInfo(type='Video', infoLabels = meta) if not fanart == None: item.setProperty('Fanart_Image', fanart) item.setProperty('Video', 'true') item.setProperty('IsPlayable', 'true') item.addContextMenuItems(cm, replaceItems=True) control.addItem(handle=int(sys.argv[1]), url='%s?%s' % (sysaddon, query), listitem=item, isFolder=False) except: pass control.directory(int(sys.argv[1]), cacheToDisc=True) except: control.infoDialog(control.lang(30501).encode('utf-8')) pass
def addDirectLink(title, infoLabels, url, iconImg="DefaultVideo.png"): item = control.item(title, iconImage=iconImg, thumbnailImage=iconImg) item.setInfo(type='Video', infoLabels=infoLabels) control.addItem(handle=int(sys.argv[1]), url=url, listitem=item)
def downloader(): thumb = control.addonThumb() fanart = control.addonFanart() status = control.window.getProperty(property + '.status') if not downloadPath == '': item = control.item('[COLOR FF00b8ff]Downloads[/COLOR]', iconImage=thumb, thumbnailImage=thumb) item.addContextMenuItems([], replaceItems=True) item.setProperty('fanart_image', fanart) control.addItem(handle=int(sys.argv[1]), url=downloadPath, listitem=item, isFolder=True) if status == 'downloading': item = control.item('[COLOR red]Stop Downloads[/COLOR]', iconImage=thumb, thumbnailImage=thumb) item.addContextMenuItems([], replaceItems=True) item.setProperty('fanart_image', fanart) control.addItem(handle=int(sys.argv[1]), url=sys.argv[0] + '?action=stopDownload', listitem=item, isFolder=True) else: item = control.item('[COLOR FF00b8ff]Start Downloads[/COLOR]', iconImage=thumb, thumbnailImage=thumb) item.addContextMenuItems([], replaceItems=True) item.setProperty('fanart_image', fanart) control.addItem(handle=int(sys.argv[1]), url=sys.argv[0] + '?action=startDownload', listitem=item, isFolder=True) if status == 'downloading': item = control.item('[COLOR gold]Download Status[/COLOR]', iconImage=thumb, thumbnailImage=thumb) item.addContextMenuItems([], replaceItems=True) item.setProperty('Fanart_Image', fanart) control.addItem(handle=int(sys.argv[1]), url=sys.argv[0] + '?action=statusDownload', listitem=item, isFolder=True) def download(): return [] result = cache.get(download, 600000000, table='rel_dl') for i in result: try: cm = [] cm.append(('Remove from Queue', 'RunPlugin(%s?action=removeDownload&url=%s)' % (sys.argv[0], urllib.quote_plus(i['url'])))) item = control.item(i['name'], iconImage=i['image'], thumbnailImage=i['image']) item.addContextMenuItems(cm, replaceItems=True) item.setProperty('fanart_image', fanart) item.setProperty('Video', 'true') item.setProperty('IsPlayable', 'true') control.addItem(handle=int(sys.argv[1]), url=i['url'], listitem=item) except: pass control.directory(int(sys.argv[1]), cacheToDisc=True)
def addItem(self, name, title, year, imdb, tmdb, tvdb, tvrage, season, episode, tvshowtitle, alter, date, meta): try: imdb = "tt" + re.sub("[^0-9]", "", str(imdb)) content = "movie" if tvshowtitle == None else "episode" self.sources = self.getSources( name, title, year, imdb, tmdb, tvdb, tvrage, season, episode, tvshowtitle, alter, date ) if self.sources == []: raise Exception() self.sources = self.sourcesFilter() meta = json.loads(meta) infoMenu = ( control.lang(30502).encode("utf-8") if content == "movie" else control.lang(30503).encode("utf-8") ) poster = meta["poster"] if "poster" in meta else "0" banner = meta["banner"] if "banner" in meta else "0" thumb = meta["thumb"] if "thumb" in meta else poster fanart = meta["fanart"] if "fanart" in meta else "0" if poster == "0": poster = control.addonPoster() if banner == "0" and poster == "0": banner = control.addonBanner() elif banner == "0": banner = poster if thumb == "0" and fanart == "0": thumb = control.addonFanart() elif thumb == "0": thumb = fanart if control.setting("fanart") == "true" and not fanart == "0": pass else: fanart = control.addonFanart() sysaddon = sys.argv[0] for i in self.sources: try: url, source, provider = i["url"], i["label"], i["provider"] sysname, sysurl, sysimage, syssource, sysprovider = ( urllib.quote_plus(name), urllib.quote_plus(url), urllib.quote_plus(poster), urllib.quote_plus(source), urllib.quote_plus(provider), ) query = "action=playItem&content=%s&name=%s&imdb=%s&tvdb=%s&url=%s&source=%s&provider=%s" % ( content, sysname, imdb, tvdb, sysurl, syssource, sysprovider, ) cm = [] cm.append((control.lang(30504).encode("utf-8"), "RunPlugin(%s?action=queueItem)" % sysaddon)) # cm.append((control.lang(30505).encode('utf-8'), 'RunPlugin(%s?action=addDownload&name=%s&url=%s&image=%s&provider=%s)' % (sysaddon, sysname, sysurl, sysimage, sysprovider))) cm.append((infoMenu, "Action(Info)")) cm.append((control.lang(30506).encode("utf-8"), "RunPlugin(%s?action=refresh)" % sysaddon)) cm.append((control.lang(30507).encode("utf-8"), "RunPlugin(%s?action=openSettings)" % sysaddon)) cm.append((control.lang(30508).encode("utf-8"), "RunPlugin(%s?action=openPlaylist)" % sysaddon)) item = control.item(label=source, iconImage="DefaultVideo.png", thumbnailImage=thumb) try: item.setArt( { "poster": poster, "tvshow.poster": poster, "season.poster": poster, "banner": banner, "tvshow.banner": banner, "season.banner": banner, } ) except: pass item.setInfo(type="Video", infoLabels=meta) if not fanart == None: item.setProperty("Fanart_Image", fanart) item.setProperty("Video", "true") item.setProperty("IsPlayable", "true") item.addContextMenuItems(cm, replaceItems=True) control.addItem( handle=int(sys.argv[1]), url="%s?%s" % (sysaddon, query), listitem=item, isFolder=False ) except: pass control.directory(int(sys.argv[1]), cacheToDisc=True) except: control.infoDialog(control.lang(30501).encode("utf-8")) pass