def _on_format(self, path, params, re_match): self._set_content_type_and_sort_methods() result = [] format_id = re_match.group('format_id') json_data = self.call_function_cached(partial(self._client.get_format, format_id), seconds=FunctionCache.ONE_HOUR) screen = json_data['screen'] screen_objects = screen['screen_objects'] for screen_object in screen_objects: screen_object_type = screen_object['type'] title = screen_object.get('title', '') if screen_object_type == 'sushi_bar' and title != 'Ganze Folgen' and len( screen_object.get('screen_objects', [])) > 0: category_item = DirectoryItem( title, self.create_uri(['format', format_id, title])) category_item.set_fanart(self.get_fanart()) result.append(category_item) pass pass screen_object = screen_util.get_screen_object_by_name( screen, 'Ganze Folgen') result.extend( screen_util.screen_objects_to_items(self, screen_object.get( 'screen_objects', []), prepend_format_title=False)) return result
def _on_format(self, path, params, re_match): self._set_content_type_and_sort_methods() result = [] format_id = re_match.group('format_id') json_data = self.call_function_cached(partial(self._client.get_format, format_id), seconds=FunctionCache.ONE_HOUR) screen = json_data['screen'] screen_objects = screen['screen_objects'] for screen_object in screen_objects: screen_object_type = screen_object['type'] title = screen_object.get('title', '') if screen_object_type == 'sushi_bar' and title != 'Ganze Folgen' and len( screen_object.get('screen_objects', [])) > 0: category_item = DirectoryItem(title, self.create_uri(['format', format_id, title])) category_item.set_fanart(self.get_fanart()) result.append(category_item) pass pass screen_object = screen_util.get_screen_object_by_name(screen, 'Ganze Folgen') result.extend(screen_util.screen_objects_to_items(self, screen_object.get('screen_objects', []), prepend_format_title=False)) return result
def on_search(self, search_text, path, params, re_match): self._set_content_type_and_sort_methods() result = [] json_data = self.call_function_cached(partial(self._client.search, search_text), seconds=FunctionCache.ONE_HOUR) screen = json_data['screen'] category = params.get('category', 'Alle') screen_objects = screen['screen_objects'] # list all sub categories of the search if category == 'Alle': for screen_object in screen_objects: title = screen_object['title'] if title != 'Alle' and len(screen_object.get('screen_objects', [])) > 0: new_params = {} new_params.update(params) new_params['category'] = title search_category_item = DirectoryItem(title, self.create_uri([path], new_params)) search_category_item.set_fanart(self.get_fanart()) result.append(search_category_item) pass pass pass screen_object = screen_util.get_screen_object_by_name(screen, category) result.extend(screen_util.screen_objects_to_items(self, screen_object.get('screen_objects', []))) return result
def on_root(self, path, params, re_match): result = [] # search search_item = DirectoryItem( '[B]' + self.localize(self.LOCAL_SEARCH) + '[/B]', self.create_uri([self.PATH_SEARCH, 'list'])) search_item.set_fanart(self.get_fanart()) result.append(search_item) if len(self.get_favorite_list().list()) > 0: fav_item = kodimon.DirectoryItem( '[B]' + self.localize(self.LOCAL_FAVORITES) + '[/B]', self.create_uri([self.PATH_FAVORITES, 'list'])) fav_item.set_fanart(self.get_fanart()) result.append(fav_item) pass # watch later if len(self.get_watch_later_list().list()) > 0: fav_item = kodimon.DirectoryItem( '[B]' + self.localize(self.LOCAL_WATCH_LATER) + '[/B]', self.create_uri([self.PATH_WATCH_LATER, 'list'])) fav_item.set_fanart(self.get_fanart()) result.append(fav_item) pass json_data = self.call_function_cached(partial(self._client.get_home), seconds=FunctionCache.ONE_HOUR) menu_items = json_data['menubar']['channels'][0]['menu_items'] for menu_item in menu_items: title = menu_item['displayName'] link_match = re.match( '\/(.+)\/v(\d+)\/(.+)\/screen\/(?P<screen_id>\d+)', menu_item['link']) if link_match: screen_id = link_match.group('screen_id') menu_item = DirectoryItem( title, self.create_uri(['screen', screen_id])) menu_item.set_fanart(self.get_fanart()) result.append(menu_item) pass pass return result
def on_search(self, search_text, path, params, re_match): self._set_content_type_and_sort_methods() result = [] json_data = self.call_function_cached(partial(self._client.search, search_text), seconds=FunctionCache.ONE_HOUR) screen = json_data['screen'] category = params.get('category', 'Alle') screen_objects = screen['screen_objects'] # list all sub categories of the search if category == 'Alle': for screen_object in screen_objects: title = screen_object['title'] if title != 'Alle' and len( screen_object.get('screen_objects', [])) > 0: new_params = {} new_params.update(params) new_params['category'] = title search_category_item = DirectoryItem( title, self.create_uri([path], new_params)) search_category_item.set_fanart(self.get_fanart()) result.append(search_category_item) pass pass pass screen_object = screen_util.get_screen_object_by_name(screen, category) result.extend( screen_util.screen_objects_to_items( self, screen_object.get('screen_objects', []))) return result
def _on_screen(self, path, params, re_match): result = [] screen_id = re_match.group('screen_id') json_data = self.call_function_cached(partial(self._client.get_screen, screen_id), seconds=FunctionCache.ONE_HOUR) screen = json_data['screen'] screen_type = screen['type'] if screen_type == 'FormatGrid': screen_objects = screen.get('screen_objects', []) if len(screen_objects) > 0: screen_objects = screen_objects[0].get('screen_objects', []) pass for screen_object in screen_objects: title = screen_object['title'] sub_screen_item = DirectoryItem( title, self.create_uri(['screen', screen_id, title])) sub_screen_item.set_fanart(self.get_fanart()) result.append(sub_screen_item) pass pass elif screen_type == 'BasicPage' or screen_type == 'home': screen_objects = screen['screen_objects'] for screen_object in screen_objects: screen_object_type = screen_object['type'] if screen_object_type != 'home_header': title = screen_object['title'] sub_screen_item = DirectoryItem( title, self.create_uri(['screen', screen_id, title])) sub_screen_item.set_fanart(self.get_fanart()) result.append(sub_screen_item) pass pass pass else: raise KodimonException("Unknown screen type '%s'" % screen_type) return result
def on_root(self, path, params, re_match): result = [] # search search_item = DirectoryItem('[B]'+self.localize(self.LOCAL_SEARCH)+'[/B]', self.create_uri([self.PATH_SEARCH, 'list'])) search_item.set_fanart(self.get_fanart()) result.append(search_item) if len(self.get_favorite_list().list()) > 0: fav_item = kodimon.DirectoryItem('[B]' + self.localize(self.LOCAL_FAVORITES) + '[/B]', self.create_uri([self.PATH_FAVORITES, 'list'])) fav_item.set_fanart(self.get_fanart()) result.append(fav_item) pass # watch later if len(self.get_watch_later_list().list()) > 0: fav_item = kodimon.DirectoryItem('[B]' + self.localize(self.LOCAL_WATCH_LATER) + '[/B]', self.create_uri([self.PATH_WATCH_LATER, 'list'])) fav_item.set_fanart(self.get_fanart()) result.append(fav_item) pass json_data = self.call_function_cached(partial(self._client.get_home), seconds=FunctionCache.ONE_HOUR) menu_items = json_data['menubar']['channels'][0]['menu_items'] for menu_item in menu_items: title = menu_item['displayName'] link_match = re.match('\/(.+)\/v(\d+)\/(.+)\/screen\/(?P<screen_id>\d+)', menu_item['link']) if link_match: screen_id = link_match.group('screen_id') menu_item = DirectoryItem(title, self.create_uri(['screen', screen_id])) menu_item.set_fanart(self.get_fanart()) result.append(menu_item) pass pass return result
def _on_screen(self, path, params, re_match): result = [] screen_id = re_match.group('screen_id') json_data = self.call_function_cached(partial(self._client.get_screen, screen_id), seconds=FunctionCache.ONE_HOUR) screen = json_data['screen'] screen_type = screen['type'] if screen_type == 'FormatGrid': screen_objects = screen.get('screen_objects', []) if len(screen_objects) > 0: screen_objects = screen_objects[0].get('screen_objects', []) pass for screen_object in screen_objects: title = screen_object['title'] sub_screen_item = DirectoryItem(title, self.create_uri(['screen', screen_id, title])) sub_screen_item.set_fanart(self.get_fanart()) result.append(sub_screen_item) pass pass elif screen_type == 'BasicPage' or screen_type == 'home': screen_objects = screen['screen_objects'] for screen_object in screen_objects: screen_object_type = screen_object['type'] if screen_object_type != 'home_header': title = screen_object['title'] sub_screen_item = DirectoryItem(title, self.create_uri(['screen', screen_id, title])) sub_screen_item.set_fanart(self.get_fanart()) result.append(sub_screen_item) pass pass pass else: raise KodimonException("Unknown screen type '%s'" % screen_type) return result
def screen_objects_to_items(provider, screen_objects, prepend_format_title=True): result = [] for screen_object in screen_objects: screen_object_type = screen_object["type"] if screen_object_type == "format_item": title = screen_object["title"] format_id = screen_object["id"] image = screen_object["image_url"] format_item = DirectoryItem(title, provider.create_uri(["format", str(format_id)]), image=image) format_item.set_fanart(provider.get_fanart()) context_menu = [ kodimon.contextmenu.create_add_to_favs( provider.get_plugin(), provider.localize(provider.LOCAL_FAVORITES_ADD), format_item ) ] format_item.set_context_menu(context_menu) result.append(format_item) pass elif screen_object_type == "video_item" or screen_object_type == "citylight_item": title = "" format_title = screen_object.get("format_title", "") video_title = screen_object.get("video_title", "") if format_title and video_title and prepend_format_title: title = "%s - %s" % (format_title, video_title) elif video_title: title = video_title elif format_title: title = format_title else: title = screen_object["id"] pass video_item = VideoItem( title, provider.create_uri(["play", screen_object["id"]]), image=screen_object["image_url"] ) video_item.set_fanart(provider.get_fanart()) # duration video_item.set_duration_in_seconds(int(screen_object["duration"])) # aired publishing_date = kodimon.parse_iso_8601(screen_object["publishing_date"]) video_item.set_aired(publishing_date["year"], publishing_date["month"], publishing_date["day"]) # season & episode try_set_season_and_episode(video_item) context_menu = [ kodimon.contextmenu.create_add_to_watch_later( provider.get_plugin(), provider.localize(provider.LOCAL_WATCH_LATER), video_item ) ] video_item.set_context_menu(context_menu) result.append(video_item) pass else: raise KodimonException("Unknown screen_object type '%s'" % screen_object_type) pass return result
def screen_objects_to_items(provider, screen_objects, prepend_format_title=True): result = [] for screen_object in screen_objects: screen_object_type = screen_object['type'] if screen_object_type == 'format_item': title = screen_object['title'] format_id = screen_object['id'] image = screen_object['image_url'] format_item = DirectoryItem(title, provider.create_uri( ['format', str(format_id)]), image=image) format_item.set_fanart(provider.get_fanart()) context_menu = [ kodimon.contextmenu.create_add_to_favs( provider.get_plugin(), provider.localize(provider.LOCAL_FAVORITES_ADD), format_item) ] format_item.set_context_menu(context_menu) result.append(format_item) pass elif screen_object_type == 'video_item' or screen_object_type == 'citylight_item': title = '' format_title = screen_object.get('format_title', '') video_title = screen_object.get('video_title', '') if format_title and video_title and prepend_format_title: title = '%s - %s' % (format_title, video_title) elif video_title: title = video_title elif format_title: title = format_title else: title = screen_object['id'] pass video_item = VideoItem(title, provider.create_uri( ['play', screen_object['id']]), image=screen_object['image_url']) video_item.set_fanart(provider.get_fanart()) # duration video_item.set_duration_in_seconds(int(screen_object['duration'])) # aired publishing_date = kodimon.parse_iso_8601( screen_object['publishing_date']) video_item.set_aired(publishing_date['year'], publishing_date['month'], publishing_date['day']) # season & episode try_set_season_and_episode(video_item) context_menu = [ kodimon.contextmenu.create_add_to_watch_later( provider.get_plugin(), provider.localize(provider.LOCAL_WATCH_LATER), video_item) ] video_item.set_context_menu(context_menu) result.append(video_item) pass else: raise KodimonException("Unknown screen_object type '%s'" % screen_object_type) pass return result