[Enhancement] Download image when using playlists with media center apps (#313)
* [WIP] started adding calls for downloading posters for playlists * Updated source image parser to work with playlists
This commit is contained in:
1 parent
0d5a41fd35
commit
5a10015634
6 files changed
+171
-27
No files matched your search
@@ -75,4 +75,51 @@ defmodule Pinchflat.Metadata.SourceImageParserTest do
|
||||
assert SourceImageParser.store_source_images(@base_dir, metadata) == %{}
|
||||
end
|
||||
end
|
||||
|
||||
describe "store_source_images/2 when testing fallbacks" do
|
||||
test "uses the entries list for a fallback poster if needed" do
|
||||
metadata = %{
|
||||
"thumbnails" => [],
|
||||
"entries" => [
|
||||
%{
|
||||
"thumbnails" => [%{"filepath" => "/app/test/support/files/channel_photos/a.0.jpg"}]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
expected = %{
|
||||
poster_filepath: "#{@base_dir}/poster.jpg"
|
||||
}
|
||||
|
||||
assert SourceImageParser.store_source_images(@base_dir, metadata) == expected
|
||||
end
|
||||
|
||||
test "doesn't blow up if the entries list doesn't have any suitable thumbnails" do
|
||||
metadata = %{
|
||||
"thumbnails" => [],
|
||||
"entries" => [
|
||||
%{"thumbnails" => [%{"id" => "1"}]}
|
||||
]
|
||||
}
|
||||
|
||||
assert SourceImageParser.store_source_images(@base_dir, metadata) == %{}
|
||||
end
|
||||
|
||||
test "doesn't use the entries list if it's empty" do
|
||||
metadata = %{
|
||||
"thumbnails" => [],
|
||||
"entries" => []
|
||||
}
|
||||
|
||||
assert SourceImageParser.store_source_images(@base_dir, metadata) == %{}
|
||||
end
|
||||
|
||||
test "doesn't use the entries list if it's not present" do
|
||||
metadata = %{
|
||||
"thumbnails" => []
|
||||
}
|
||||
|
||||
assert SourceImageParser.store_source_images(@base_dir, metadata) == %{}
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -143,7 +143,9 @@ defmodule Pinchflat.Metadata.SourceMetadataStorageWorkerTest do
|
||||
|
||||
{:ok, source_details_return_fixture(%{filename: filename})}
|
||||
|
||||
_url, _opts, ot when ot == @metadata_ot ->
|
||||
_url, opts, ot when ot == @metadata_ot ->
|
||||
assert {:convert_thumbnails, "jpg"} in opts
|
||||
|
||||
{:ok, render_metadata(:channel_source_metadata)}
|
||||
end)
|
||||
|
||||
@@ -164,6 +166,42 @@ defmodule Pinchflat.Metadata.SourceMetadataStorageWorkerTest do
|
||||
Sources.delete_source(source, delete_files: true)
|
||||
end
|
||||
|
||||
test "calls one set of yt-dlp metadata opts for channels" do
|
||||
stub(YtDlpRunnerMock, :run, fn
|
||||
_url, _opts, ot when ot == @source_details_ot ->
|
||||
{:ok, source_details_return_fixture()}
|
||||
|
||||
_url, opts, ot when ot == @metadata_ot ->
|
||||
assert {:playlist_items, 0} in opts
|
||||
assert :write_all_thumbnails in opts
|
||||
|
||||
{:ok, render_metadata(:channel_source_metadata)}
|
||||
end)
|
||||
|
||||
profile = media_profile_fixture(%{download_source_images: true})
|
||||
source = source_fixture(media_profile_id: profile.id, collection_type: :channel)
|
||||
|
||||
perform_job(SourceMetadataStorageWorker, %{id: source.id})
|
||||
end
|
||||
|
||||
test "calls another set of yt-dlp metadata opts for playlists" do
|
||||
stub(YtDlpRunnerMock, :run, fn
|
||||
_url, _opts, ot when ot == @source_details_ot ->
|
||||
{:ok, source_details_return_fixture()}
|
||||
|
||||
_url, opts, ot when ot == @metadata_ot ->
|
||||
assert {:playlist_items, 1} in opts
|
||||
assert :write_thumbnail in opts
|
||||
|
||||
{:ok, render_metadata(:channel_source_metadata)}
|
||||
end)
|
||||
|
||||
profile = media_profile_fixture(%{download_source_images: true})
|
||||
source = source_fixture(media_profile_id: profile.id, collection_type: :playlist)
|
||||
|
||||
perform_job(SourceMetadataStorageWorker, %{id: source.id})
|
||||
end
|
||||
|
||||
test "does not store source images if the profile is not set to" do
|
||||
stub(YtDlpRunnerMock, :run, fn
|
||||
_url, _opts, ot when ot == @source_details_ot ->
|
||||
|
||||
Reference in new issue
Block a user