[Bugfix] Improve livestream detection (#362)
* Livestream status is now based off live_status instead of was_live * Updated tests
This commit is contained in:
@@ -101,7 +101,7 @@ defmodule Pinchflat.FastIndexing.FastIndexingHelpersTest do
|
||||
id: "video2",
|
||||
title: "Video 2",
|
||||
webpage_url: "https://example.com/shorts/video2",
|
||||
was_live: true,
|
||||
live_status: "is_live",
|
||||
description: "desc2",
|
||||
aspect_ratio: 1.67,
|
||||
duration: 345.67,
|
||||
|
||||
@@ -43,11 +43,12 @@ defmodule Pinchflat.Metadata.MetadataParserTest do
|
||||
test "it extracts the livestream flag", %{metadata: metadata} do
|
||||
result = Parser.parse_for_media_item(metadata)
|
||||
|
||||
assert result.livestream == metadata["was_live"]
|
||||
assert metadata["live_status"] == "not_live"
|
||||
refute result.livestream
|
||||
end
|
||||
|
||||
test "the livestream flag defaults to false", %{metadata: metadata} do
|
||||
metadata = Map.put(metadata, "was_live", nil)
|
||||
metadata = Map.put(metadata, "live_status", nil)
|
||||
|
||||
result = Parser.parse_for_media_item(metadata)
|
||||
|
||||
|
||||
@@ -173,7 +173,7 @@ defmodule Pinchflat.SlowIndexing.SlowIndexingHelpersTest do
|
||||
Phoenix.json_library().encode!(%{
|
||||
id: "video3",
|
||||
title: "Video 3",
|
||||
was_live: false,
|
||||
live_status: "not_live",
|
||||
description: "desc3",
|
||||
# Only focusing on these because these are passed to functions that
|
||||
# could fail if they're not present
|
||||
@@ -289,7 +289,7 @@ defmodule Pinchflat.SlowIndexing.SlowIndexingHelpersTest do
|
||||
id: "video2",
|
||||
title: "Video 2",
|
||||
webpage_url: "https://example.com/shorts/video2",
|
||||
was_live: true,
|
||||
live_status: "is_live",
|
||||
description: "desc2",
|
||||
aspect_ratio: 1.67,
|
||||
duration: 345.67,
|
||||
|
||||
@@ -138,7 +138,9 @@ defmodule Pinchflat.YtDlp.MediaTest do
|
||||
|
||||
describe "indexing_output_template/0" do
|
||||
test "contains all the greatest hits" do
|
||||
attrs = ~w(id title was_live webpage_url description aspect_ratio duration upload_date timestamp playlist_index)a
|
||||
attrs =
|
||||
~w(id title live_status webpage_url description aspect_ratio duration upload_date timestamp playlist_index)a
|
||||
|
||||
formatted_attrs = "%(.{#{Enum.join(attrs, ",")}})j"
|
||||
|
||||
assert formatted_attrs == Media.indexing_output_template()
|
||||
@@ -152,7 +154,7 @@ defmodule Pinchflat.YtDlp.MediaTest do
|
||||
"title" => "Trying to Wheelie Without the Rear Brake",
|
||||
"description" => "I'm not sure what I expected.",
|
||||
"webpage_url" => "https://www.youtube.com/watch?v=TiZPUDkDYbk",
|
||||
"was_live" => false,
|
||||
"live_status" => "not_live",
|
||||
"aspect_ratio" => 1.0,
|
||||
"duration" => 60,
|
||||
"upload_date" => "20210101",
|
||||
@@ -239,7 +241,7 @@ defmodule Pinchflat.YtDlp.MediaTest do
|
||||
assert %Media{duration_seconds: nil} = Media.response_to_struct(response)
|
||||
end
|
||||
|
||||
test "sets livestream to false if the was_live field isn't present" do
|
||||
test "sets livestream to false if the live_status field isn't present" do
|
||||
response = %{
|
||||
"webpage_url" => "https://www.youtube.com/watch?v=TiZPUDkDYbk",
|
||||
"aspect_ratio" => 1.0,
|
||||
|
||||
Reference in New Issue
Block a user