* Bumped up the line length because I fear no man * Refactored indexing Previously, indexing worked by collecting the video IDs of only videos that matched indexing criteria. This new model instead stores ALL videos for a given source, but will only _download_ videos that meet that criteria. This lets us backfill without indexing, makes it easier to add in other backends, lets us download one-off videos for a source that don't quite meet criteria, you name it. * Updated media finders to respect format filters; Added credo file
58 lines
1.5 KiB
Elixir
58 lines
1.5 KiB
Elixir
defmodule Pinchflat.MediaSourceFixtures do
|
|
@moduledoc """
|
|
This module defines test helpers for creating
|
|
entities via the `Pinchflat.MediaSource` context.
|
|
"""
|
|
|
|
alias Pinchflat.Repo
|
|
alias Pinchflat.ProfilesFixtures
|
|
alias Pinchflat.MediaSource.Source
|
|
|
|
@doc """
|
|
Generate a source.
|
|
"""
|
|
def source_fixture(attrs \\ %{}) do
|
|
{:ok, source} =
|
|
%Source{}
|
|
|> Source.changeset(
|
|
Enum.into(attrs, %{
|
|
collection_name: "Source ##{:rand.uniform(1_000_000)}",
|
|
collection_id: Base.encode16(:crypto.hash(:md5, "#{:rand.uniform(1_000_000)}")),
|
|
collection_type: "channel",
|
|
friendly_name: "Cool and good internal name!",
|
|
original_url: "https://www.youtube.com/channel/#{Faker.String.base64(12)}",
|
|
media_profile_id: ProfilesFixtures.media_profile_fixture().id,
|
|
index_frequency_minutes: 60
|
|
})
|
|
)
|
|
|> Repo.insert()
|
|
|
|
source
|
|
end
|
|
|
|
def source_attributes_return_fixture do
|
|
source_attributes = [
|
|
%{
|
|
id: "video1",
|
|
title: "Video 1",
|
|
original_url: "https://example.com/video1",
|
|
was_live: false
|
|
},
|
|
%{
|
|
id: "video2",
|
|
title: "Video 2",
|
|
original_url: "https://example.com/video2",
|
|
was_live: true
|
|
},
|
|
%{
|
|
id: "video3",
|
|
title: "Video 3",
|
|
original_url: "https://example.com/video3",
|
|
was_live: false
|
|
}
|
|
]
|
|
|
|
source_attributes
|
|
|> Enum.map_join("\n", &Phoenix.json_library().encode!(&1))
|
|
end
|
|
end
|