Skip to content

Commit

Permalink
Merge pull request #40 from Constellado/yt-dlp
Browse files Browse the repository at this point in the history
Replaces youtube-dl install with yt-dlp
  • Loading branch information
Constellado authored Oct 13, 2024
2 parents bfc240e + f806f54 commit 1c4fe51
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions code/modules/admin/verbs/playsound.dm
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@

var/ytdl = CONFIG_GET(string/invoke_youtubedl)
if(!ytdl)
to_chat(src, "<span class='boldwarning'>Youtube-dl was not configured, action unavailable</span>", confidential = TRUE) //Check config.txt for the INVOKE_YOUTUBEDL value
to_chat(src, "<span class='boldwarning'>yt-dlp was not configured, action unavailable</span>", confidential = TRUE) //Check config.txt for the INVOKE_YOUTUBEDL value
return

var/web_sound_input = input("Enter content URL (supported sites only, leave blank to stop playing)", "Play Internet Sound via youtube-dl") as text|null
var/web_sound_input = input("Enter content URL (supported sites only, leave blank to stop playing)", "Play Internet Sound via yt-dlp") as text|null
if(istext(web_sound_input))
var/web_sound_url = ""
var/stop_web_sounds = FALSE
Expand All @@ -87,7 +87,7 @@
web_sound_input = trim(web_sound_input)
if(findtext(web_sound_input, ":") && !findtext(web_sound_input, GLOB.is_http_protocol))
to_chat(src, "<span class='boldwarning'>Non-http(s) URIs are not allowed.</span>", confidential = TRUE)
to_chat(src, "<span class='warning'>For youtube-dl shortcuts like ytsearch: please use the appropriate full url from the website.</span>", confidential = TRUE)
to_chat(src, "<span class='warning'>For yt-dlp shortcuts like ytsearch: please use the appropriate full url from the website.</span>", confidential = TRUE)
return
var/shell_scrubbed_input = shell_url_scrub(web_sound_input)
var/list/output = world.shelleo("[ytdl] --geo-bypass --format \"bestaudio\[ext=mp3]/best\[ext=mp4]\[height<=360]/bestaudio\[ext=m4a]/bestaudio\[ext=aac]\" --dump-single-json --no-playlist -- \"[shell_scrubbed_input]\"")
Expand Down
12 changes: 6 additions & 6 deletions config/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -291,13 +291,13 @@ CHECK_RANDOMIZER
## Ban appeals URL - usually for a forum or wherever people should go to contact your admins.
# BANAPPEALS http://justanotherday.example.com

## System command that invokes youtube-dl, used by Play Internet Sound.
## You can install youtube-dl with
## "pip install youtube-dl" if you have pip installed
## from https://github.com/rg3/youtube-dl/releases
## System command that invokes yt-dlp, used by Play Internet Sound.
## You can install yt-dlp with
## "pip install yt-dlp" if you have pip installed
## from https://github.com/yt-dlp/yt-dlp/releases
## or your package manager
## The default value assumes youtube-dl is in your system PATH
# INVOKE_YOUTUBEDL youtube-dl
## The default value assumes pip install yt-dlp is in your system PATH
# INVOKE_YOUTUBEDL yt-dlp

## In-game features
##Toggle for having jobs load up from the .txt
Expand Down
12 changes: 6 additions & 6 deletions tools/tgs_scripts/InstallDeps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ has_cargo="$(command -v ~/.cargo/bin/cargo)"
has_sudo="$(command -v sudo)"
has_curl="$(command -v curl)"
has_grep="$(command -v grep)"
has_youtubedl="$(command -v youtube-dl)"
has_ytdlp="$(command -v yt-dlp)"
has_pip3="$(command -v pip3)"
set -e
set -x
Expand All @@ -33,19 +33,19 @@ if ! [ -x "$has_cargo" ]; then
. ~/.profile
fi

# install or update youtube-dl when not present, or if it is present with pip3,
# install or update yt-dlp when not present, or if it is present with pip3,
# which we assume was used to install it
if ! [ -x "$has_youtubedl" ]; then
echo "Installing youtube-dl with pip3..."
echo "Installing yt-dlp with pip3..."
if ! [ -x "$has_sudo" ]; then
apt-get update
apt-get install -y python3 python3-pip
else
sudo apt-get update
sudo apt-get install -y python3 python3-pip
fi
pip3 install youtube-dl --break-system-packages
pip3 install yt-dlp --break-system-packages
elif [ -x "$has_pip3" ]; then
echo "Ensuring youtube-dl is up-to-date with pip3..."
pip3 install youtube-dl -U --break-system-packages
echo "Ensuring yt-dlp is up-to-date with pip3..."
pip3 install yt-dlp -U --break-system-packages
fi

0 comments on commit 1c4fe51

Please sign in to comment.