add cookies, think about parameters
This commit is contained in:
+5
-5
@@ -10,7 +10,7 @@ $rejects_string = $rejects -join '|'
|
|||||||
|
|
||||||
# Download flat playlist
|
# Download flat playlist
|
||||||
Write-Verbose -Message "Download flat playlist"
|
Write-Verbose -Message "Download flat playlist"
|
||||||
$flat = D:\youtube-dlp\yt-dlp.exe -j --flat-playlist $URL
|
$flat = D:\yt-dlp\yt-dlp.exe -j --flat-playlist $URL
|
||||||
$flat | Set-Content -Path YT_TheRegulationPodcast.json
|
$flat | Set-Content -Path YT_TheRegulationPodcast.json
|
||||||
|
|
||||||
# load json into memory, convert to psobject
|
# load json into memory, convert to psobject
|
||||||
@@ -53,7 +53,7 @@ ForEach ($obj in $json) {
|
|||||||
Else {
|
Else {
|
||||||
# Check if this is a YouTube Short by getting video info (aspect ratio or duration)
|
# Check if this is a YouTube Short by getting video info (aspect ratio or duration)
|
||||||
Write-Verbose -Message "Checking if video is a Short: $Title"
|
Write-Verbose -Message "Checking if video is a Short: $Title"
|
||||||
$videoInfo = D:\youtube-dlp\yt-dlp.exe -j $videoUrl
|
$videoInfo = D:\yt-dlp\yt-dlp.exe -j $videoUrl
|
||||||
$videoInfoObj = $videoInfo | ConvertFrom-Json
|
$videoInfoObj = $videoInfo | ConvertFrom-Json
|
||||||
|
|
||||||
# Determine if this is a short based on duration or aspect ratio
|
# Determine if this is a short based on duration or aspect ratio
|
||||||
@@ -72,18 +72,18 @@ ForEach ($obj in $json) {
|
|||||||
# Set output path based on whether it's a short or not
|
# Set output path based on whether it's a short or not
|
||||||
if ($isShort) {
|
if ($isShort) {
|
||||||
Write-Verbose -Message "Video detected as Short: $Title"
|
Write-Verbose -Message "Video detected as Short: $Title"
|
||||||
$outputPath = "Web-RegulationPodcast/YouTube Shorts/%(release_date>%Y%m%d,upload_date>%Y%m%d)s - %(title).180B [%(extractor)s-%(id)s].%(ext)s"
|
$outputPath = "YouTube Shorts/%(release_date>%Y%m%d,upload_date>%Y%m%d)s - %(title).180B [%(extractor)s-%(id)s].%(ext)s"
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Write-Verbose -Message "Video detected as regular: $Title"
|
Write-Verbose -Message "Video detected as regular: $Title"
|
||||||
$outputPath = "Web-RegulationPodcast/Regulation Gameplay/Season %(release_date>%y,upload_date>%y|Unknown)s/%(release_date>%Y%m%d,upload_date>%Y%m%d)s - %(title).180B [%(extractor)s-%(id)s].%(ext)s"
|
$outputPath = "Regulation Gameplay/Season %(release_date>%y,upload_date>%y|Unknown)s/%(release_date>%Y%m%d,upload_date>%Y%m%d)s - %(title).180B [%(extractor)s-%(id)s].%(ext)s"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Execute yt-dlp command for non-rejected videos
|
# Execute yt-dlp command for non-rejected videos
|
||||||
try {
|
try {
|
||||||
Write-Warning -Message "Dwnld $Id ##### $Title"
|
Write-Warning -Message "Dwnld $Id ##### $Title"
|
||||||
#$attemptedDownloads.Add($obj)
|
#$attemptedDownloads.Add($obj)
|
||||||
D:\youtube-dlp\yt-dlp.exe $videoUrl `
|
D:\yt-dlp\yt-dlp.exe $videoUrl `
|
||||||
--write-info-json `
|
--write-info-json `
|
||||||
--write-thumbnail `
|
--write-thumbnail `
|
||||||
--convert-thumbnails jpg `
|
--convert-thumbnails jpg `
|
||||||
+12
-11
@@ -1,6 +1,6 @@
|
|||||||
## YT Regulation Podcast
|
## Regulation Gameplay
|
||||||
# Set URL and Location
|
# Set URL and Location
|
||||||
$URL = "https://www.youtube.com/@theregulationpod"
|
$URL = "https://www.youtube.com/@TheRegulationPodcast"
|
||||||
$folderPath = "\\truenas3.kwyjibo.info\RegulationPodcast$"
|
$folderPath = "\\truenas3.kwyjibo.info\RegulationPodcast$"
|
||||||
|
|
||||||
Set-Location $folderPath
|
Set-Location $folderPath
|
||||||
@@ -10,11 +10,11 @@ $rejects_string = $rejects -join '|'
|
|||||||
|
|
||||||
# Download flat playlist
|
# Download flat playlist
|
||||||
Write-Verbose -Message "Download flat playlist"
|
Write-Verbose -Message "Download flat playlist"
|
||||||
$flat = D:\youtube-dlp\yt-dlp.exe -j --flat-playlist $URL
|
$flat = D:\yt-dlp\yt-dlp.exe -j --flat-playlist $URL
|
||||||
$flat | Set-Content -Path YT_theregulationpod.json
|
$flat | Set-Content -Path YT_TheRegulationPodcast.json
|
||||||
|
|
||||||
# load json into memory, convert to psobject
|
# load json into memory, convert to psobject
|
||||||
$json = Get-Content -Path YT_theregulationpod.json | ConvertFrom-Json
|
$json = Get-Content -Path YT_TheRegulationPodcast.json | ConvertFrom-Json
|
||||||
|
|
||||||
# Load all .mp4 files into memory once at the start
|
# Load all .mp4 files into memory once at the start
|
||||||
$mp4Files = Get-ChildItem -Path $folderPath -Recurse -Filter "*.mp4"
|
$mp4Files = Get-ChildItem -Path $folderPath -Recurse -Filter "*.mp4"
|
||||||
@@ -53,12 +53,12 @@ ForEach ($obj in $json) {
|
|||||||
Else {
|
Else {
|
||||||
# Check if this is a YouTube Short by getting video info (aspect ratio or duration)
|
# Check if this is a YouTube Short by getting video info (aspect ratio or duration)
|
||||||
Write-Verbose -Message "Checking if video is a Short: $Title"
|
Write-Verbose -Message "Checking if video is a Short: $Title"
|
||||||
$videoInfo = D:\youtube-dlp\yt-dlp.exe -j $videoUrl
|
$videoInfo = D:\yt-dlp\yt-dlp.exe -j $videoUrl
|
||||||
$videoInfoObj = $videoInfo | ConvertFrom-Json
|
$videoInfoObj = $videoInfo | ConvertFrom-Json
|
||||||
|
|
||||||
# Determine if this is a short based on duration or aspect ratio
|
# Determine if this is a short based on duration or aspect ratio
|
||||||
$isShort = $false
|
$isShort = $false
|
||||||
if ($videoInfoObj.duration -and $videoInfoObj.duration -lt 60) {
|
if ($videoInfoObj.duration -and $videoInfoObj.duration -eq 60) {
|
||||||
$isShort = $true
|
$isShort = $true
|
||||||
}
|
}
|
||||||
elseif ($videoInfoObj.width -and $videoInfoObj.height) {
|
elseif ($videoInfoObj.width -and $videoInfoObj.height) {
|
||||||
@@ -72,18 +72,18 @@ ForEach ($obj in $json) {
|
|||||||
# Set output path based on whether it's a short or not
|
# Set output path based on whether it's a short or not
|
||||||
if ($isShort) {
|
if ($isShort) {
|
||||||
Write-Verbose -Message "Video detected as Short: $Title"
|
Write-Verbose -Message "Video detected as Short: $Title"
|
||||||
$outputPath = "Web-RegulationPodcast/YouTube Shorts/%(release_date>%Y%m%d,upload_date>%Y%m%d)s - %(title).180B [%(extractor)s-%(id)s].%(ext)s"
|
$outputPath = "YouTube Shorts/%(release_date>%Y%m%d,upload_date>%Y%m%d)s - %(title).180B [%(extractor)s-%(id)s].%(ext)s"
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Write-Verbose -Message "Video detected as regular: $Title"
|
Write-Verbose -Message "Video detected as regular: $Title"
|
||||||
$outputPath = "Web-RegulationPodcast/Regular Videos/Season %(release_date>%y,upload_date>%y|Unknown)s/%(release_date>%Y%m%d,upload_date>%Y%m%d)s - %(title).180B [%(extractor)s-%(id)s].%(ext)s"
|
$outputPath = "Regulation Gameplay/Season %(release_date>%y,upload_date>%y|Unknown)s/%(release_date>%Y%m%d,upload_date>%Y%m%d)s - %(title).180B [%(extractor)s-%(id)s].%(ext)s"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Execute yt-dlp command for non-rejected videos
|
# Execute yt-dlp command for non-rejected videos
|
||||||
try {
|
try {
|
||||||
Write-Warning -Message "Dwnld $Id ##### $Title"
|
Write-Warning -Message "Dwnld $Id ##### $Title"
|
||||||
#$attemptedDownloads.Add($obj)
|
#$attemptedDownloads.Add($obj)
|
||||||
D:\youtube-dlp\yt-dlp.exe $videoUrl `
|
D:\yt-dlp\yt-dlp.exe $videoUrl `
|
||||||
--write-info-json `
|
--write-info-json `
|
||||||
--write-thumbnail `
|
--write-thumbnail `
|
||||||
--convert-thumbnails jpg `
|
--convert-thumbnails jpg `
|
||||||
@@ -94,7 +94,8 @@ ForEach ($obj in $json) {
|
|||||||
-f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best" `
|
-f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best" `
|
||||||
-S vcodec:h264 `
|
-S vcodec:h264 `
|
||||||
--reject-title $rejects_string `
|
--reject-title $rejects_string `
|
||||||
--playlist-reverse
|
--playlist-reverse `
|
||||||
|
--cookies-from-browser firefox
|
||||||
#--cookies "D:\youtube-dlp\20251024_currentsite_cookies.firefox-private.txt" #`
|
#--cookies "D:\youtube-dlp\20251024_currentsite_cookies.firefox-private.txt" #`
|
||||||
#--extractor-args "youtube:player_client=default,web_safari;player_js_version=actual"
|
#--extractor-args "youtube:player_client=default,web_safari;player_js_version=actual"
|
||||||
# --reject-title "Dude Soup|Podcast" ` # FH
|
# --reject-title "Dude Soup|Podcast" ` # FH
|
||||||
@@ -0,0 +1,121 @@
|
|||||||
|
## YT Regulation Podcast
|
||||||
|
# Set URL and Location
|
||||||
|
$URL = "https://www.youtube.com/@theregulationpod"
|
||||||
|
$folderPath = "\\truenas3.kwyjibo.info\RegulationPodcast$"
|
||||||
|
|
||||||
|
Set-Location $folderPath
|
||||||
|
|
||||||
|
$rejects = @()
|
||||||
|
$rejects_string = $rejects -join '|'
|
||||||
|
|
||||||
|
# Download flat playlist
|
||||||
|
Write-Verbose -Message "Download flat playlist"
|
||||||
|
$flat = D:\yt-dlp\yt-dlp.exe -j --flat-playlist $URL
|
||||||
|
$flat | Set-Content -Path YT_theregulationpod.json
|
||||||
|
|
||||||
|
# load json into memory, convert to psobject
|
||||||
|
$json = Get-Content -Path YT_theregulationpod.json | ConvertFrom-Json
|
||||||
|
|
||||||
|
# Load all .mp4 files into memory once at the start
|
||||||
|
$mp4Files = Get-ChildItem -Path $folderPath -Recurse -Filter "*.mp4"
|
||||||
|
|
||||||
|
ForEach ($obj in $json) {
|
||||||
|
# Initialize $fileFound as null for each iteration
|
||||||
|
$fileFound = $false
|
||||||
|
|
||||||
|
# Extract information from the JSON object
|
||||||
|
$videoUrl = $obj.webpage_url
|
||||||
|
$Title = $obj.title
|
||||||
|
$Id = $obj.id
|
||||||
|
|
||||||
|
# --- NEW CHECK ADDED HERE ---
|
||||||
|
if ($videoUrl -like "*shorts*") {
|
||||||
|
Write-Verbose "Skipping video because the URL contains 'shorts': $Id ##### $Title" -Verbose
|
||||||
|
continue # Jumps immediately to the next iteration of the loop
|
||||||
|
}
|
||||||
|
# ----------------------------
|
||||||
|
|
||||||
|
# Log the start of the process
|
||||||
|
Write-Verbose -Message "Start $Id ##### $Title"
|
||||||
|
|
||||||
|
# Check if the title matches any reject term using wildcards
|
||||||
|
$reject_matches = $rejects | Where-Object { $Title -like "*$($_)*" }
|
||||||
|
|
||||||
|
# If matches are found, reject the title
|
||||||
|
If ($reject_matches) {
|
||||||
|
Write-Warning -Message "Skip $Id ##### $Title (Rejected by Title)"
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
# downloaded already?
|
||||||
|
# Regular expression to match the ID after "youtube-" and before the closing bracket
|
||||||
|
$regex = "(?i)youtube-$Id"
|
||||||
|
|
||||||
|
# Check if any file already exists that matches the video ID
|
||||||
|
$fileFound = $mp4Files | Where-Object { $_.Name -match $regex }
|
||||||
|
|
||||||
|
|
||||||
|
# If no file is found, notify the user
|
||||||
|
if ($fileFound) {
|
||||||
|
Write-Warning "File found with the YouTube ID: $Id"
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
# Check if this is a YouTube Short by getting video info (aspect ratio or duration)
|
||||||
|
# NOTE: If you use the URL check above, this section might become redundant for Shorts,
|
||||||
|
# but keeping it allows for fallback/verification.
|
||||||
|
Write-Verbose -Message "Checking if video is a Short: $Title"
|
||||||
|
$videoInfo = D:\yt-dlp\yt-dlp.exe -j $videoUrl
|
||||||
|
$videoInfoObj = $videoInfo | ConvertFrom-Json
|
||||||
|
|
||||||
|
# Determine if this is a short based on duration or aspect ratio
|
||||||
|
$isShort = $false
|
||||||
|
if ($videoInfoObj.duration -and $videoInfoObj.duration -lt 60) {
|
||||||
|
$isShort = $true
|
||||||
|
}
|
||||||
|
elseif ($videoInfoObj.width -and $videoInfoObj.height) {
|
||||||
|
# Calculate aspect ratio (height/width for vertical videos)
|
||||||
|
$aspectRatio = [double]$videoInfoObj.height / [double]$videoInfoObj.width
|
||||||
|
if ($aspectRatio -gt 1.5) { # Vertical video (typically > 1.5:1)
|
||||||
|
$isShort = $true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Set output path based on whether it's a short or not
|
||||||
|
if ($isShort) {
|
||||||
|
Write-Verbose -Message "Video detected as Short: $Title" -Verbose
|
||||||
|
$outputPath = "YouTube Shorts/%(release_date>%Y%m%d,upload_date>%Y%m%d)s - %(title).180B [%(extractor)s-%(id)s].%(ext)s"
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Write-Verbose -Message "Video detected as regular: $Title" -Verbose
|
||||||
|
$outputPath = "Podcast & Supplementals/Season %(release_date>%y,upload_date>%y|Unknown)s/%(release_date>%Y%m%d,upload_date>%Y%m%d)s - %(title).180B [%(extractor)s-%(id)s].%(ext)s"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Execute yt-dlp command for non-rejected videos
|
||||||
|
try {
|
||||||
|
Write-Warning -Message "Dwnld $Id ##### $Title"
|
||||||
|
#$attemptedDownloads.Add($obj)
|
||||||
|
D:\yt-dlp\yt-dlp.exe $videoUrl `
|
||||||
|
--write-info-json `
|
||||||
|
--write-thumbnail `
|
||||||
|
--convert-thumbnails jpg `
|
||||||
|
--no-progress `
|
||||||
|
-t sleep `
|
||||||
|
--rate-limit 5M `
|
||||||
|
-o $outputPath `
|
||||||
|
-f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best" `
|
||||||
|
-S vcodec:h264 `
|
||||||
|
--reject-title $rejects_string `
|
||||||
|
--playlist-reverse `
|
||||||
|
#--cookies-from-browser firefox
|
||||||
|
#--cookies "D:\youtube-dlp\20251024_currentsite_cookies.firefox-private.txt" #`
|
||||||
|
#--extractor-args "youtube:player_client=default,web_safari;player_js_version=actual"
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
Write-Error "Failed to download $Id - $_"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Log the end of the process
|
||||||
|
Write-Verbose -Message "End $Id ##### $Title"
|
||||||
|
}
|
||||||
@@ -0,0 +1,121 @@
|
|||||||
|
## YT Regulation Podcast
|
||||||
|
# Set URL and Location
|
||||||
|
$URL = "https://www.youtube.com/@theregulationpod"
|
||||||
|
$folderPath = "\\truenas3.kwyjibo.info\RegulationPodcast$"
|
||||||
|
|
||||||
|
Set-Location $folderPath
|
||||||
|
|
||||||
|
$rejects = @()
|
||||||
|
$rejects_string = $rejects -join '|'
|
||||||
|
|
||||||
|
# Download flat playlist
|
||||||
|
Write-Verbose -Message "Download flat playlist"
|
||||||
|
$flat = D:\yt-dlp\yt-dlp.exe -j --flat-playlist $URL
|
||||||
|
$flat | Set-Content -Path YT_theregulationpod.json
|
||||||
|
|
||||||
|
# load json into memory, convert to psobject
|
||||||
|
$json = Get-Content -Path YT_theregulationpod.json | ConvertFrom-Json
|
||||||
|
|
||||||
|
# Load all .mp4 files into memory once at the start
|
||||||
|
$mp4Files = Get-ChildItem -Path $folderPath -Recurse -Filter "*.mp4"
|
||||||
|
|
||||||
|
ForEach ($obj in $json) {
|
||||||
|
# Initialize $fileFound as null for each iteration
|
||||||
|
$fileFound = $false
|
||||||
|
|
||||||
|
# Extract information from the JSON object
|
||||||
|
$videoUrl = $obj.webpage_url
|
||||||
|
$Title = $obj.title
|
||||||
|
$Id = $obj.id
|
||||||
|
|
||||||
|
# --- NEW CHECK ADDED HERE ---
|
||||||
|
if ($videoUrl -like "*shorts*") {
|
||||||
|
Write-Verbose "Skipping video because the URL contains 'shorts': $Id ##### $Title" -Verbose
|
||||||
|
continue # Jumps immediately to the next iteration of the loop
|
||||||
|
}
|
||||||
|
# ----------------------------
|
||||||
|
|
||||||
|
# Log the start of the process
|
||||||
|
Write-Verbose -Message "Start $Id ##### $Title"
|
||||||
|
|
||||||
|
# Check if the title matches any reject term using wildcards
|
||||||
|
$reject_matches = $rejects | Where-Object { $Title -like "*$($_)*" }
|
||||||
|
|
||||||
|
# If matches are found, reject the title
|
||||||
|
If ($reject_matches) {
|
||||||
|
Write-Warning -Message "Skip $Id ##### $Title (Rejected by Title)"
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
# downloaded already?
|
||||||
|
# Regular expression to match the ID after "youtube-" and before the closing bracket
|
||||||
|
$regex = "(?i)youtube-$Id"
|
||||||
|
|
||||||
|
# Check if any file already exists that matches the video ID
|
||||||
|
$fileFound = $mp4Files | Where-Object { $_.Name -match $regex }
|
||||||
|
|
||||||
|
|
||||||
|
# If no file is found, notify the user
|
||||||
|
if ($fileFound) {
|
||||||
|
Write-Warning "File found with the YouTube ID: $Id"
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
# Check if this is a YouTube Short by getting video info (aspect ratio or duration)
|
||||||
|
# NOTE: If you use the URL check above, this section might become redundant for Shorts,
|
||||||
|
# but keeping it allows for fallback/verification.
|
||||||
|
Write-Verbose -Message "Checking if video is a Short: $Title"
|
||||||
|
$videoInfo = D:\yt-dlp\yt-dlp.exe -j $videoUrl
|
||||||
|
$videoInfoObj = $videoInfo | ConvertFrom-Json
|
||||||
|
|
||||||
|
# Determine if this is a short based on duration or aspect ratio
|
||||||
|
$isShort = $false
|
||||||
|
if ($videoInfoObj.duration -and $videoInfoObj.duration -lt 60) {
|
||||||
|
$isShort = $true
|
||||||
|
}
|
||||||
|
elseif ($videoInfoObj.width -and $videoInfoObj.height) {
|
||||||
|
# Calculate aspect ratio (height/width for vertical videos)
|
||||||
|
$aspectRatio = [double]$videoInfoObj.height / [double]$videoInfoObj.width
|
||||||
|
if ($aspectRatio -gt 1.5) { # Vertical video (typically > 1.5:1)
|
||||||
|
$isShort = $true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Set output path based on whether it's a short or not
|
||||||
|
if ($isShort) {
|
||||||
|
Write-Verbose -Message "Video detected as Short: $Title" -Verbose
|
||||||
|
$outputPath = "YouTube Shorts/%(release_date>%Y%m%d,upload_date>%Y%m%d)s - %(title).180B [%(extractor)s-%(id)s].%(ext)s"
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Write-Verbose -Message "Video detected as regular: $Title" -Verbose
|
||||||
|
$outputPath = "Podcast & Supplementals/Season %(release_date>%y,upload_date>%y|Unknown)s/%(release_date>%Y%m%d,upload_date>%Y%m%d)s - %(title).180B [%(extractor)s-%(id)s].%(ext)s"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Execute yt-dlp command for non-rejected videos
|
||||||
|
try {
|
||||||
|
Write-Warning -Message "Dwnld $Id ##### $Title"
|
||||||
|
#$attemptedDownloads.Add($obj)
|
||||||
|
D:\yt-dlp\yt-dlp.exe $videoUrl `
|
||||||
|
--write-info-json `
|
||||||
|
--write-thumbnail `
|
||||||
|
--convert-thumbnails jpg `
|
||||||
|
--no-progress `
|
||||||
|
-t sleep `
|
||||||
|
--rate-limit 5M `
|
||||||
|
-o $outputPath `
|
||||||
|
-f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best" `
|
||||||
|
-S vcodec:h264 `
|
||||||
|
--reject-title $rejects_string `
|
||||||
|
--playlist-reverse `
|
||||||
|
--cookies-from-browser firefox
|
||||||
|
#--cookies "D:\youtube-dlp\20251024_currentsite_cookies.firefox-private.txt" #`
|
||||||
|
#--extractor-args "youtube:player_client=default,web_safari;player_js_version=actual"
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
Write-Error "Failed to download $Id - $_"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Log the end of the process
|
||||||
|
Write-Verbose -Message "End $Id ##### $Title"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user