def RecentMissingSubtitlesMenu(force=False, randomize=None): title = _("Items with missing subtitles") oc = SubFolderObjectContainer(title2=title, no_cache=True, no_history=True) running = scheduler.is_task_running("MissingSubtitles") task_data = scheduler.get_task_data("MissingSubtitles") missing_items = task_data["missing_subtitles"] if task_data else None if ((missing_items is None) or force) and not running: scheduler.dispatch_task("MissingSubtitles") running = True if not running: oc.add( DirectoryObject( key=Callback(RecentMissingSubtitlesMenu, force=True, randomize=timestamp()), title=_(u"Find recent items with missing subtitles"), thumb=default_thumb)) else: oc.add( DirectoryObject(key=Callback(RecentMissingSubtitlesMenu, force=False, randomize=timestamp()), title=_(u"Updating, refresh here ..."), thumb=default_thumb)) if missing_items is not None: for added_at, item_id, item_title, item, missing_languages in missing_items: oc.add( DirectoryObject(key=Callback(ItemDetailsMenu, title=title + " > " + item_title, item_title=item_title, rating_key=item_id), title=item_title, summary=_( "Missing: %s", ", ".join( display_language(l) for l in missing_languages)), thumb=get_item_thumb(item) or default_thumb)) return oc
def RecentMissingSubtitlesMenu(force=False, randomize=None): title = _("Items with missing subtitles") oc = SubFolderObjectContainer(title2=title, no_cache=True, no_history=True) running = scheduler.is_task_running("MissingSubtitles") task_data = scheduler.get_task_data("MissingSubtitles") missing_items = task_data["missing_subtitles"] if task_data else None if ((missing_items is None) or force) and not running: scheduler.dispatch_task("MissingSubtitles") running = True if not running: oc.add(DirectoryObject( key=Callback(RecentMissingSubtitlesMenu, force=True, randomize=timestamp()), title=_(u"Find recent items with missing subtitles"), thumb=default_thumb )) else: oc.add(DirectoryObject( key=Callback(RecentMissingSubtitlesMenu, force=False, randomize=timestamp()), title=_(u"Updating, refresh here ..."), thumb=default_thumb )) if missing_items is not None: for added_at, item_id, item_title, item, missing_languages in missing_items: oc.add(DirectoryObject( key=Callback(ItemDetailsMenu, title=title + " > " + item_title, item_title=item_title, rating_key=item_id), title=item_title, summary=_("Missing: %s", ", ".join(display_language(l) for l in missing_languages)), thumb=get_item_thumb(item) or default_thumb )) return oc
def ListAvailableSubsForItemMenu(rating_key=None, part_id=None, title=None, item_title=None, filename=None, item_type="episode", language=None, language_name=None, force=False, current_id=None, current_data=None, current_provider=None, current_score=None, randomize=None): assert rating_key, part_id running = scheduler.is_task_running("AvailableSubsForItem") search_results = get_item_task_data("AvailableSubsForItem", rating_key, language) if (search_results is None or force) and not running: scheduler.dispatch_task("AvailableSubsForItem", rating_key=rating_key, item_type=item_type, part_id=part_id, language=language) running = True oc = SubFolderObjectContainer(title2=unicode(title), replace_parent=True) oc.add(DirectoryObject( key=Callback(ItemDetailsMenu, rating_key=rating_key, item_title=item_title, title=title, randomize=timestamp()), title=u"< Back to %s" % title, summary=current_data, thumb=default_thumb )) metadata = get_plex_metadata(rating_key, part_id, item_type) plex_part = None if not config.low_impact_mode: scanned_parts = scan_videos([metadata], ignore_all=True) if not scanned_parts: Log.Error("Couldn't list available subtitles for %s", rating_key) return oc video, plex_part = scanned_parts.items()[0] video_display_data = [video.format] if video.format else [] if video.release_group: video_display_data.append(u"by %s" % video.release_group) video_display_data = " ".join(video_display_data) else: video_display_data = metadata["filename"] current_display = (u"Current: %s (%s) " % (current_provider, current_score) if current_provider else "") if not running: oc.add(DirectoryObject( key=Callback(ListAvailableSubsForItemMenu, rating_key=rating_key, item_title=item_title, language=language, filename=filename, part_id=part_id, title=title, current_id=current_id, force=True, current_provider=current_provider, current_score=current_score, current_data=current_data, item_type=item_type, randomize=timestamp()), title=u"Search for %s subs (%s)" % (get_language(language).name, video_display_data), summary=u"%sFilename: %s" % (current_display, filename), thumb=default_thumb )) if search_results == "found_none": oc.add(DirectoryObject( key=Callback(ListAvailableSubsForItemMenu, rating_key=rating_key, item_title=item_title, language=language, filename=filename, current_data=current_data, force=True, part_id=part_id, title=title, current_id=current_id, item_type=item_type, current_provider=current_provider, current_score=current_score, randomize=timestamp()), title=u"No subtitles found", summary=u"%sFilename: %s" % (current_display, filename), thumb=default_thumb )) else: oc.add(DirectoryObject( key=Callback(ListAvailableSubsForItemMenu, rating_key=rating_key, item_title=item_title, language=language, filename=filename, current_data=current_data, part_id=part_id, title=title, current_id=current_id, item_type=item_type, current_provider=current_provider, current_score=current_score, randomize=timestamp()), title=u"Searching for %s subs (%s), refresh here ..." % (display_language(get_language(language)), video_display_data), summary=u"%sFilename: %s" % (current_display, filename), thumb=default_thumb )) if not search_results or search_results == "found_none": return oc current_sub, stored_subs, storage = get_current_sub(rating_key, part_id, language) current_bl, subs = stored_subs.get_blacklist(part_id, language) seen = [] for subtitle in search_results: if subtitle.id in seen: continue bl_addon = "" if (str(subtitle.provider_name), str(subtitle.id)) in current_bl: bl_addon = "Blacklisted " wrong_fps_addon = "" if subtitle.wrong_fps: if plex_part: wrong_fps_addon = " (wrong FPS, sub: %s, media: %s)" % (subtitle.fps, plex_part.fps) else: wrong_fps_addon = " (wrong FPS, sub: %s, media: unknown, low impact mode)" % subtitle.fps oc.add(DirectoryObject( key=Callback(TriggerDownloadSubtitle, rating_key=rating_key, randomize=timestamp(), item_title=item_title, subtitle_id=str(subtitle.id), language=language), title=u"%s%s: %s, score: %s%s" % (bl_addon, "Available" if current_id != subtitle.id else "Current", subtitle.provider_name, subtitle.score, wrong_fps_addon), summary=u"Release: %s, Matches: %s" % (subtitle.release_info, ", ".join(subtitle.matches)), thumb=default_thumb )) seen.append(subtitle.id) return oc
def ListAvailableSubsForItemMenu(rating_key=None, part_id=None, title=None, item_title=None, filename=None, item_type="episode", language=None, language_name=None, force=False, current_id=None, current_data=None, current_provider=None, current_score=None, randomize=None): assert rating_key, part_id running = scheduler.is_task_running("AvailableSubsForItem") search_results = get_item_task_data("AvailableSubsForItem", rating_key, language) current_data = unicode(current_data) if current_data else None if (search_results is None or force) and not running: scheduler.dispatch_task("AvailableSubsForItem", rating_key=rating_key, item_type=item_type, part_id=part_id, language=language) running = True oc = SubFolderObjectContainer(title2=unicode(title), replace_parent=True) oc.add(DirectoryObject( key=Callback(ItemDetailsMenu, rating_key=rating_key, item_title=item_title, title=title, randomize=timestamp()), title=_(u"< Back to %s", title), summary=current_data, thumb=default_thumb )) metadata = get_plex_metadata(rating_key, part_id, item_type) plex_part = None if not config.low_impact_mode: scanned_parts = scan_videos([metadata], ignore_all=True) if not scanned_parts: Log.Error("Couldn't list available subtitles for %s", rating_key) return oc video, plex_part = scanned_parts.items()[0] video_display_data = [video.format] if video.format else [] if video.release_group: video_display_data.append(unicode(_(u"by %(release_group)s", release_group=video.release_group))) video_display_data = " ".join(video_display_data) else: video_display_data = metadata["filename"] current_display = (_(u"Current: %(provider_name)s (%(score)s) ", provider_name=_(current_provider), score=current_score if current_provider else "")) if not running: oc.add(DirectoryObject( key=Callback(ListAvailableSubsForItemMenu, rating_key=rating_key, item_title=item_title, language=language, filename=filename, part_id=part_id, title=title, current_id=current_id, force=True, current_provider=current_provider, current_score=current_score, current_data=current_data, item_type=item_type, randomize=timestamp()), title=_(u"Search for %(language)s subs (%(video_data)s)", language=get_language(language).name, video_data=video_display_data), summary=_(u"%(current_info)sFilename: %(filename)s", current_info=current_display, filename=filename), thumb=default_thumb )) if search_results == "found_none": oc.add(DirectoryObject( key=Callback(ListAvailableSubsForItemMenu, rating_key=rating_key, item_title=item_title, language=language, filename=filename, current_data=current_data, force=True, part_id=part_id, title=title, current_id=current_id, item_type=item_type, current_provider=current_provider, current_score=current_score, randomize=timestamp()), title=_(u"No subtitles found"), summary=_(u"%(current_info)sFilename: %(filename)s", current_info=current_display, filename=filename), thumb=default_thumb )) else: oc.add(DirectoryObject( key=Callback(ListAvailableSubsForItemMenu, rating_key=rating_key, item_title=item_title, language=language, filename=filename, current_data=current_data, part_id=part_id, title=title, current_id=current_id, item_type=item_type, current_provider=current_provider, current_score=current_score, randomize=timestamp()), title=_(u"Searching for %(language)s subs (%(video_data)s), refresh here ...", language=display_language(get_language(language)), video_data=video_display_data), summary=_(u"%(current_info)sFilename: %(filename)s", current_info=current_display, filename=filename), thumb=default_thumb )) if not search_results or search_results == "found_none": return oc current_sub, stored_subs, storage = get_current_sub(rating_key, part_id, language) current_bl, subs = stored_subs.get_blacklist(part_id, language) seen = [] for subtitle in search_results: if subtitle.id in seen: continue bl_addon = "" if (str(subtitle.provider_name), str(subtitle.id)) in current_bl: bl_addon = "Blacklisted " wrong_fps_addon = "" wrong_series_addon = "" wrong_season_ep_addon = "" if subtitle.wrong_fps: if plex_part: wrong_fps_addon = _(" (wrong FPS, sub: %(subtitle_fps)s, media: %(media_fps)s)", subtitle_fps=subtitle.fps, media_fps=plex_part.fps) else: wrong_fps_addon = _(" (wrong FPS, sub: %(subtitle_fps)s, media: unknown, low impact mode)", subtitle_fps=subtitle.fps) if subtitle.wrong_series: wrong_series_addon = _(" (possibly wrong series)") if subtitle.wrong_season_ep: wrong_season_ep_addon = _(" (possibly wrong season/episode)") oc.add(DirectoryObject( key=Callback(TriggerDownloadSubtitle, rating_key=rating_key, randomize=timestamp(), item_title=item_title, subtitle_id=str(subtitle.id), language=language), title=_(u"%(blacklisted_state)s%(current_state)s: %(provider_name)s, score: %(score)s%(wrong_fps_state)s" u"%(wrong_series_state)s%(wrong_season_ep_state)s", blacklisted_state=bl_addon, current_state=_("Available") if current_id != subtitle.id else _("Current"), provider_name=_(subtitle.provider_name), score=subtitle.score, wrong_fps_state=wrong_fps_addon, wrong_series_state=wrong_series_addon, wrong_season_ep_state=wrong_season_ep_addon), summary=_(u"Release: %(release_info)s, Matches: %(matches)s", release_info=subtitle.release_info, matches=", ".join(subtitle.matches)), thumb=default_thumb )) seen.append(subtitle.id) return oc