Skip to content

Commit

Permalink
feat: Copy cookies.txt before used
Browse files Browse the repository at this point in the history
- Add support for using cookies in LiveChatDownloadService
- Set the cookies file for live_chatOptionSet and info_jsonOptionSet
- Log a message when cookies file is detected and used for yt-dlp
- Create a copy of the cookies file and use it as the cookies file

Signed-off-by: 陳鈞 <[email protected]>
  • Loading branch information
jim60105 committed Dec 3, 2023
1 parent 0352deb commit 22f3c09
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Services/LiveChatDownloadService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,13 @@ private Task<int> ExecuteAsyncInternal(CancellationToken stoppingToken)
IgnoreNoFormatsError = true
};

if (File.Exists("cookies.txt"))
FileInfo cookies = new("cookies.txt");
if (cookies.Exists)
{
live_chatOptionSet.Cookies = "cookies.txt";
info_jsonOptionSet.Cookies = "cookies.txt";
_logger.LogInformation("Detected {cookies}, use it for yt-dlp", cookies.FullName);
var bak = cookies.CopyTo("cookies.copy.txt", true);
live_chatOptionSet.Cookies = bak.FullName;
info_jsonOptionSet.Cookies = bak.FullName;
}

YoutubeDLProcess ytdlProc = new(Helper.WhereIsYt_dlp());
Expand Down

0 comments on commit 22f3c09

Please sign in to comment.