Compare commits

...

3 Commits

Author SHA1 Message Date
Dominika Liberda 6b43d9ef5f * fixed unquoted shell expansion 2021-03-30 23:23:13 +02:00
Dominika Liberda 02eaae1023 * added /c/ route 2021-03-30 23:22:32 +02:00
Dominika Liberda c713490cc8 + makes use of new haruhi-dl infoextractor picker (thanks, @selfisekai! :3) 2021-03-30 23:22:16 +02:00
4 changed files with 13 additions and 10 deletions

View File

@ -2,6 +2,7 @@
#router "/uwu" "owo"
router "/c/:c" "${cfg[namespace]}/webroot/channel.shs"
router "/channel/:id" "${cfg[namespace]}/webroot/channel.shs"
router "/user/:user" "${cfg[namespace]}/webroot/channel.shs"
router "/playlist" "${cfg[namespace]}/webroot/playlist.shs"

View File

@ -3,13 +3,15 @@
declare -A strings
if [[ "${params[id]}" ]]; then
data=$(haruhi-dl -J --flat-playlist "https://www.youtube.com/channel/${params[id]}")
data=$(haruhi-dl --ie-key YoutubeChannel -J --flat-playlist "https://www.youtube.com/channel/${params[id]}")
elif [[ "${params[user]}" ]]; then
data=$(haruhi-dl -J --flat-playlist "https://www.youtube.com/user/${params[user]}")
data=$(haruhi-dl --ie-key YoutubeChannel -J --flat-playlist "https://www.youtube.com/user/${params[user]}")
elif [[ "${params[c]}" ]]; then
data=$(haruhi-dl --ie-key YoutubeChannel -J --flat-playlist "https://www.youtube.com/c/${params[c]}")
elif [[ "${get_data[id]}" ]]; then
data=$(haruhi-dl -J --flat-playlist "https://www.youtube.com/channel/${get_data[id]}")
data=$(haruhi-dl --ie-key YoutubeChannel -J --flat-playlist "https://www.youtube.com/channel/${get_data[id]}")
elif [[ "${get_data[name]}" ]]; then
data=$(haruhi-dl -J --flat-playlist "https://www.youtube.com/user/${get_data[name]}")
data=$(haruhi-dl --ie-key YoutubeChannel -J --flat-playlist "https://www.youtube.com/user/${get_data[name]}")
else
echo "Please specify either id or name"
return

View File

@ -13,7 +13,7 @@ if [[ "${get_data[q]}" ]]; then
fi
if [[ "${get_data[q]}" ]]; then
data=$(haruhi-dl "ytsearch30:${get_data[q]}" --flat-playlist -J | jq '.entries[]')
data=$(haruhi-dl --ie-key YoutubeSearch "ytsearch30:${get_data[q]}" --flat-playlist -J | jq '.entries[]')
IFS=$'\n'
id=($(jq -r '.id' <<< "$data"))
@ -32,7 +32,7 @@ else
strings[results]="search for something will 'ya?"
fi
if [[ ! $(which haruhi-dl) || $? != "0" ]]; then
if [[ ! "$(which haruhi-dl)" || $? != "0" ]]; then
strings[results]="Could not fetch search results"
fi

View File

@ -6,7 +6,7 @@ fi
declare -A strings
if [[ ! $(which haruhi-dl) ]]; then
if [[ ! "$(which haruhi-dl)" ]]; then
strings[error]='Could not load video'
source templates/head.sh
source "${cfg[namespace]}/templates/header.shs"
@ -28,10 +28,10 @@ if [[ "${get_data[v]}" ]]; then
fi
else
cd temp
video=$(haruhi-dl --write-pages --cookies ${cfg[_cookies]} -J "http://youtube.com/watch?v=${get_data[v]}")
video=$(haruhi-dl --ie-key Youtube --write-pages --cookies "${cfg[_cookies]}" -J "http://youtube.com/watch?v=${get_data[v]}")
if [[ $video == '' ]]; then # okay who did this
random_hash=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 24 | head -n 1)
video=$(haruhi-dl --write-pages --cookies ${cfg[_cookies]} -J "http://youtube.com/watch?v=${get_data[v]}" &> output$random_hash.log)
video=$(haruhi-dl --ie-key Youtube --write-pages --cookies ${cfg[_cookies]} -J "http://youtube.com/watch?v=${get_data[v]}" &> output$random_hash.log)
if [[ $video == '' ]]; then # seriously WHO DID THIS
output=$(cat output$random_hash.log)
rm output$random_hash.log
@ -147,7 +147,7 @@ if [[ "${get_data[v]}" ]]; then
strings[playlist]=""
if [[ "${get_data[playlist]}" ]]; then
playlist=$(haruhi-dl --cookies ${cfg[_cookies]} -j --flat-playlist "https://www.youtube.com/playlist?list=${get_data[playlist]}")
playlist=$(haruhi-dl --ie-key YoutubePlaylist --cookies ${cfg[_cookies]} -j --flat-playlist "https://www.youtube.com/playlist?list=${get_data[playlist]}")
IFS=$'\n'
video_title=($(jq -r '.title' <<< $playlist))