def remove(self, videoid): """Remove an item from the Kodi library""" if ui.ask_for_confirmation(common.get_local_string(30030), common.get_local_string(30124)): library.execute_library_tasks(videoid, [library.remove_item], common.get_local_string(30030)) common.container_refresh(use_delay=True)
def remove(self, videoid): """Remove an item from the Kodi library""" if not ui.ask_for_confirmation(common.get_local_string(30030), common.get_local_string(30124)): return get_library_cls().remove_from_library(videoid) common.container_refresh(use_delay=True)
def remove_watched_status(self, videoid): """Remove the watched status from the Netflix service""" if not ui.ask_for_confirmation( common.get_local_string(30168), common.get_local_string(30300).format( xbmc.getInfoLabel('ListItem.Label'))): return if not api.remove_watched_status(videoid): ui.show_notification( 'The operation was cancelled due to an unexpected error') return # Check if item is in the cache videoid_exists, list_id = common.make_http_call( 'get_continuewatching_videoid_exists', {'video_id': str(videoid.value)}) if videoid_exists: # Try to remove the videoid from the list in the cache try: video_list_sorted_data = G.CACHE.get(cache_utils.CACHE_COMMON, list_id) del video_list_sorted_data.videos[videoid.value] G.CACHE.add(cache_utils.CACHE_COMMON, list_id, video_list_sorted_data) common.json_rpc( 'Input.Down') # Avoids selection back to the top except CacheMiss: pass common.container_refresh()
def library_playback_remove_profile(self, pathitems): # pylint: disable=unused-argument """Remove the GUID for the playback from Kodi library""" G.LOCAL_DB.set_value('library_playback_profile_guid', '') profile_name = G.LOCAL_DB.get_profile_config( 'profileName', '???', self.params['profile_guid']) common.container_refresh() ui.show_notification(profile_name, title=common.get_local_string(30053))
def autoselect_remove_profile(self, pathitems): # pylint: disable=unused-argument """Remove the GUID from auto-selection""" G.LOCAL_DB.set_value('autoselect_profile_guid', '') profile_name = G.LOCAL_DB.get_profile_config( 'profileName', '???', self.params['profile_guid']) common.container_refresh() ui.show_notification(profile_name, title=common.get_local_string(30056))
def search_clear(): """Clear all search items""" if not ui.ask_for_confirmation(common.get_local_string(30404), common.get_local_string(30406)): return False G.LOCAL_DB.clear_search_items() common.container_refresh() return True
def my_list(self, videoid, pathitems): """Add or remove an item from my list""" operation = pathitems[1] api.update_my_list(videoid, operation, self.params) sync_library(videoid, operation) if operation == 'remove' and common.WndHomeProps[common.WndHomeProps.CURRENT_DIRECTORY_MENU_ID] == 'myList': common.json_rpc('Input.Down') # Avoids selection back to the top common.container_refresh()
def remind_me(self, videoid, pathitems): """Add or remove an item to 'remind me' feature""" # This functionality is used with videos that are not available, # allows you to automatically add the title to my list as soon as it becomes available. operation = pathitems[1] G.CACHE.add(CACHE_BOOKMARKS, 'is_in_remind_me_' + str(videoid), bool(operation == 'add')) api.update_remindme(operation, videoid, self.params['trackid']) common.container_refresh()
def lib_remove(self, pathitems, videoid=None): # pylint: disable=unused-argument """Remove an item to the Kodi library""" if videoid.mediatype in [common.VideoId.SUPPLEMENTAL, common.VideoId.EPISODE]: return if not ui.ask_for_confirmation(common.get_local_string(30030), common.get_local_string(30124)): return get_library_cls().remove_from_library(videoid) common.container_refresh(use_delay=True)
def lib_export(self, pathitems, videoid=None): # pylint: disable=unused-argument """Export or update an item to the Kodi library""" if videoid.mediatype in [common.VideoId.SUPPLEMENTAL, common.VideoId.EPISODE]: return if lib_utils.is_videoid_in_db(videoid): get_library_cls().update_library(videoid) else: get_library_cls().export_to_library(videoid) common.container_refresh()
def update(self, videoid): """Update an item in the Kodi library""" nfo_settings = nfo.NFOSettings() nfo_settings.show_export_dialog(videoid.mediatype) library.execute_library_tasks( videoid, [library.remove_item, library.export_item], common.get_local_string(30061), nfo_settings=nfo_settings) common.container_refresh()
def autoselect_set_profile(self, pathitems): # pylint: disable=unused-argument """Save the GUID for profile auto-selection""" G.LOCAL_DB.set_value('autoselect_profile_guid', self.params['profile_guid']) profile_name = G.LOCAL_DB.get_profile_config( 'profileName', '???', self.params['profile_guid']) G.IS_CONTAINER_REFRESHED = True common.container_refresh() ui.show_notification(profile_name, title=common.get_local_string(30055))
def library_playback_set_profile(self, pathitems=None): # pylint: disable=unused-argument """Save the GUID for the playback from Kodi library""" G.LOCAL_DB.set_value('library_playback_profile_guid', self.params['profile_guid']) profile_name = G.LOCAL_DB.get_profile_config( 'profileName', '???', self.params['profile_guid']) G.IS_CONTAINER_REFRESHED = True common.container_refresh() ui.show_notification(profile_name, title=common.get_local_string(30052))
def my_list(self, pathitems, videoid=None): # pylint: disable=unused-argument """Add or remove an item from my list""" if videoid.mediatype not in [common.VideoId.MOVIE, common.VideoId.SHOW]: return perpetual_range_start = xbmc.getInfoLabel('ListItem.Property(nf_perpetual_range_start)') is_in_mylist = xbmc.getInfoLabel('ListItem.Property(nf_is_in_mylist)') == 'True' operation = 'remove' if is_in_mylist else 'add' api.update_my_list(videoid, operation, {'perpetual_range_start': perpetual_range_start}) sync_library(videoid, operation) common.container_refresh()
def change_watched_status_locally(videoid): """Change the watched status locally""" # Todo: how get resumetime/playcount of selected item for calculate current watched status? profile_guid = G.LOCAL_DB.get_active_profile_guid() current_value = G.SHARED_DB.get_watched_status(profile_guid, videoid.value, None, bool) if current_value: txt_index = 1 G.SHARED_DB.set_watched_status(profile_guid, videoid.value, False) elif current_value is not None and not current_value: txt_index = 2 G.SHARED_DB.delete_watched_status(profile_guid, videoid.value) else: txt_index = 0 G.SHARED_DB.set_watched_status(profile_guid, videoid.value, True) ui.show_notification(common.get_local_string(30237).split('|')[txt_index]) common.container_refresh()
def on_playback_stopped(self, player_state): # It could happen that Kodi does not assign as watched a video, # this because the credits can take too much time, then the point where playback is stopped # falls in the part that kodi recognizes as unwatched (playcountminimumpercent 90% + no-mans land 2%) # https://kodi.wiki/view/HOW-TO:Modify_automatic_watch_and_resume_points#Settings_explained # In these cases we try change/fix manually the watched status of the video by using netflix offset data if int(player_state['percentage']) > 92: return if not self.watched_threshold or not player_state['elapsed_seconds'] > self.watched_threshold: return if G.ADDON.getSettingBool('ProgressManager_enabled') and not self.is_played_from_strm: # This have not to be applied with our custom watched status of Netflix sync, within the addon return if self.is_played_from_strm: # The current video played is a STRM, then generate the path of a STRM file file_path = G.SHARED_DB.get_episode_filepath( self.videoid.tvshowid, self.videoid.seasonid, self.videoid.episodeid) url = G.py2_decode(translatePath(file_path)) if G.KODI_VERSION.is_major_ver('18'): common.json_rpc('Files.SetFileDetails', {"file": url, "media": "video", "resume": {"position": 0, "total": 0}, "playcount": 1}) # After apply the change Kodi 18 not update the library directory item common.container_refresh() else: common.json_rpc('Files.SetFileDetails', {"file": url, "media": "video", "resume": None, "playcount": 1}) else: if G.KODI_VERSION.is_major_ver('18'): # "Files.SetFileDetails" on Kodi 18 not support "plugin://" path return url = common.build_url(videoid=self.videoid, mode=G.MODE_PLAY, params={'profile_guid': G.LOCAL_DB.get_active_profile_guid()}) common.json_rpc('Files.SetFileDetails', {"file": url, "media": "video", "resume": None, "playcount": 1}) LOG.info('Has been fixed the watched status of the video: {}', url)
def include_in_auto_update(self, videoid): library_au.exclude_show_from_auto_update(videoid, False) common.container_refresh()
def update(self, videoid): """Update an item in the Kodi library""" get_library_cls().update_library(videoid) common.container_refresh()
def my_list(self, videoid, pathitems): """Add or remove an item from my list""" operation = pathitems[1] api.update_my_list(videoid, operation, self.params) sync_library(videoid, operation) common.container_refresh()
def include_in_auto_update(self, videoid): lib_utils.set_show_excluded_from_auto_update(videoid, False) common.container_refresh()
def search_remove(row_id): """Remove a search item""" LOG.debug('Removing search item with ID {}', row_id) G.LOCAL_DB.delete_search_item(row_id) common.json_rpc('Input.Down') # Avoids selection back to the top common.container_refresh()
def export(self, videoid): """Export an item to the Kodi library""" get_library_cls().export_to_library(videoid) common.container_refresh()
def exclude_from_auto_update(self, videoid): library_au.exclude_show_from_auto_update(videoid, True) common.container_refresh()