From 5bc3a0e09d16da35a1e91ef3953d0be7eaf9433f Mon Sep 17 00:00:00 2001 From: Kieran Eglin Date: Tue, 12 Mar 2024 12:07:48 -0700 Subject: [PATCH] Fixed issue with source details when first video is a premier --- lib/pinchflat/yt_dlp/media_collection.ex | 5 ++++- test/pinchflat/yt_dlp/media_collection_test.exs | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/pinchflat/yt_dlp/media_collection.ex b/lib/pinchflat/yt_dlp/media_collection.ex index 57a5450..c83ec04 100644 --- a/lib/pinchflat/yt_dlp/media_collection.ex +++ b/lib/pinchflat/yt_dlp/media_collection.ex @@ -54,7 +54,10 @@ defmodule Pinchflat.YtDlp.MediaCollection do Returns {:ok, map()} | {:error, any, ...}. """ def get_source_details(source_url) do - opts = [:simulate, :skip_download, playlist_end: 1] + # `ignore_no_formats_error` is necessary because yt-dlp will error out if + # the first video has not released yet (ie: is a premier). We don't care about + # available formats since we're just getting the source details + opts = [:simulate, :skip_download, :ignore_no_formats_error, playlist_end: 1] output_template = "%(.{channel,channel_id,playlist_id,playlist_title})j" with {:ok, output} <- backend_runner().run(source_url, opts, output_template), diff --git a/test/pinchflat/yt_dlp/media_collection_test.exs b/test/pinchflat/yt_dlp/media_collection_test.exs index 190bec6..41a0145 100644 --- a/test/pinchflat/yt_dlp/media_collection_test.exs +++ b/test/pinchflat/yt_dlp/media_collection_test.exs @@ -87,7 +87,7 @@ defmodule Pinchflat.YtDlp.MediaCollectionTest do test "it passes the expected args to the backend runner" do expect(YtDlpRunnerMock, :run, fn @channel_url, opts, ot -> - assert opts == [:simulate, :skip_download, playlist_end: 1] + assert opts == [:simulate, :skip_download, :ignore_no_formats_error, playlist_end: 1] assert ot == "%(.{channel,channel_id,playlist_id,playlist_title})j" {:ok, "{}"}