New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expand video attached image extraction to support multiple images/types #6689
Conversation
if (!string.Equals(streamInfo.CodecType, "attachment", StringComparison.OrdinalIgnoreCase) && | ||
!(streamInfo.Disposition != null && streamInfo.Disposition.GetValueOrDefault("attached_pic") == 1)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Attached images in mkv files are currently parsed as MediaStream
s with MediaStreamType.EmbeddedImage
(see line 738 of this file). To determine the type of an attached image I needed the filename and/or mimetype fields, which are only stored for MediaAttachment
s.
This was the minimal change to store the available metadata in the current structures, but it results in storing attached images in both the MediaAttachment
and MediaStream
lists. If there is a better way to store the data I'm open to suggestions.
tests/Jellyfin.Providers.Tests/MediaInfo/EmbeddedImageProviderTests.cs
Outdated
Show resolved
Hide resolved
1394d71
to
3353f7b
Compare
tests/Jellyfin.Providers.Tests/MediaInfo/VideoImageProviderTests.cs
Outdated
Show resolved
Hide resolved
tests/Jellyfin.Providers.Tests/MediaInfo/VideoImageProviderTests.cs
Outdated
Show resolved
Hide resolved
tests/Jellyfin.Providers.Tests/MediaInfo/VideoImageProviderTests.cs
Outdated
Show resolved
Hide resolved
tests/Jellyfin.Providers.Tests/MediaInfo/VideoImageProviderTests.cs
Outdated
Show resolved
Hide resolved
tests/Jellyfin.Providers.Tests/MediaInfo/VideoImageProviderTests.cs
Outdated
Show resolved
Hide resolved
4327e85
to
7bb9de4
Compare
string validatedOutputExtension; | ||
if (string.IsNullOrEmpty(outputExtension)) | ||
{ | ||
validatedOutputExtension = ".jpg"; | ||
} | ||
else if (outputExtension.FirstOrDefault() != '.') | ||
{ | ||
validatedOutputExtension = "." + outputExtension; | ||
} | ||
else | ||
{ | ||
validatedOutputExtension = outputExtension; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I would put this in ExtractImageInternal
and rewrite it as this
if (string.IsNullOrEmpty(outputExtension))
{
outputExtension = ".jpg";
}
else if (outputExtension[0] != '.')
{
outputExtension = "." + outputExtension;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the slow response, was away for the weekend without electronics.
Rider underlined it when I reassigned a parameter so I thought that was discouraged. I prefer this pattern as well, and I forget why I put it one method earlier in the call chain.
If this completes what you want changed let me know and I'd be happy to squash the review comment commits to clean up the git log.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rider underlined it when I reassigned a parameter so I thought that was discouraged. I prefer this pattern as well, and I forget why I put it one method earlier in the call chain.
I get why it underlines it. It's not nice, but in this case I think a new variable is overkill.
If this completes what you want changed let me know and I'd be happy to squash the review comment commits to clean up the git log.
I don't particularly care, but if you want to squash it, the go ahead (and I see you did).
tests/Jellyfin.Providers.Tests/MediaInfo/VideoImageProviderTests.cs
Outdated
Show resolved
Hide resolved
Clean up style Fix references in class summaries Combine Where+FirstOrDefault queries Break up large method, long lines Add validation on file extension Apply test naming conventions Extract mock of Movie class, comment on why not mocking interface Co-authored-by: Cody Robibero <cody@robibe.ro> Co-authored-by: Claus Vium <cvium@users.noreply.github.com>
454dc1a
to
31baea0
Compare
Changes
VideoImageProvider
to createEmbeddedImageProvider
: Video for taking a screenshot of a video, Embedded for extracting image attachments.EmbeddedImageProvider
to support multiple embedded image types in the same file: Primary, Background, LogoVideoImageProvider
andEmbeddedImageProvider
Rationale
VideoImageProvider
into a separate provider. To minimize disruption the default order is for the new embedded provider to come just before the old one, which matches the behavior of the old combined provider.