def _fill_movie_details(f, properties): """ Helper function to provide episode details """ info = { 'movieid': f._beacon_id[1], 'label': f.get('title') } # it kind of sucks, but we have to ask kaa.(web)metadata again for # each movie to get the details. metadata = kaa.metadata.parse(f.url[7:]) webmetadata = kaa.webmetadata.parse(f.url[7:], metadata) for prop in properties: if prop == 'title': info[prop] = f.get('title') elif prop == 'thumbnail': info[prop] = utils.register_image(f.get('poster'), f) elif prop in ('rating',): info[prop] = 0.0 elif prop == 'file': info[prop] = f.url elif prop == 'plot': info[prop] = f.get('description') elif prop in ('playcount', 'setid'): info[prop] = 0 elif prop == 'resume': info[prop] = { 'position': 0, 'total': 0 } elif prop == 'set': info[prop] = '' elif prop == 'fanart': info[prop] = utils.register_image((webmetadata and webmetadata.image) or '') elif prop == 'imdbnumber': info[prop] = (webmetadata and webmetadata.imdb) or '' elif prop == 'genre': info[prop] = (webmetadata and webmetadata.genre) or [] elif prop == 'year': info[prop] = (webmetadata and webmetadata.year) or 0 elif prop == 'runtime': info[prop] = f.get('length') elif prop in ('firstaired', 'dateadded', 'originaltitle', 'sorttitle', 'trailer'): info[prop] = '' elif prop in ('cast', 'mpaa', 'studio', 'director', 'tag'): info[prop] = [] elif prop == 'streamdetails': info[prop] = { 'audio': [], 'subtitle': [], 'video': [] } if metadata: for v in metadata.video: info[prop]['video'].append(utils.fill_video_details(v, metadata)) for a in metadata.audio: info[prop]['audio'].append(utils.fill_audio_details(a)) for s in metadata.subtitles: info[prop]['subtitle'].append(utils.fill_subtitle_details(s)) else: log.error('no support for %s' % prop) info[prop] = '' return info
def _fill_movie_details(f, properties): """ Helper function to provide episode details """ info = {'movieid': f._beacon_id[1], 'label': f.get('title')} # it kind of sucks, but we have to ask kaa.(web)metadata again for # each movie to get the details. metadata = kaa.metadata.parse(f.url[7:]) webmetadata = kaa.webmetadata.parse(f.url[7:], metadata) for prop in properties: if prop == 'title': info[prop] = f.get('title') elif prop == 'thumbnail': info[prop] = utils.register_image(f.get('poster'), f) elif prop in ('rating', ): info[prop] = 0.0 elif prop == 'file': info[prop] = f.url elif prop == 'plot': info[prop] = f.get('description') elif prop in ('playcount', 'setid'): info[prop] = 0 elif prop == 'resume': info[prop] = {'position': 0, 'total': 0} elif prop == 'set': info[prop] = '' elif prop == 'fanart': info[prop] = utils.register_image( (webmetadata and webmetadata.image) or '') elif prop == 'imdbnumber': info[prop] = (webmetadata and webmetadata.imdb) or '' elif prop == 'genre': info[prop] = (webmetadata and webmetadata.genre) or [] elif prop == 'year': info[prop] = (webmetadata and webmetadata.year) or 0 elif prop == 'runtime': info[prop] = f.get('length') elif prop in ('firstaired', 'dateadded', 'originaltitle', 'sorttitle', 'trailer'): info[prop] = '' elif prop in ('cast', 'mpaa', 'studio', 'director', 'tag'): info[prop] = [] elif prop == 'streamdetails': info[prop] = {'audio': [], 'subtitle': [], 'video': []} if metadata: for v in metadata.video: info[prop]['video'].append( utils.fill_video_details(v, metadata)) for a in metadata.audio: info[prop]['audio'].append(utils.fill_audio_details(a)) for s in metadata.subtitles: info[prop]['subtitle'].append( utils.fill_subtitle_details(s)) else: log.error('no support for %s' % prop) info[prop] = '' return info
def GetEpisodeDetails(episodeid, properties): """ JsonRPC Callback VideoLibrary.GetEpisodeDetails """ result = (yield kaa.beacon.query(id=episodeid, type='video')) if len(result) != 1: log.error('bad query') yield {} details = _fill_episode_details(result[0], properties) if 'streamdetails' in properties: metadata = kaa.metadata.parse(result[0].url) value = {'audio': [], 'subtitle': [], 'video': []} if metadata: for v in metadata.video: value['video'].append(utils.fill_video_details(v, metadata)) for a in metadata.audio: value['audio'].append(utils.fill_audio_details(a)) for s in metadata.subtitles: value['subtitle'].append(utils.fill_subtitle_details(s)) details['streamdetails'] = value yield {'episodedetails': details}
def GetEpisodeDetails(episodeid, properties): """ JsonRPC Callback VideoLibrary.GetEpisodeDetails """ result = (yield kaa.beacon.query(id=episodeid, type='video')) if len(result) != 1: log.error('bad query') yield {} details = _fill_episode_details(result[0], properties) if 'streamdetails' in properties: metadata = kaa.metadata.parse(result[0].url) value = { 'audio': [], 'subtitle': [], 'video': [] } if metadata: for v in metadata.video: value['video'].append(utils.fill_video_details(v, metadata)) for a in metadata.audio: value['audio'].append(utils.fill_audio_details(a)) for s in metadata.subtitles: value['subtitle'].append(utils.fill_subtitle_details(s)) details['streamdetails'] = value yield {'episodedetails': details}
def _fill_episode_details(f, properties, metadata=None): """ Helper function to provide episode details """ info = { 'episodeid': f._beacon_id[1], 'label': '%s %sx%02d - %s' % (f.get('series'), f.get('season'), f.get('episode'), f.get('title')) } for prop in properties: if prop == 'season': info[prop] = f.get('season') or 0 elif prop == 'episode': info[prop] = f.get('episode') or 0 elif prop == 'showtitle': info[prop] = f.get('series') or '' elif prop == 'title': info[prop] = f.get('title') or '' elif prop == 'thumbnail': info[prop] = utils.register_image(f.thumbnail, f) elif prop in ('rating',): info[prop] = 0.0 elif prop == 'file': info[prop] = f.url elif prop == 'plot': info[prop] = f.get('description') or '' elif prop == 'playcount': info[prop] = 0 elif prop == 'resume': info[prop] = { 'position': 0.0, 'total': 0.0 } elif prop in ('firstaired', 'dateadded', 'originaltitle', 'lastplayed'): info[prop] = '' elif prop in ('cast', ): info[prop] = [] elif prop == 'streamdetails': info[prop] = { 'audio': [], 'subtitle': [], 'video': [] } if metadata and 0: for v in metadata.video: info[prop]['video'].append(utils.fill_video_details(v, metadata)) for a in metadata.audio: info[prop]['audio'].append(utils.fill_audio_details(a)) for s in metadata.subtitles: info[prop]['subtitle'].append(utils.fill_subtitle_details(s)) else: info[prop]['video'].append({ 'height': 720, 'width': 1280, 'aspect': 16.0/9, 'codec': 'h264', 'duration': 1290, 'stereomode': '', }) info[prop]['audio'].append({ 'channels': 6, 'codec': 'ac3', 'language': '', }) elif prop in ('tvshowid', 'specialsortepisode', 'specialsortseason'): info[prop] = -1 else: log.error('no support for %s' % prop) info[prop] = '' return info