Skip to content

Commit fe5c00d

Browse files
authored
[Enhancement] Download failures due to videos being members-only are not immediately retried (#609)
1 parent 28f0d8c commit fe5c00d

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

lib/pinchflat/downloading/media_download_worker.ex

+5-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,11 @@ defmodule Pinchflat.Downloading.MediaDownloadWorker do
129129
defp action_on_error(message) do
130130
# This will attempt re-download at the next indexing, but it won't be retried
131131
# immediately as part of job failure logic
132-
non_retryable_errors = ["Video unavailable", "Sign in to confirm"]
132+
non_retryable_errors = [
133+
"Video unavailable",
134+
"Sign in to confirm",
135+
"This video is available to this channel's members"
136+
]
133137

134138
if String.contains?(to_string(message), non_retryable_errors) do
135139
Logger.error("yt-dlp download will not be retried: #{inspect(message)}")

test/pinchflat/downloading/media_download_worker_test.exs

+16
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,22 @@ defmodule Pinchflat.Downloading.MediaDownloadWorkerTest do
147147
end)
148148
end
149149

150+
test "does not set the job to retryable you aren't a member", %{media_item: media_item} do
151+
expect(YtDlpRunnerMock, :run, 2, fn
152+
_url, :get_downloadable_status, _opts, _ot, _addl ->
153+
{:ok, "{}"}
154+
155+
_url, :download, _opts, _ot, _addl ->
156+
{:error, "This video is available to this channel's members on level: foo", 1}
157+
end)
158+
159+
Oban.Testing.with_testing_mode(:inline, fn ->
160+
{:ok, job} = Oban.insert(MediaDownloadWorker.new(%{id: media_item.id, quality_upgrade?: true}))
161+
162+
assert job.state == "completed"
163+
end)
164+
end
165+
150166
test "ensures error are returned in a 2-item tuple", %{media_item: media_item} do
151167
expect(YtDlpRunnerMock, :run, 2, fn
152168
_url, :get_downloadable_status, _opts, _ot, _addl -> {:ok, "{}"}

0 commit comments

Comments
 (0)