intro-skipper icon indicating copy to clipboard operation
intro-skipper copied to clipboard

Support analyze .strm files

Open bitxeno opened this issue 1 month ago • 8 comments

Add support for analyzing .strm files and include an option to disable this feature. Since analyzing .strm files may trigger rate limits, it is turned off by default.

#594

Summary by Sourcery

Enable support for analyzing .strm shortcut videos by tracking and routing analysis to their real paths, probing durations with ffprobe to adjust fingerprinting, and controlling the feature via a new ProcessShortcutVideos configuration option.

New Features:

  • Add ProcessShortcutVideos option to enable or disable analyzing .strm shortcut files

Enhancements:

  • Introduce IsShortcut and ShortcutPath on queued media and route FFmpeg analysis to shortcut paths where applicable
  • Integrate ffprobe-based duration probing to determine real runtime for shortcut files and adjust fingerprint analysis ranges
  • Update QueueManager to skip or process shortcut videos based on the new setting and recalculate intro/credits segments after probing duration

Documentation:

  • Add ProcessShortcutVideos checkbox to the plugin configuration UI

bitxeno avatar Nov 15 '25 03:11 bitxeno

Reviewer's Guide

Implements optional support for analyzing .strm shortcut files by extending the data model with shortcut metadata and a new configuration flag, updating the queue logic to initialize, skip or probe shortcut items based on that setting, adapting FFmpegWrapper to use shortcut paths and adding ffprobe-based duration probing methods, and exposing a ProcessShortcutVideos option in the UI.

Entity relationship diagram for shortcut video support in QueuedEpisode

erDiagram
QUEUEDEPISODE {
  string Path
  string ShortcutPath
  bool IsShortcut
}
PLUGINCONFIGURATION {
  bool ProcessShortcutVideos
}
QUEUEDEPISODE ||--|| PLUGINCONFIGURATION : "uses config for shortcut processing"

Class diagram for updated QueuedEpisode and PluginConfiguration

classDiagram
class QueuedEpisode {
  string Path
  string ShortcutPath
  bool IsExcluded
  bool IsShortcut
  ...
}
class PluginConfiguration {
  bool AnalyzeSeasonZero
  bool ProcessShortcutVideos
  ...
}

File-Level Changes

Change Details Files
Introduce shortcut metadata and configuration flag for processing .strm files
  • Add ShortcutPath and IsShortcut properties to queued media
  • Add ProcessShortcutVideos property (default false) to plugin configuration
IntroSkipper/Data/QueuedEpisode.cs
IntroSkipper/Configuration/PluginConfiguration.cs
Expose ProcessShortcutVideos setting in the configuration UI
  • Insert checkbox and description for ProcessShortcutVideos in configPage.html
  • Include ProcessShortcutVideos in the booleanConfigurationFields array
IntroSkipper/Configuration/configPage.html
Adapt FFmpegWrapper to handle shortcut paths and add ffprobe duration probing
  • Use episode.ShortcutPath when IsShortcut is true across silence, black frame, keyframe detection and fingerprinting
  • Implement ProbeDuration method to retrieve media duration via ffprobe
  • Add GetProbeOutput helper to run ffprobe and capture output
IntroSkipper/FFmpegWrapper.cs
Update queue management to initialize, skip, and probe shortcut media
  • Set IsShortcut and ShortcutPath when queuing episodes and movies
  • Skip shortcut items early if processing is disabled
  • Probe duration for uninitialized shortcuts and recalculate intro/credits ranges
IntroSkipper/Manager/QueueManager.cs

Possibly linked issues

  • #594: The PR adds support for analyzing .strm files by using ffprobe to determine media duration and provides a toggle for this feature.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an issue from a review comment by replying to it. You can also reply to a review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull request title to generate a title at any time. You can also comment @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in the pull request body to generate a PR summary at any time exactly where you want it. You can also comment @sourcery-ai summary on the pull request to (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the pull request to resolve all Sourcery comments. Useful if you've already addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull request to dismiss all existing Sourcery reviews. Especially useful if you want to start fresh with a new review - don't forget to comment @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

  • Contact our support team for questions or feedback.
  • Visit our documentation for detailed guides and information.
  • Keep in touch with the Sourcery team by following us on X/Twitter, LinkedIn or GitHub.

sourcery-ai[bot] avatar Nov 15 '25 03:11 sourcery-ai[bot]

I'm not sure "shortcut" is the best name for it. That's just personal opinion, though. You may also want to consider the suggestion sourcery had about checking ffprobe for a clean exit, since we are talking about videos that don't actually exist on the system.

AbandonedCart avatar Nov 15 '25 04:11 AbandonedCart

I'm not sure "shortcut" is the best name for it. That's just personal opinion, though. You may also want to consider the suggestion sourcery had about checking ffprobe for a clean exit, since we are talking about videos that don't actually exist on the system.

The name "shortcut" following Jellyfin's. Do you have any alternative naming suggestions? I have modified it to ensure ffprobe exits cleanly.

bitxeno avatar Nov 15 '25 06:11 bitxeno

I need to point out that analyzing a large number of .strm files with ffmpeg does easily trigger rate limits. My current implementation is indeed not very good and tends to trigger restrictions, making it generally difficult to complete the analysis. It may be better to use another task to analyze in batches slowly.

bitxeno avatar Nov 15 '25 06:11 bitxeno

Something as simple as "isShortcutVideo" would avoid any references being mistaken as a different type of shortcut down the line.

AbandonedCart avatar Nov 15 '25 09:11 AbandonedCart

What copilot is complaining about with the exit codes can be silenced with something like

        ffprobe.WaitForExit(timeout);

        if (ffprobe.HasExited)
        {
            if (ffprobe.ExitCode != 0)
            {
                Logger?.LogWarning("ffprobe exited with code {ExitCode} for arguments: {Arguments}", ffprobe.ExitCode, ffprobe.StartInfo.Arguments);
            }
        } else {
            // Handle timeout: kill process and log error
            try
            {
                ffprobe.Kill();
            }
            catch (InvalidOperationException)
            {
                // ignore if already exited
            }
            catch (Exception ex)
            {
                Logger?.LogWarning("Unexpected exception when killing ffprobe: {Message}", ex.Message);
            }
        }

And thanks for the submission. This is something that has been requested before.

AbandonedCart avatar Nov 15 '25 09:11 AbandonedCart

I don't think we will add this feature. From my point of view, it would just cause a lot of support work on our side. It makes sense that Jellyfin doesn't store the duration, given that the content of the file can change at any time.

jumoog avatar Nov 15 '25 19:11 jumoog

Okay, Jellyfin will store the duration after the media has been played,possibly due to the request rate limit.

bitxeno avatar Nov 16 '25 01:11 bitxeno