this post was submitted on 22 Sep 2024
710 points (98.4% liked)
Technology
59549 readers
3244 users here now
This is a most excellent place for technology news and articles.
Our Rules
- Follow the lemmy.world rules.
- Only tech related content.
- Be excellent to each another!
- Mod approved content bots can post up to 10 articles per day.
- Threads asking for personal tech support may be deleted.
- Politics threads may be removed.
- No memes allowed as posts, OK to post as comments.
- Only approved bots from the list below, to ask if your bot can be added please contact us.
- Check for duplicates before posting, duplicates may be removed
Approved Bots
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
“Give me a Python script using yt-dlp that I can run on a cronjob that will download the videos from any of my subscribed channels since the last time the script was run”
You can use the following Python script to download videos from your subscribed channels since the last run. This script uses
yt-dlp
and stores the last download timestamp to track new videos.First, ensure you have
yt-dlp
installed:Then, create a script called
download_videos.py
:Setting Up the Cron Job
Make the script executable:
Open your crontab:
Add a line to run the script at your desired interval (e.g., daily at 2 AM):
Notes
CHANNEL_ID
in the script with your actual channel IDs or use a playlist URL if preferred.archive.txt
file keeps track of already downloaded videos to avoid duplicates.Another example, which i can personally verify has been working fine for months. It works a bit different to the above, it downloads the latests 2* vids that are not already downloaded and runs once every hour with cron. I also attempted to filter out live vids and shorts.
Channels i am "subscribed" too are stored in a single text file, it also uses the avc1 codec because i found p9 and p10 had issues with the jellyfin client on my tv.
looks like this, i added categories but i don't actually use them in the script besides putting them in a variable, lol. Vid-limit is how many of the latests vids it should look at to download. The original reason i implemented that is so i could selectively download a bulk of latests vids if i wanted to.
Yeah this is more elegant and closer to what I’d actually want to implement. I was more just showing what could be done in literally thirty seconds on the can with ChatGPT.
I knew i recognized that output.
Mine is actually also made with the help of Chatgpt but manually refined and tested.