diff --git a/mpv-root/installer/updater.ps1 b/mpv-root/installer/updater.ps1
index 8873191..cc1d62c 100644
--- a/mpv-root/installer/updater.ps1
+++ b/mpv-root/installer/updater.ps1
@@ -83,7 +83,17 @@ function Download-Ytplugin ($plugin, $version) {
if (-Not (Test-Path (Join-Path $env:windir "SysWow64"))) {
$32bit = "_x86"
}
- $link = -join("https://github.com/yt-dlp/yt-dlp/releases/download/", $version, "/", $plugin, $32bit, ".exe")
+ $ytdlp_channel = Check-Ytdlp-Channel
+ if ($ytdlp_channel -eq 'stable') {
+ $repo = "https://github.com/yt-dlp/yt-dlp"
+ }
+ elseif ($ytdlp_channel -eq 'nightly') {
+ $repo = "https://github.com/yt-dlp/yt-dlp-nightly-builds"
+ }
+ elseif ($ytdlp_channel -eq 'master') {
+ $repo = "https://github.com/yt-dlp/yt-dlp-master-builds"
+ }
+ $link = -join($repo, "/releases/download/", $version, "/", $plugin, $32bit, ".exe")
$plugin_exe = -join($plugin, $32bit, ".exe")
}
"youtube-dl" {
@@ -141,8 +151,18 @@ function Get-Latest-Mpv($Arch, $channel) {
function Get-Latest-Ytplugin ($plugin) {
switch -wildcard ($plugin) {
"yt-dlp*" {
- $link = "https://github.com/yt-dlp/yt-dlp/releases.atom"
- Write-Host "Fetching RSS feed for ytp-dlp" -ForegroundColor Green
+ $ytdlp_channel = Check-Ytdlp-Channel
+ if ($ytdlp_channel -eq 'stable') {
+ $repo = "https://github.com/yt-dlp/yt-dlp"
+ }
+ elseif ($ytdlp_channel -eq 'nightly') {
+ $repo = "https://github.com/yt-dlp/yt-dlp-nightly-builds"
+ }
+ elseif ($ytdlp_channel -eq 'master') {
+ $repo = "https://github.com/yt-dlp/yt-dlp-master-builds"
+ }
+ $link = -join($repo, "/releases.atom")
+ Write-Host "Fetching RSS feed for yt-dlp $ytdlp_channel" -ForegroundColor Green
$resp = [xml](Invoke-WebRequest $link -MaximumRedirection 0 -ErrorAction Ignore -UseBasicParsing).Content
$link = $resp.feed.entry[0].link.href
$version = $link.split("/")[-1]
@@ -241,6 +261,8 @@ function Create-XML {
unset
unset
unset
+ unset
+ unset
"@ | Set-Content "settings.xml" -Encoding UTF8
}
@@ -362,6 +384,89 @@ function Check-GetFFmpeg() {
return $get_ffmpeg
}
+function Check-GetYTDL() {
+ $get_ytdl = ""
+ $file = "settings.xml"
+
+ if (-not (Test-Path $file)) { exit }
+ [xml]$doc = Get-Content $file
+ if ($null -eq $doc.settings.getytdl) {
+ $yt = Check-Ytplugin
+ if ($yt -eq $null){
+ $get_ytdl = "unset"
+ }
+ elseif ((Get-Item $yt).BaseName -Match "yt-dlp*") {
+ $get_ytdl = "ytdlp"
+ }
+ else {
+ $get_ytdl = "youtubedl"
+ }
+ $newNode = $doc.CreateElement("getytdl")
+ $newNode.AppendChild($doc.CreateTextNode($get_ytdl)) | out-null
+ $doc.settings.appendchild($newNode) | out-null
+ $doc.Save($file)
+ }
+ else {
+ $get_ytdl = $doc.settings.getytdl
+ }
+
+ if ($get_ytdl -eq "unset") {
+ $result = Read-KeyOrTimeout "Download ytdlp or youtubedl? [1=ytdlp/2=youtubedl/N] (default=1)" "D1"
+ Write-Host ""
+ if ($result -eq 'D1') {
+ $get_ytdl = "ytdlp"
+ }
+ elseif ($result -eq 'D2') {
+ $get_ytdl = "youtubedl"
+ }
+ elseif ($result -eq 'N') {
+ $get_ytdl = "false"
+ }
+ else {
+ throw "Please enter valid input key."
+ }
+ $doc.settings.getytdl = $get_ytdl
+ $doc.Save($file)
+ }
+
+ return $get_ytdl
+}
+
+function Check-Ytdlp-Channel() {
+ $ytdlp_channel = ""
+ $file = "settings.xml"
+
+ if (-not (Test-Path $file)) { exit }
+ [xml]$doc = Get-Content $file
+ if ($null -eq $doc.settings.ytdlpchannel) {
+ $newNode = $doc.CreateElement("ytdlpchannel")
+ $newNode.AppendChild($doc.CreateTextNode("unset")) | out-null
+ $doc.settings.appendchild($newNode) | out-null
+ }
+ if ($doc.settings.ytdlpchannel -eq "unset") {
+ $result = Read-KeyOrTimeout "Which update channel to update yt-dlp to? [1=stable/2=nightly/3=master] (default=1)" "D1"
+ Write-Host ""
+ if ($result -eq 'D1') {
+ $ytdlp_channel = "stable"
+ }
+ elseif ($result -eq 'D2') {
+ $ytdlp_channel = "nightly"
+ }
+ elseif ($result -eq 'D3') {
+ $ytdlp_channel = "master"
+ }
+ else {
+ throw "Please enter valid input key."
+ }
+ $doc.settings.ytdlpchannel = $ytdlp_channel
+ $doc.Save($file)
+ }
+ else {
+ $ytdlp_channel = $doc.settings.ytdlpchannel
+ }
+ return $ytdlp_channel
+}
+
function Upgrade-Mpv {
$need_download = $false
$remoteName = ""
@@ -443,28 +548,28 @@ function Upgrade-Ytplugin {
}
else {
Write-Host "Newer" (Get-Item $yt).BaseName "build available" -ForegroundColor Green
- & $yt --update
+ if ((Get-Item $yt).BaseName -Match "yt-dlp*") {
+ $ytdlp_channel = Check-Ytdlp-Channel
+ & $yt --update-to $ytdlp_channel
+ }
+ else {
+ & $yt --update
+ }
}
}
else {
Write-Host "ytdlp or youtube-dl doesn't exist. " -ForegroundColor Green -NoNewline
- $result = Read-KeyOrTimeout "Proceed with downloading? [Y/n] (default=n)" "N"
- Write-Host ""
-
- if ($result -eq 'Y') {
- $result_exe = Read-KeyOrTimeout "Download ytdlp or youtubedl? [1=ytdlp/2=youtubedl] (default=1)" "D1"
- Write-Host ""
- if ($result_exe -eq 'D1') {
- $latest_release = Get-Latest-Ytplugin "yt-dlp"
- Download-Ytplugin "yt-dlp" $latest_release
- }
- elseif ($result_exe -eq 'D2') {
- $latest_release = Get-Latest-Ytplugin "youtube-dl"
- Download-Ytplugin "youtube-dl" $latest_release
- }
- else {
- throw "Please enter valid input key."
- }
+ $ytdl = Check-GetYTDL
+ if ($ytdl -eq 'ytdlp') {
+ $latest_release = Get-Latest-Ytplugin "yt-dlp"
+ Download-Ytplugin "yt-dlp" $latest_release
+ }
+ elseif ($ytdl -eq 'youtubedl') {
+ $latest_release = Get-Latest-Ytplugin "youtube-dl"
+ Download-Ytplugin "youtube-dl" $latest_release
+ }
+ elseif ($ytdl -ne 'false') {
+ throw "Please enter valid input key."
}
}
}