def set_refresh_menu_state(state_or_media, media_type="movies"): """ :param state_or_media: string, None, or Media argument from Agent.update() :param media_type: movies or series :return: """ if not state_or_media: # store it in last state and remove the current Dict["last_refresh_state"] = Dict["current_refresh_state"] Dict["current_refresh_state"] = None return if isinstance(state_or_media, types.StringTypes): Dict["current_refresh_state"] = state_or_media return media = state_or_media media_id = media.id title = None if media_type == "series": for season in media.seasons: for episode in media.seasons[season].episodes: ep = media.seasons[season].episodes[episode] media_id = ep.id title = format_video("show", ep.title, parent_title=media.title, season=int(season), episode=int(episode)) else: title = format_video("movie", media.title) force_refresh = intent.get("force", media_id) Dict["current_refresh_state"] = "%sRefreshing %s" % ("Force-" if force_refresh else "", title)
def scanMovieMedia(media): videos = {} forceRefresh = intent.get("force", media.id) for item in media.items: for part in item.parts: scannedVideo = scanVideo(part, "movie", ignore_all=forceRefresh) scannedVideo.id = media.id videos[scannedVideo] = part return videos
def scanTvMedia(media): videos = {} for season in media.seasons: for episode in media.seasons[season].episodes: ep = media.seasons[season].episodes[episode] forceRefresh = intent.get("force", ep.id) for item in media.seasons[season].episodes[episode].items: for part in item.parts: scannedVideo = scanVideo(part, "episode", ignore_all=forceRefresh) scannedVideo.id = media.seasons[season].episodes[episode].id videos[scannedVideo] = part return videos
def scanTvMedia(media): videos = {} for season in media.seasons: for episode in media.seasons[season].episodes: ep = media.seasons[season].episodes[episode] forceRefresh = intent.get("force", ep.id) for item in media.seasons[season].episodes[episode].items: for part in item.parts: scannedVideo = scanVideo(part, "episode", ignore_all=forceRefresh) scannedVideo.id = media.seasons[season].episodes[ episode].id videos[scannedVideo] = part return videos
def scanMovieMedia(media): videos = {} force_refresh = intent.get("force", media.id) for item in media.items: for part in item.parts: scanned_video = scanVideo(part, ignore_all=force_refresh, hints={ "type": "movie", "expected_title": [media.title] }) if not scanned_video: continue scanned_video.id = media.id videos[scanned_video] = part return videos
def scanParts(parts, kind="series"): """ receives a list of parts containing dictionaries returned by flattenToParts :param parts: :param kind: series or movies :return: dictionary of scanned videos of subliminal.video.scan_video """ ret = {} for part in parts: force_refresh = intent.get("force", part["id"]) hints = {"expected_title": [part["title"]]} hints.update({"type": "episode", "expected_series": [part["series"]]} if kind == "series" else {"type": "movie"}) scanned_video = scanVideo(part["video"], ignore_all=force_refresh, hints=hints) if not scanned_video: continue scanned_video.id = part["id"] ret[scanned_video] = part["video"] return ret
def scan_parts(parts, kind="series"): """ receives a list of parts containing dictionaries returned by flattenToParts :param parts: :param kind: series or movies :return: dictionary of subliminal.video.scan_video, key=subliminal scanned video, value=plex file part """ ret = {} for part in parts: force_refresh = intent.get("force", part["id"], part["series_id"], part["season_id"]) hints = helpers.get_item_hints(part["title"], kind, series=part["series"] if kind == "series" else None) part["video"].fps = get_stream_fps(part["video"].streams) scanned_video = scan_video(part["video"], ignore_all=force_refresh, hints=hints) if not scanned_video: continue scanned_video.id = part["id"] part_metadata = part.copy() del part_metadata["video"] scanned_video.plexapi_metadata = part_metadata ret[scanned_video] = part["video"] return ret
def scanTvMedia(media): videos = {} for season in media.seasons: for episode in media.seasons[season].episodes: ep = media.seasons[season].episodes[episode] force_refresh = intent.get("force", ep.id) for item in media.seasons[season].episodes[episode].items: for part in item.parts: scanned_video = scanVideo(part, ignore_all=force_refresh, hints={ "type": "episode", "expected_series": [media.title], "expected_title": [ep.title] }) if not scanned_video: continue scanned_video.id = media.seasons[season].episodes[ episode].id videos[scanned_video] = part return videos
def set_refresh_menu_state(state_or_media, media_type="movies"): """ :param state_or_media: string, None, or Media argument from Agent.update() :param media_type: movies or series :return: """ if not state_or_media: # store it in last state and remove the current Dict["last_refresh_state"] = Dict["current_refresh_state"] Dict["current_refresh_state"] = None return if isinstance(state_or_media, types.StringTypes): Dict["current_refresh_state"] = state_or_media return media = state_or_media media_id = media.id title = None if media_type == "series": for season in media.seasons: for episode in media.seasons[season].episodes: ep = media.seasons[season].episodes[episode] media_id = ep.id title = format_video("show", ep.title, parent_title=media.title, season=int(season), episode=int(episode)) else: title = format_video("movie", media.title) force_refresh = intent.get("force", media_id) Dict["current_refresh_state"] = "%sRefreshing %s" % ( "Force-" if force_refresh else "", title)