Updated video downloader to use full URL; improved docs (#35)
This commit is contained in:
parent
ebebbf7571
commit
2ca395a5bf
4 changed files with 22 additions and 17 deletions
|
|
@ -11,19 +11,21 @@ defmodule Pinchflat.Media.MediaItem do
|
||||||
alias Pinchflat.Media.MediaMetadata
|
alias Pinchflat.Media.MediaMetadata
|
||||||
alias Pinchflat.Media.MediaItemSearchIndex
|
alias Pinchflat.Media.MediaItemSearchIndex
|
||||||
|
|
||||||
@allowed_fields ~w(
|
@allowed_fields [
|
||||||
title
|
# these fields are captured on indexing
|
||||||
media_id
|
:title,
|
||||||
description
|
:media_id,
|
||||||
original_url
|
:description,
|
||||||
livestream
|
:original_url,
|
||||||
media_downloaded_at
|
:livestream,
|
||||||
media_filepath
|
:source_id,
|
||||||
subtitle_filepaths
|
# these fields are captured on download
|
||||||
thumbnail_filepath
|
:media_downloaded_at,
|
||||||
metadata_filepath
|
:media_filepath,
|
||||||
source_id
|
:subtitle_filepaths,
|
||||||
)a
|
:thumbnail_filepath,
|
||||||
|
:metadata_filepath
|
||||||
|
]
|
||||||
@required_fields ~w(title original_url livestream media_id source_id)a
|
@required_fields ~w(title original_url livestream media_id source_id)a
|
||||||
|
|
||||||
schema "media_items" do
|
schema "media_items" do
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ defmodule Pinchflat.MediaClient.VideoDownloader do
|
||||||
item_with_preloads = Repo.preload(media_item, [:metadata, source: :media_profile])
|
item_with_preloads = Repo.preload(media_item, [:metadata, source: :media_profile])
|
||||||
media_profile = item_with_preloads.source.media_profile
|
media_profile = item_with_preloads.source.media_profile
|
||||||
|
|
||||||
case download_for_media_profile(media_item.media_id, media_profile, backend) do
|
case download_for_media_profile(media_item.original_url, media_profile, backend) do
|
||||||
{:ok, parsed_json} ->
|
{:ok, parsed_json} ->
|
||||||
parser = metadata_parser(backend)
|
parser = metadata_parser(backend)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,8 @@ defmodule Pinchflat.MediaClient.VideoDownloaderTest do
|
||||||
|
|
||||||
describe "download_for_media_item/3" do
|
describe "download_for_media_item/3" do
|
||||||
test "it calls the backend runner", %{media_item: media_item} do
|
test "it calls the backend runner", %{media_item: media_item} do
|
||||||
expect(YtDlpRunnerMock, :run, fn _url, _opts, ot ->
|
expect(YtDlpRunnerMock, :run, fn url, _opts, ot ->
|
||||||
|
assert url == media_item.original_url
|
||||||
assert ot == "after_move:%()j"
|
assert ot == "after_move:%()j"
|
||||||
|
|
||||||
{:ok, render_metadata(:media_metadata)}
|
{:ok, render_metadata(:media_metadata)}
|
||||||
|
|
|
||||||
|
|
@ -10,12 +10,14 @@ defmodule Pinchflat.MediaFixtures do
|
||||||
Generate a media_item.
|
Generate a media_item.
|
||||||
"""
|
"""
|
||||||
def media_item_fixture(attrs \\ %{}) do
|
def media_item_fixture(attrs \\ %{}) do
|
||||||
|
media_id = Faker.String.base64(12)
|
||||||
|
|
||||||
{:ok, media_item} =
|
{:ok, media_item} =
|
||||||
attrs
|
attrs
|
||||||
|> Enum.into(%{
|
|> Enum.into(%{
|
||||||
media_id: Faker.String.base64(12),
|
media_id: media_id,
|
||||||
title: Faker.Commerce.product_name(),
|
title: Faker.Commerce.product_name(),
|
||||||
original_url: "https://www.youtube.com/channel/#{Faker.String.base64(12)}",
|
original_url: "https://www.youtube.com/watch?v=#{media_id}",
|
||||||
livestream: false,
|
livestream: false,
|
||||||
media_filepath: "/video/#{Faker.File.file_name(:video)}",
|
media_filepath: "/video/#{Faker.File.file_name(:video)}",
|
||||||
source_id: SourcesFixtures.source_fixture().id
|
source_id: SourcesFixtures.source_fixture().id
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue