def store_blank_subtitle_metadata(self, video_part_map): store_subtitle_info(video_part_map, dict((k, []) for k in video_part_map.keys()), None, mode="a")
def update(self, metadata, media, lang): Log.Debug("Sub-Zero %s, %s update called" % (config.version, self.agent_type)) intent = get_intent() if not media: Log.Error( "Called with empty media, something is really wrong with your setup!" ) return item_ids = [] try: config.init_subliminal_patches() videos = media_to_videos(media, kind=self.agent_type) # find local media update_local_media(metadata, media, media_type=self.agent_type) # media ignored? use_any_parts = False for video in videos: if is_ignored(video["id"]): Log.Debug(u"Ignoring %s" % video) continue use_any_parts = True if not use_any_parts: Log.Debug(u"Nothing to do.") return try: use_score = int(Prefs[self.score_prefs_key].strip()) except ValueError: Log.Error( "Please only put numbers into the scores setting. Exiting") return set_refresh_menu_state(media, media_type=self.agent_type) # scanned_video_part_map = {subliminal.Video: plex_part, ...} scanned_video_part_map = scan_videos(videos, kind=self.agent_type) downloaded_subtitles = None if not config.enable_agent: Log.Debug("Skipping Sub-Zero agent(s)") else: # downloaded_subtitles = {subliminal.Video: [subtitle, subtitle, ...]} downloaded_subtitles = download_best_subtitles( scanned_video_part_map, min_score=use_score) item_ids = get_media_item_ids(media, kind=self.agent_type) downloaded_any = False if downloaded_subtitles: downloaded_any = any(downloaded_subtitles.values()) if downloaded_any: save_subtitles(scanned_video_part_map, downloaded_subtitles, mods=config.default_mods) track_usage("Subtitle", "refreshed", "download", 1) for video, video_subtitles in downloaded_subtitles.items(): # store item(s) in history for subtitle in video_subtitles: item_title = get_title_for_video_metadata( video.plexapi_metadata, add_section_title=False) history = get_history() history.add( item_title, video.id, section_title=video.plexapi_metadata["section"], subtitle=subtitle) else: # store subtitle info even if we've downloaded none store_subtitle_info( scanned_video_part_map, dict((k, []) for k in scanned_video_part_map.keys()), None, mode="a") update_local_media(metadata, media, media_type=self.agent_type) finally: # update the menu state set_refresh_menu_state(None) # notify any running tasks about our finished update for item_id in item_ids: #scheduler.signal("updated_metadata", item_id) # resolve existing intent for that id intent.resolve("force", item_id) Dict.Save()