Exemple #1
0
def refresh_item(rating_key,
                 force=False,
                 timeout=8000,
                 refresh_kind=None,
                 parent_rating_key=None):
    intent = get_intent()

    # timeout actually is the time for which the intent will be valid
    if force:
        Log.Debug("Setting intent for force-refresh of %s to timeout: %s",
                  rating_key, timeout)
        intent.set("force", rating_key, timeout=timeout)

        # force Dict.Save()
        intent.store.save()

    refresh = [rating_key]

    if refresh_kind == "season":
        # season refresh, needs explicit per-episode refresh
        refresh = [
            item.rating_key for item in list(Plex["library/metadata"].children(
                int(rating_key)))
        ]

    multiple = len(refresh) > 1
    for key in refresh:
        Log.Info("%s item %s",
                 "Refreshing" if not force else "Forced-refreshing", key)
        Plex["library/metadata"].refresh(key)
        if multiple:
            Thread.Sleep(10.0)
Exemple #2
0
def scan_videos(videos, kind="series", ignore_all=False, no_refining=False):
    """
    receives a list of videos containing dictionaries returned by media_to_videos
    :param videos:
    :param kind: series or movies
    :return: dictionary of subliminal.video.scan_video, key=subliminal scanned video, value=plex file part
    """
    ret = {}
    for video in videos:
        intent = get_intent()
        force_refresh = intent.get("force", video["id"], video["series_id"],
                                   video["season_id"])
        Log.Debug(
            "Determining force-refresh (video: %s, series: %s, season: %s), result: %s"
            % (video["id"], video["series_id"], video["season_id"],
               force_refresh))

        hints = helpers.get_item_hints(video)
        video["plex_part"].fps = get_stream_fps(video["plex_part"].streams)
        scanned_video = scan_video(video,
                                   ignore_all=force_refresh or ignore_all,
                                   hints=hints,
                                   rating_key=video["id"],
                                   no_refining=no_refining)

        if not scanned_video:
            continue

        scanned_video.id = video["id"]
        part_metadata = video.copy()
        del part_metadata["plex_part"]
        scanned_video.plexapi_metadata = part_metadata
        ret[scanned_video] = video["plex_part"]
    return ret
Exemple #3
0
def refresh_item(rating_key, force=False, timeout=8000, refresh_kind=None, parent_rating_key=None):
    intent = get_intent()

    # timeout actually is the time for which the intent will be valid
    if force:
        Log.Debug("Setting intent for force-refresh of %s to timeout: %s", rating_key, timeout)
        intent.set("force", rating_key, timeout=timeout)

        # force Dict.Save()
        intent.store.save()

    refresh = [rating_key]

    if refresh_kind == "season":
        # season refresh, needs explicit per-episode refresh
        refresh = [item.rating_key for item in list(Plex["library/metadata"].children(int(rating_key)))]

    multiple = len(refresh) > 1
    for key in refresh:
        Log.Info("%s item %s", "Refreshing" if not force else "Forced-refreshing", key)
        Plex["library/metadata"].refresh(key)
        if multiple:
            Thread.Sleep(10.0)