this post was submitted on 29 Jul 2023
3 points (100.0% liked)

youtube-dl

186 readers
1 users here now

youtube-dl and the yt-dlp fork are a command-line program to download videos from YouTube.com, as well as many other sites. We are a community of enthusiasts helping each other with problems and usability issues.

founded 1 year ago
MODERATORS
 

Hi folks! Glad to see that the youtube-dl community has migrated to Lemmy.

As I documented in The Other Place, I previously put together a Windows batch script to continuously monitor a specific channel for livestreams and download them as they occur.

A recent change to YouTube resulted in https://www.youtube.com/%channel_name%/live no longer consistently linking to the most recent livestream. Fortunately, u/werid's suggestion of using --match-filter "live_status = is_live" on https://www.youtube.com/%channel_name%/streams still works, though I had to rework the script to not issue the download command for the same stream multiple times.

If anyone is interested or needs to do something similar, this is the current .bat script that I use:

@echo off
set channel_name=@SpaceX
:loop
@echo off
set DATE_TIME=%DATE:~6,4%-%DATE:~3,2%-%DATE:~0,2%_%TIME:~0,2%-%TIME:~3,2%-%TIME:~6,2%
set DATE_TIME=%DATE_TIME: =0%
set /A clock=%RANDOM% %% 80 + 1
set clock=%clock: =0%

set newLivestream=false
echo Looking for new %channel_name% livestreams...
@for /f %%i in ('yt-dlp --print id --match-filter "live_status = is_live" "https://www.youtube.com/%channel_name%/streams"') do (
	@if NOT defined %%i (
	set newLivestream=true
	echo New livestream found: %%i
	@set "%%i=false"
	start cmd /c yt-dlp --live-from-start -x -k -o "D:/Videos/%%(release_date)s_%%(channel)s_%%(id)s_%%(title)s.%%(ext)s" https://www.youtube.com/watch?v=%%i
	@set "%%i=true"
	@timeout /t 1
	)
)
if %newLivestream%==false (
	echo No new livestreams found
)
timeout /t %clock%
goto loop

You'll obviously need to change the channel_name and output template to suit your needs.

top 1 comments
sorted by: hot top controversial new old
[–] [email protected] 3 points 1 year ago* (last edited 1 year ago)

Glad to see that the youtube-dl community has migrated to Lemmy.

I'm not sure I would consider us "migrated". We created this as a test while we evaluated it and other alternatives to The Other Place. Actually migrating isn't anything that we've come to a conclusion yet.