Initial commit.
This commit is contained in:
commit
d714a37953
20
LICENSE
Normal file
20
LICENSE
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
Copyright (C) 2020 Ortega Froysa, Nicolás <nicolas@ortegas.org> All rights reserved.
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
|
||||||
|
3. This notice may not be removed or altered from any source
|
||||||
|
distribution.
|
15
README
Normal file
15
README
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
=================
|
||||||
|
*** play-lofi ***
|
||||||
|
=================
|
||||||
|
A small script that plays lofi music from Invidious[0], a YouTube
|
||||||
|
proxy. You can choose what stream you'd like to listen to and it saves
|
||||||
|
it to the file `$XDG_CONFIG_HOME/lofi-link`.
|
||||||
|
|
||||||
|
To use this script you will require the following:
|
||||||
|
- curl
|
||||||
|
- mpv
|
||||||
|
|
||||||
|
# License
|
||||||
|
---------
|
||||||
|
This script is licensed with the ZLib license. Basically, don't
|
||||||
|
misrepresent where you got the script from.
|
89
play-lofi
Executable file
89
play-lofi
Executable file
@ -0,0 +1,89 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Copyright (C) 2020 Ortega Froysa, Nicolás <nicolas@ortegas.org> All rights reserved.
|
||||||
|
# Author: Ortega Froysa, Nicolás <nicolas@ortegas.org>
|
||||||
|
#
|
||||||
|
# This software is provided 'as-is', without any express or implied
|
||||||
|
# warranty. In no event will the authors be held liable for any damages
|
||||||
|
# arising from the use of this software.
|
||||||
|
#
|
||||||
|
# Permission is granted to anyone to use this software for any purpose,
|
||||||
|
# including commercial applications, and to alter it and redistribute it
|
||||||
|
# freely, subject to the following restrictions:
|
||||||
|
#
|
||||||
|
# 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
# claim that you wrote the original software. If you use this software
|
||||||
|
# in a product, an acknowledgment in the product documentation would be
|
||||||
|
# appreciated but is not required.
|
||||||
|
#
|
||||||
|
# 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
# misrepresented as being the original software.
|
||||||
|
#
|
||||||
|
# 3. This notice may not be removed or altered from any source
|
||||||
|
# distribution.
|
||||||
|
|
||||||
|
link_file="$XDG_CONFIG_HOME/lofi-link"
|
||||||
|
|
||||||
|
new_link() {
|
||||||
|
local results=$(curl -s "https://invidio.us/search?q=lofi+radio" |
|
||||||
|
grep "<p>.*watch" | tr -d "\n" | tr -s " ")
|
||||||
|
results=${results//\<p\>\<a href\=\"/\"https:\/\/invidio.us}
|
||||||
|
results=${results//\"\>/\" \"}
|
||||||
|
results=${results//\<\/a\>\<\/p\>/\" æ }
|
||||||
|
results=${results::-2} # remove that last separator
|
||||||
|
|
||||||
|
# NOTE: I chose æ because never in a million years will that
|
||||||
|
# character be in the title of a lofi video stream.
|
||||||
|
IFS="æ" read -r -a streams <<< $results
|
||||||
|
|
||||||
|
echo "Streams:"
|
||||||
|
local id=1
|
||||||
|
for i in "${streams[@]}"
|
||||||
|
do
|
||||||
|
title=${i//*\" \"/\"}
|
||||||
|
echo "$id) ${title:1:-2}"
|
||||||
|
((id++))
|
||||||
|
done
|
||||||
|
opt=0
|
||||||
|
while [ "$opt" -gt "${#streams[@]}" ] || [ "$opt" -lt "1" ]
|
||||||
|
do
|
||||||
|
printf "Selection: "
|
||||||
|
read opt
|
||||||
|
done
|
||||||
|
link=${streams[$opt]}
|
||||||
|
link=${link//\" \"*/}
|
||||||
|
link=${link//*\"/}
|
||||||
|
echo $link > $link_file
|
||||||
|
}
|
||||||
|
|
||||||
|
# check for link file
|
||||||
|
if ! [ -e "$link_file" ]
|
||||||
|
then
|
||||||
|
echo "No link file found in '$link_file'."
|
||||||
|
while [ "$option" != "y" ] && [ "$option" != "n" ]
|
||||||
|
do
|
||||||
|
printf "Would you like to create one? [y/n] "
|
||||||
|
read option
|
||||||
|
done
|
||||||
|
[ "$option" = "n" ] && exit 1
|
||||||
|
new_link
|
||||||
|
echo "New link file created."
|
||||||
|
fi
|
||||||
|
|
||||||
|
link=$(cat $link_file)
|
||||||
|
|
||||||
|
# check if video is available
|
||||||
|
output=$(curl -s $link | grep "This video is unavailable.")
|
||||||
|
if [ -n "$output" ]
|
||||||
|
then
|
||||||
|
echo "The stream link '$link' is unavailable."
|
||||||
|
while [ "$option" != "y" ] && [ "$option" != "n" ]
|
||||||
|
do
|
||||||
|
printf "Would you like to find a new one? [y/n] "
|
||||||
|
read option
|
||||||
|
done
|
||||||
|
[ "$option" = "n" ] && exit 1
|
||||||
|
new_link
|
||||||
|
echo "New link saved."
|
||||||
|
fi
|
||||||
|
|
||||||
|
mpv --no-video --msg-level=ffmpeg=no $link
|
Loading…
Reference in New Issue
Block a user