def remove_favorite(req_attrib, modelMap): logging.getLogger().debug('remove tv show favorite...') favorite = CacheManager().get('selected_favorite') favorite_thumb = CacheManager().get('selected_favorite_thumb') favorites = CacheManager().get('tv_favorites') if favorites is None: favorites = {} elif favorites.has_key(favorite): favorites.pop(favorite) context = AddonContext() filepath = file.resolve_file_path(context.get_addon_data_path(), extraDirPath='data', filename='DTB_Favorites.json', makeDirs=False) logging.getLogger().debug(favorites) _write_favorite_tv_shows_cache_(filepath, favorites) notification = "XBMC.Notification(%s,%s,%s,%s)" % (favorite, 'REMOVED FAVORITE', 2500, favorite_thumb) xbmc.executebuiltin(notification) modelMap['reload_favorite_tv_shows_items'] = True if len(favorites) > 0: favorite_tv_shows_items = [] for tv_show_name in favorites: favorite_tv_show = favorites[tv_show_name] item = xbmcgui.ListItem(label=tv_show_name, iconImage=favorite_tv_show['tv-show-thumb'], thumbnailImage=favorite_tv_show['tv-show-thumb']) item.setProperty('channel-type', favorite_tv_show['channel-type']) item.setProperty('channel-name', favorite_tv_show['channel-name']) item.setProperty('tv-show-name', tv_show_name) item.setProperty('tv-show-url', favorite_tv_show['tv-show-url']) item.setProperty('tv-show-thumb', favorite_tv_show['tv-show-thumb']) favorite_tv_shows_items.append(item) modelMap['favorite_tv_shows_items'] = favorite_tv_shows_items
def add_tv_show_favorite(req_attrib, modelMap): logging.getLogger().debug('add tv show favorite...') tv_show_url = req_attrib['tv-show-url'] tv_show_name = req_attrib['tv-show-name'] tv_show_thumb = req_attrib['tv-show-thumb'] channel_type = req_attrib['channel-type'] channel_name = req_attrib['channel-name'] logging.getLogger().debug('add tv show favorite...' + tv_show_url) favorites = CacheManager().get('dtb_tv_favorites') if favorites is None: favorites = {} elif favorites.has_key(tv_show_name): favorites.pop(tv_show_name) favorites[tv_show_name] = { 'tv-show-name': tv_show_name, 'tv-show-thumb': tv_show_thumb, 'tv-show-url': tv_show_url, 'channel-name': channel_name, 'channel-type': channel_type } context = AddonContext() filepath = file.resolve_file_path(context.get_addon_data_path(), extraDirPath='data', filename='DTB_Favorites.json', makeDirs=False) logging.getLogger().debug(favorites) _write_favorite_tv_shows_cache_(filepath, favorites) notification = "XBMC.Notification(%s,%s,%s,%s)" % ( tv_show_name, 'ADDED TO FAVORITES', 2500, tv_show_thumb) xbmc.executebuiltin(notification)
def remove_favorite(req_attrib, modelMap): logging.getLogger().debug('remove tv show favorite...') favorite = CacheManager().get('dtb_selected_favorite') favorite_thumb = CacheManager().get('dtb_selected_favorite_thumb') favorites = CacheManager().get('dtb_tv_favorites') if favorites is None: favorites = {} elif favorites.has_key(favorite): favorites.pop(favorite) context = AddonContext() filepath = file.resolve_file_path(context.get_addon_data_path(), extraDirPath='data', filename='DTB_Favorites.json', makeDirs=False) logging.getLogger().debug(favorites) _write_favorite_tv_shows_cache_(filepath, favorites) notification = "XBMC.Notification(%s,%s,%s,%s)" % ( favorite, 'REMOVED FAVORITE', 2500, favorite_thumb) xbmc.executebuiltin(notification) modelMap['reload_favorite_tv_shows_items'] = True if len(favorites) > 0: favorite_tv_shows_items = [] for tv_show_name in favorites: favorite_tv_show = favorites[tv_show_name] item = xbmcgui.ListItem( label=tv_show_name, iconImage=favorite_tv_show['tv-show-thumb'], thumbnailImage=favorite_tv_show['tv-show-thumb']) item.setProperty('channel-type', favorite_tv_show['channel-type']) item.setProperty('channel-name', favorite_tv_show['channel-name']) item.setProperty('tv-show-name', tv_show_name) item.setProperty('tv-show-url', favorite_tv_show['tv-show-url']) item.setProperty('tv-show-thumb', favorite_tv_show['tv-show-thumb']) favorite_tv_shows_items.append(item) modelMap['favorite_tv_shows_items'] = favorite_tv_shows_items
def add_tv_show_favorite(req_attrib, modelMap): logging.getLogger().debug('add tv show favorite...') tv_show_url = req_attrib['tv-show-url'] tv_show_name = req_attrib['tv-show-name'] tv_show_thumb = req_attrib['tv-show-thumb'] channel_type = req_attrib['channel-type'] channel_name = req_attrib['channel-name'] logging.getLogger().debug('add tv show favorite...' + tv_show_url) favorites = CacheManager().get('dtb_tv_favorites') if favorites is None: favorites = {} elif favorites.has_key(tv_show_name): favorites.pop(tv_show_name) favorites[tv_show_name] = {'tv-show-name':tv_show_name, 'tv-show-thumb':tv_show_thumb, 'tv-show-url':tv_show_url, 'channel-name':channel_name, 'channel-type':channel_type} context = AddonContext() filepath = file.resolve_file_path(context.get_addon_data_path(), extraDirPath='data', filename='DTB_Favorites.json', makeDirs=False) logging.getLogger().debug(favorites) _write_favorite_tv_shows_cache_(filepath, favorites) notification = "XBMC.Notification(%s,%s,%s,%s)" % (tv_show_name, 'ADDED TO FAVORITES', 2500, tv_show_thumb) xbmc.executebuiltin(notification)