Updated video metadata parser to extract the title
This commit is contained in:
parent
cfdba60b67
commit
b2de1e6aa6
3 changed files with 11 additions and 3 deletions
|
|
@ -17,6 +17,7 @@ defmodule Pinchflat.MediaClient.Backends.YtDlp.MetadataParser do
|
|||
"""
|
||||
def parse_for_media_item(metadata) do
|
||||
%{
|
||||
title: metadata["title"],
|
||||
video_filepath: metadata["filepath"],
|
||||
metadata: %{
|
||||
client_response: metadata
|
||||
|
|
|
|||
|
|
@ -30,6 +30,12 @@ defmodule Pinchflat.MediaClient.Backends.YtDlp.MediaParserTest do
|
|||
assert String.ends_with?(result.video_filepath, ".mkv")
|
||||
end
|
||||
|
||||
test "it extracts the title", %{metadata: metadata} do
|
||||
result = Parser.parse_for_media_item(metadata)
|
||||
|
||||
assert result.title == "Trying to Wheelie Without the Rear Brake"
|
||||
end
|
||||
|
||||
test "it returns the metadata as a map", %{metadata: metadata} do
|
||||
result = Parser.parse_for_media_item(metadata)
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ defmodule Pinchflat.MediaClient.VideoDownloaderTest do
|
|||
setup do
|
||||
media_item =
|
||||
Repo.preload(
|
||||
media_item_fixture(%{video_filepath: nil}),
|
||||
media_item_fixture(%{title: nil, video_filepath: nil}),
|
||||
[:metadata, channel: :media_profile]
|
||||
)
|
||||
|
||||
|
|
@ -33,9 +33,10 @@ defmodule Pinchflat.MediaClient.VideoDownloaderTest do
|
|||
{:ok, render_metadata(:media_metadata)}
|
||||
end)
|
||||
|
||||
assert is_nil(media_item.video_filepath)
|
||||
assert %{video_filepath: nil, title: nil} = media_item
|
||||
assert {:ok, updated_media_item} = VideoDownloader.download_for_media_item(media_item)
|
||||
assert is_binary(updated_media_item.video_filepath)
|
||||
assert updated_media_item.video_filepath
|
||||
assert updated_media_item.title
|
||||
end
|
||||
|
||||
test "it saves the metadata to the database", %{media_item: media_item} do
|
||||
|
|
|
|||
Loading…
Reference in a new issue