Open mollyrealized opened 1 year ago
Related: #1760, #1761, #2668
This has been requested before, but there's no issue open afair. This is however currently difficult to implement. As workaround, you can:
ERROR:
, or --print-to-file after_move:original_url success.txt
will record all successful URLs, which you can then diff with your --batch-fileI also need similar functions, I use in the CMD under Windows >> re-directed output content, but it only has a general log (I guess only download and download successfully downloading and running successfully) But all error outputs are still output on the screen How can I only output the error into the log file? The function of this implementation is the opposite I need :)
3.
--print-to-file after_move:original_url success.txt
will record all successful URLs, which you can then diff with your --batch-file
Thank you, this is really useful
Here is a batch file that handles an input file and then writes anything with the "ERROR" prefix during the output into a separate file. Use at your own risk and no warranty is offered, but it should work ...
@echo off
setlocal
rem Check if the input file argument is provided
if "%~1"=="" (
echo Usage: %~nx0 inputfile
exit /b 1
)
rem Get the input file from the command-line argument
set "inputFile=%~1"
rem Verify the input file exists
if not exist "%inputFile%" (
echo The input file "%inputFile%" does not exist.
exit /b 1
)
rem Get the current date and time in the format YYYYMMDDHHMMSS
for /f "tokens=2 delims==" %%i in ('wmic os get localdatetime /value ^| find "="') do set datetime=%%i
set "datetime=%datetime:~0,4%%datetime:~4,2%%datetime:~6,2%%datetime:~8,2%%datetime:~10,2%%datetime:~12,2%"
rem Paths to the output files
set "fullOutput=full_output.log"
set "errorFile=errorlog-%datetime%.txt"
set "tempErrorFile=temp_error.txt"
rem Clear previous logs if they exist
if exist "%fullOutput%" del "%fullOutput%"
if exist "%errorFile%" del "%errorFile%"
if exist "%tempErrorFile%" del "%tempErrorFile%"
rem Download videos and log the full output
yt-dlp --batch-file="%inputFile%" > "%fullOutput%" 2>&1
rem Extract lines containing errors and save to temporary error file
findstr /r /c:"ERROR: " "%fullOutput%" > "%tempErrorFile%"
rem Remove "ERROR: " from the beginning of each error line and save to final error file
for /f "tokens=*" %%i in (%tempErrorFile%) do (
set "line=%%i"
setlocal enabledelayedexpansion
echo !line:ERROR: =! >> "%errorFile%"
endlocal
)
rem Cleanup temporary file
del "%tempErrorFile%"
del "%fullOutput%"
endlocal
The reason why I went this route instead of comparing the original request with the successful downloads is because - at least for me - sometimes I will download stuff that has already been downloaded. In those cases, those (falsely, for my purposes) register as failed downloads.
DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE
Checklist
Provide a description that is worded well enough to be understood
Using the "--batch-file" option to download multiple videos generates a substantial amount of output, making it difficult to identify reports of videos that failed to download. A feature that allows the URLs of videos that couldn't be downloaded to be written to a specific text file (log file) would be beneficial both for manual inspection and for allowing error logging while using "-quiet --progress-bar". Current 'abort' commands that halt the download process when failures are detected are not ideal, as they interrupt the entire operation.
Is the description of the issue itself sufficient? and Is there enough context in your bug report? In my view, yes. If anything remains confusing, please let me know. Are you using the latest version? Yes. Is the issue already documented? Not that I can tell through searching open issues. Why are existing options not enough? I do not think there are any logging options such as I describe. Have you read and understood the changes, between youtube-dl and yt-dlp Yes. Does the issue involve one problem, and one problem only? Yes. Is anyone going to need the feature? Yes, I believe this would be needed widely by anyone using the --batch-file option. Is your question about yt-dlp? Yes. Are you willing to share account details if needed? Yes. Is the website primarily used for piracy? No.
Provide verbose output that clearly demonstrates the problem
yt-dlp -vU <your command line>
)'verbose': True
toYoutubeDL
params instead[debug] Command-line config
) and insert it belowComplete Verbose Output