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

datahoarder

6770 readers
3 users here now

Who are we?

We are digital librarians. Among us are represented the various reasons to keep data -- legal requirements, competitive requirements, uncertainty of permanence of cloud services, distaste for transmitting your data externally (e.g. government or corporate espionage), cultural and familial archivists, internet collapse preppers, and people who do it themselves so they're sure it's done right. Everyone has their reasons for curating the data they have decided to keep (either forever or For A Damn Long Time). Along the way we have sought out like-minded individuals to exchange strategies, war stories, and cautionary tales of failures.

We are one. We are legion. And we're trying really hard not to forget.

-- 5-4-3-2-1-bang from this thread

founded 4 years ago
MODERATORS
 

Hi folks! Glad to see that the Data Hoarders community has migrated to Lemmy. I thought I'd share a yt-dlp script that I use regularly.

cross-posted from: https://sh.itjust.works/post/1891050

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.

you are viewing a single comment's thread
view the rest of the comments
[โ€“] sherry@lemmy.sherry.moe 3 points 1 year ago

Thank you for sharing. I'll totally give this a try next time I need it ๐Ÿ˜ฏ