(Windows) Setup Archival Scripts for Youtube
Essentials:
- Download yt-dlp.exe: https://github.com/yt-dlp/yt-dlp/releases
- Download ffmpeg: https://www.gyan.dev/ffmpeg/builds/ffmpeg-git-full.7z
- Place "yt-dlp.exe" in a permanent folder somewhere named "yt-dlp" (Ex: ../yt-dlp/yt-dlp.exe)
- Place the extracted ffmpeg contents in a permanent folder somewhere named "ffmpeg"
- Press win key + R and type "sysdm.cpl" and press Enter.
- Go to the Advanced tab and open "Environment Variables..." at the bottom.
- Under "User Variables" at the top, select "Path" and then "Edit".
- Select a new line and add the location of the "../yt-dlp/" folder you created earlier.
- Select a new line and add the ffmpeg bin folder "../ffmpeg/bin/" next.
Now you can type yt-dlp [link]
into Command Prompt or Powershell (shift+right click inside folder) to download videos easily. I highly recommend using Powershell. It makes it so much simpler as it will automatically open from the directory you shift+right clicked inside, as well as save files to that same directory. The user variables setup also allows you to do the same with ffmpeg commands.
Archive a full channel:
- Download the "master.zip" from https://github.com/dmn001/youtube_channel_archiver
You can also just create the "yt-dlp.conf" file yourself, using the same parameters from the github, and it will do the same thing.
- Add the channels you want to "yt-dlp-channels.txt".
- I would recommend editing the yt-dlp.conf file to remove unnecessary things; like resolution and duration in the filename or subs if you don't want live chat archived.
- Run "download_archive.bat". Or shift+right click inside the folder to open Powershell and just type
yt-dlp
and hit enter. The yt-dlp.conf file will automatically be loaded from the same folder you run the command from. - To set up cookies to archive members content, use one of the options below.
- Using cookies.txt addon/extension, open a Private Window and log into youtube. Save your cookies for youtube and add--cookies cookies.txt
to the yt-dlp.conf file. For me the correct file wasn't the main cookies.txt file but the cookies.firefox-private.txt file. I just renamed that one to cookies.txt and used it instead. You may need to allow cookies.txt to run in a private window to get it to show up.
- You can also use--cookies-from-browser
but I don't use that so I can't give concrete instructions for it. I believe you can specify the program "chrome" or "firefox" or the profile "firefox:profile here.default".
You can run this script any time a new video is uploaded and it will only download the new video. Skipping all the ones that are already listed in yt-dlp-archive.txt.
Editing the script from above for standard yt-dlp usage:
- Copy "yt-dlp.conf" and "yt-dlp-archive.txt" to a separate folder. You can always cut and paste whatever you download to the other folder if you like. The archive.txt file will also let you copy and paste anything you download to the main archive text file if needed. Or you can use the
[%(id)s]
from the downloaded files and paste that into the archive.txt. - I would recommend removing everything in the "# Get All Subs to SRT" section as you cannot archive live video and live chat with the same script. You would need to open another instance.
To download live chat you can create a another folder with a config that has "--skip-download" added to skip downloading the video. Make sure to copy the config that has "Get All Subs SRT" in it to actually download live chat.
- Remove
-a yt-dlp-channels.txt
from yt-dlp.conf. Optional: you can also delete--download-archive yt-dlp-archive.txt
if you don't plan to use that. - Add
--live-from-start
and--wait-for-video 60
to your yt-dlp.conf file. This will archive live streams from the beginning as well as keep trying every 60s until the stream starts. Meaning you can start the script from the waiting room. - Now if you want to quickly archive something outside of the channels.txt file, you can open Powershell/Command Prompt and just type
yt-dlp [link]
and it will save it with the same formatting as the yt-dlp.conf in the same folder.
Clipping Timestamped Sections
The simplest method is to just use a folder without an archive.txt for this. Just add this after the youtube link:
--download-sections "*00:00:00-00:00:00" --force-keyframes-at-cuts
The timestamp is in HH:MM:SS format.
The timestamp can be shortened but I'm not sure on what the exact rules are.