def magazine_list(): control.content(int(sys.argv[1]), 'images') index_txt = client.request(variables.mags_base_url) splitted = index_txt.splitlines() number = re.sub(r'Volume (\d{1,3}).+', r'\1', splitted[-1]) if len(number) == 1: number = '00' + number elif len(number) == 2: number = '0' + number voice_img = urljoin(variables.mags_base_url, 'mag_thumb_{0}.jpg'.format(number)) magazines = [] for line in splitted: title = line.replace('Volume', control.lang(30025)) image = line.partition(' - ')[0].replace('Volume ', 'vol') image = urljoin(variables.mags_base_url, image + '/thumbs' + '/thumb-01.jpg') url = '{0}?action=mag_index&url={1}'.format(sys.argv[0], image.partition('/thumbs')[0]) data = {'title': title, 'image': image, 'url': url} magazines.append(data) return magazines, voice_img
def paper_index(link): menu = [] items = _paper_index(link) if items is None: return for i in items: li = control.item(label=i['title']) li.setArt({ 'poster': i['image'], 'thumb': i['image'], 'fanart': control.join(control.addonPath, 'resources', 'media', 'newspaper_fanart.png') }) li.setInfo('image', {'title': i['title'], 'picturepath': i['url']}) url = i['url'] menu.append((url, li, False)) control.content(syshandle, 'images') control.addItems(syshandle, menu) control.directory(syshandle)
def add(items, cacheToDisc=True, content=None, mediatype=None, infotype='video', argv=None, as_playlist=False, pd_heading=None, pd_message='', clear_first=True, progress=False, category=None): if argv is None: from tulip.init import sysaddon, syshandle else: sysaddon = argv[0] syshandle = int(argv[1]) if items is None or len(items) == 0: return # sysicon = control.join(control.addonInfo('path'), 'resources', 'media') sysimage = control.addonInfo('icon') sysfanart = control.addonInfo('fanart') if progress: pd = control.progressDialogGB pd.create(heading=control.name() if not pd_heading else pd_heading, message=pd_message) else: pd = None if as_playlist and clear_first: control.playlist(1 if infotype == 'video' else 0).clear() meta_tags = [ 'count', 'size', 'date', 'genre', 'country', 'year', 'episode', 'season', 'sortepisode', 'sortseason', 'episodeguide', 'showlink', 'top250', 'setid', 'tracknumber', 'rating', 'userrating', 'watched', 'playcount', 'overlay', 'cast', 'castandrole', 'director', 'mpaa', 'plot', 'plotoutline', 'title', 'originaltitle', 'sorttitle', 'duration', 'studio', 'tagline', 'writer', 'tvshowtitle', 'premiered', 'status', 'set', 'gameclient', 'setoverview', 'tag', 'imdbnumber', 'code', 'aired', 'credits', 'lastplayed', 'album', 'artist', 'votes', 'path', 'trailer', 'dateadded', 'mediatype', 'dbid', 'tracknumber', 'discnumber', 'lyrics', 'listeners', 'musicbrainztrackid', 'comment', 'picturepath', 'platform', 'genres', 'publisher', 'developer', 'overview' ] for c, i in list(enumerate(items)): try: if progress: p = control.per_cent(c, len(items)) pd.update(p) try: label = control.lang(i['title']).encode('utf-8') except Exception: label = i['title'] if 'label' in i and not i['label'] == '0': label = i['label'] if 'image' in i and not i['image'] == '0': image = i['image'] elif 'poster' in i and not i['poster'] == '0': image = i['poster'] elif 'icon' in i and not i['icon'] == '0': image = control.addonmedia(i['icon']) else: image = sysimage if 'banner' in i and not i['banner'] == '0': banner = i['banner'] elif 'fanart' in i and not i['fanart'] == '0': banner = i['fanart'] else: banner = image 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 try: is_play_boolean = i.get('isPlayable') in [ 'True', 'true', '1', 'yes', 'Yes' ] except Exception: is_play_boolean = False isPlayable = True if not isFolder and 'isPlayable' not in i else is_play_boolean if isPlayable: isFolder = False try: action = '{0}?action={1}'.format(sysaddon, i['action']) except KeyError: return try: url = 'url={0}'.format(quote_plus(i['url'])) except Exception: url = None try: title = 'title={0}'.format(quote_plus(i['title'])) except KeyError: try: title = 'title={0}'.format( quote_plus(i['title'].encode('utf-8'))) except KeyError: title = None except Exception: title = None try: icon = 'image={0}'.format(quote_plus(i['image'])) except KeyError: try: icon = 'image={0}'.format( quote_plus(i['image'].encode('utf-8'))) except KeyError: icon = None except Exception: icon = None try: name = 'name={0}'.format(quote_plus(i['name'])) except KeyError: try: name = 'name={0}'.format( quote_plus(i['name'].encode('utf-8'))) except KeyError: name = None except Exception: name = None try: year = 'year={0}'.format(quote_plus(i['year'])) except Exception: year = None try: plot = 'plot={0}'.format(quote_plus(i['plot'])) except KeyError: try: plot = 'plot={0}'.format( quote_plus(i['plot'].encode('utf-8'))) except KeyError: plot = None except Exception: plot = None try: genre = 'genre={0}'.format(quote_plus(i['genre'])) except KeyError: try: genre = 'genre={0}'.format( quote_plus(i['genre'].encode('utf-8'))) except KeyError: genre = None except Exception: genre = None try: dash = 'dash={0}'.format(quote_plus(i['dash'])) except Exception: dash = None try: query = 'query={0}'.format(quote_plus(i['query'])) except Exception: query = None parts = [ foo for foo in [ action, url, title, icon, name, year, plot, genre, dash, query ] if foo ] uri = '&'.join(parts) cm = [] menus = i['cm'] if 'cm' in i else [] for menu in menus: try: try: tmenu = control.lang(menu['title']).encode('utf-8') except Exception: tmenu = menu['title'] try: qmenu = urlencode(menu['query']) except Exception: qmenu = urlencode( dict((k, v.encode('utf-8')) for k, v in menu['query'].items())) cm.append( (tmenu, 'RunPlugin({0}?{1})'.format(sysaddon, qmenu))) except Exception: pass meta = dict((k, v) for k, v in iteritems(i) if k in meta_tags and (not v == '0' or v is None)) if mediatype is not None: meta['mediatype'] = mediatype item = control.item(label=label) item.setArt({ 'icon': image, 'thumb': image, 'poster': image, 'tvshow.poster': image, 'season.poster': image, 'banner': banner, 'tvshow.banner': banner, 'season.banner': banner, 'fanart': fanart }) item.addContextMenuItems(cm) item.setInfo( type=infotype if 'infotype' not in i else i['infotype'], infoLabels=meta) if isPlayable: if not i['action'] == 'pvr_client': item.setProperty('IsPlayable', 'true') else: item.setProperty('IsPlayable', 'false') if not i['action'] == 'pvr_client': if 'streaminfo' not in i and infotype == 'video': item.addStreamInfo(infotype, {'codec': 'h264'}) else: item.addStreamInfo(infotype, i.get('streaminfo')) if as_playlist and isPlayable: control.playlist(1 if infotype == 'video' else 0).add( url=uri, listitem=item, index=c) else: control.addItem(handle=syshandle, url=uri, listitem=item, isFolder=isFolder, totalItems=len(items)) except Exception as reason: log('Directory not added, reason of failure: ' + repr(reason)) if progress: pd.update(100) pd.close() if as_playlist: control.openPlaylist(1 if infotype == 'video' else 0) return try: i = items[0] if i['next'] == '': raise Exception() url = '{0}?action={1}&url={2}'.format(sysaddon, i['nextaction'], quote_plus(i['next'])) icon = i['nexticon'] if 'nexticon' in i else control.addonmedia( 'next.png') fanart = i['nextfanart'] if 'nextfanart' in i else sysfanart try: label = control.lang(i['nextlabel']).encode('utf-8') except Exception: label = 'Next' item = control.item(label=label) item.setArt({ 'icon': icon, 'thumb': icon, 'poster': icon, 'tvshow.poster': icon, 'season.poster': icon, 'banner': icon, 'tvshow.banner': icon, 'season.banner': icon, 'fanart': fanart }) control.addItem(handle=syshandle, url=url, listitem=item, isFolder=True, totalItems=len(items)) except Exception: pass if content is not None: control.content(syshandle, content) if category is not None: control.setcategory(syshandle, category) control.directory(syshandle, cacheToDisc=cacheToDisc)