Added code to compensate for yt-dlp bug
This commit is contained in:
parent
028497f415
commit
bd54e08555
2 changed files with 25 additions and 3 deletions
|
|
@ -54,9 +54,22 @@ defmodule Pinchflat.Metadata.MetadataParser do
|
||||||
|> Enum.reverse()
|
|> Enum.reverse()
|
||||||
|> Enum.find_value(fn attrs -> attrs["filepath"] end)
|
|> Enum.find_value(fn attrs -> attrs["filepath"] end)
|
||||||
|
|
||||||
%{
|
if thumbnail_filepath do
|
||||||
thumbnail_filepath: thumbnail_filepath
|
# NOTE: whole ordeal needed due to a bug I found in yt-dlp
|
||||||
}
|
# https://github.com/yt-dlp/yt-dlp/issues/9445
|
||||||
|
# Can be reverted to remove this entire conditional once fixed
|
||||||
|
%{
|
||||||
|
thumbnail_filepath:
|
||||||
|
thumbnail_filepath
|
||||||
|
|> String.split(~r{\.}, include_captures: true)
|
||||||
|
|> List.insert_at(-3, "-thumb")
|
||||||
|
|> Enum.join()
|
||||||
|
}
|
||||||
|
else
|
||||||
|
%{
|
||||||
|
thumbnail_filepath: thumbnail_filepath
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp parse_infojson_metadata(metadata) do
|
defp parse_infojson_metadata(metadata) do
|
||||||
|
|
|
||||||
|
|
@ -94,6 +94,15 @@ defmodule Pinchflat.Metadata.MetadataParserTest do
|
||||||
assert String.ends_with?(result.thumbnail_filepath, ".webp")
|
assert String.ends_with?(result.thumbnail_filepath, ".webp")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# NOTE: this can be removed once this bug is fixed
|
||||||
|
# https://github.com/yt-dlp/yt-dlp/issues/9445
|
||||||
|
# and the associated conditional in the parser is removed
|
||||||
|
test "automatically appends `-thumb` to the thumbnail filename", %{metadata: metadata} do
|
||||||
|
result = Parser.parse_for_media_item(metadata)
|
||||||
|
|
||||||
|
assert String.contains?(result.thumbnail_filepath, "-thumb.webp")
|
||||||
|
end
|
||||||
|
|
||||||
test "doesn't freak out if the media has no thumbnails", %{metadata: metadata} do
|
test "doesn't freak out if the media has no thumbnails", %{metadata: metadata} do
|
||||||
metadata = Map.put(metadata, "thumbnails", %{})
|
metadata = Map.put(metadata, "thumbnails", %{})
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue