From 958c2fa6d261941e024a2169ce82f8e870038ca4 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 19 Jun 2023 15:01:47 -0400 Subject: [PATCH] Improve resuming interrupted download when using yt-dlp or youtube-dl Fixes a failure like this: curl: (33) HTTP server doesn't seem to support byte ranges. Cannot resume. That happens because the whole web page has already been downloaded previously, and kept, so now addurl tries to download it, and curl asks the server to resume from the last byte. And youtube.com can't, for whatever stupid reason. So, delete the temp file after determining that youtube-dl can be used. --- CHANGELOG | 2 +- Command/AddUrl.hs | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index c3023b7ed4..ed6c552493 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -93,7 +93,7 @@ git-annex (10.20230408) UNRELEASED; urgency=medium * Fix display when run with -J1. * assistant: Fix a crash when a small file is deleted immediately after being created. - * Improve resuming interrupted download when using yt-dlp. + * Improve resuming interrupted download when using yt-dlp or youtube-dl. -- Joey Hess Sat, 08 Apr 2023 13:57:18 -0400 diff --git a/Command/AddUrl.hs b/Command/AddUrl.hs index f474e77573..988131c89e 100644 --- a/Command/AddUrl.hs +++ b/Command/AddUrl.hs @@ -343,9 +343,10 @@ downloadWeb addunlockedmatcher o url urlinfo file = -- Ask youtube-dl what filename it will download first, -- so it's only used when the file contains embedded media. tryyoutubedl tmp backend = youtubeDlFileNameHtmlOnly url >>= \case - Right mediafile -> + Right mediafile -> do + liftIO $ liftIO $ removeWhenExistsWith R.removeLink tmp let f = youtubeDlDestFile o file (toRawFilePath mediafile) - in lookupKey f >>= \case + lookupKey f >>= \case Just k -> alreadyannexed f k Nothing -> dl f Left err -> checkRaw (Just err) o (pure Nothing) (normalfinish tmp backend)