Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8adbb1274e | |||
| 7e5b1b4e20 | |||
| 35321f0f4a | |||
| cb11960fbb | |||
| 86e986227f | |||
| 4716231802 | |||
| 35bc81e2da |
@@ -2,11 +2,14 @@
|
||||
## **Find songs nobody knows exist!**
|
||||
A small wrapper and custom list for fortune/misfortune that picks a random Teto song of the day from any of almost 28,000 original, finished songs with videos on VocaDB. Your original fortune command will remain untouched, tetosong just tells it to use a custom directory.
|
||||
|
||||
## **Enable Audio to Hear "Teto Song of the Day!" in your terminal from Utau, SynthV, or SynthV2 Teto!**
|
||||
Sound plays based on the song you get! Utau for Utau! SV for SV!
|
||||
https://github.com/user-attachments/assets/bc2a9909-d24a-43fa-882a-5e785cda3020
|
||||
|
||||
## **Now With Optional Automatic Updates!**
|
||||
Disabled by default, opt-in during setup to enable a systemd user service and timer to update the script and song list every Sunday at 5AM UTC. I check for new songs and push new tetofortunes from my server every Sunday at 3AM UTC
|
||||
|
||||
|
||||
## **Dependencies**
|
||||
|
||||
### install.sh and tetosong
|
||||
|
||||
BIN
audio/teto/SOTD.zip
Normal file
BIN
audio/teto/SOTD.zip
Normal file
Binary file not shown.
BIN
audio/teto/svSOTD.wav
Normal file
BIN
audio/teto/svSOTD.wav
Normal file
Binary file not shown.
BIN
audio/teto/utSOTD.wav
Normal file
BIN
audio/teto/utSOTD.wav
Normal file
Binary file not shown.
65
automakefortune/automakefortune.sh
Normal file
65
automakefortune/automakefortune.sh
Normal file
@@ -0,0 +1,65 @@
|
||||
#!/usr/bin/bash
|
||||
git clone git@github.com:eric5949/tetosong.git
|
||||
cd tetosong
|
||||
ARTIST=140308 # 116 is Kasane Teto
|
||||
CHILDREN="true" # If we want child voicebanks, we do so we can get all songs from utau, sv, and sv2
|
||||
START=0 # Start at the beginning of the recordset. if i wanted to make the file in chunks to use the api less i would use this and max to get the songs in chunks. They say dont use it "thousands of times a day", getting every teto song is 280 times. I think I'm ok. maybe.
|
||||
RESULTS=100 # Max results. Limit is 100.
|
||||
MAX=30000 # when to stop, there's as of 4-23-26 over 28,000 songs featuring Kasane Teto in the recordset i have selected.
|
||||
if [ ! -f var.json ]; then # var.json has our latest date, we use it to know where to stop going back, past it the songs already exist in the fortune file.
|
||||
echo '{"lastDate": "2000-04-21T00:00:00Z"}' > var.json # if it doesn't exist, we create it with a default date back in 2000.
|
||||
fi
|
||||
PREVDATE=$(jq -r '.lastDate' var.json)
|
||||
AFTERDATE=$(date -u -d "$PREVDATE + 1 Second" +"%Y-%m-%dT%H:%M:%SZ")
|
||||
echo "Result: $AFTERDATE"
|
||||
#rm tetofortunes var.json tetofortunes.dat # during testing we will remove everything, or if we want to regenerate the fortune file from scratch.
|
||||
# setting the latest date. just pulling the latest song from the api and setting the createDate as the latest date in var.json for use when we update the fortune file again, dont want to add the same songs twice. idk how I'll handle broken links and such, maybe just regenerate the whole thing periodically.
|
||||
CURLURL="https://vocadb.net/api/songs?songTypes=Original&afterDate=${AFTERDATE}&&artistId%5B%5D=${ARTIST}&childVoicebanks=${CHILDREN}&onlyWithPvs=true&status=Finished&start=0&maxResults=1&sort=PublishDate&fields=PVs"
|
||||
echo "CURLURL: $CURLURL"
|
||||
DATA=$(curl -X 'GET' \
|
||||
$CURLURL \
|
||||
-H 'accept: application/json')
|
||||
# making sure there are songs to add.
|
||||
SONGS=$(echo "$DATA" | jq -c '.items | length')
|
||||
if [ "$SONGS" -eq 0 ]; then
|
||||
echo "Result is empty. No more songs."
|
||||
exit 0
|
||||
fi
|
||||
DATE=$(echo "$DATA" | jq -r '.items[0].publishDate')
|
||||
echo "DATE: $DATE"
|
||||
echo "{\"lastDate\": \"$DATE\"}" > var.json
|
||||
# looping the api to get all songs we need.
|
||||
while true; do
|
||||
CURLURL="https://vocadb.net/api/songs?songTypes=Original&afterDate=${AFTERDATE}&&artistId%5B%5D=${ARTIST}&childVoicebanks=${CHILDREN}&onlyWithPvs=true&status=Finished&start=${START}&maxResults=${RESULTS}&sort=PublishDate&fields=PVs"
|
||||
DATA=$(curl -X 'GET' \
|
||||
$CURLURL \
|
||||
-H 'accept: application/json')
|
||||
SONGS=$(echo "$DATA" | jq -r '.items | length')
|
||||
if [ "$SONGS" -eq 0 ]; then
|
||||
echo "Result is empty. No more songs."
|
||||
break
|
||||
else
|
||||
START=$((START + SONGS))
|
||||
echo "Found songs! Processing... (Total fetched: $START)"
|
||||
echo "$DATA" | jq -r '.items[] | [.artistString, .defaultName, .pvs[0].url] | @tsv' | while IFS=$'\t' read -r artist name url; do
|
||||
echo "TETO SONG OF THE DAY!"
|
||||
echo ""
|
||||
echo "$artist -- $name"
|
||||
echo ""
|
||||
echo "$url"
|
||||
echo ""
|
||||
echo "▼・ᴗ・▼"
|
||||
echo "%"
|
||||
done >> tetofortunes
|
||||
if [ "$START" -ge "$MAX" ]; then
|
||||
echo "Reached max results. Stopping."
|
||||
break
|
||||
fi
|
||||
echo "Done!"
|
||||
fi
|
||||
done
|
||||
# create the fortune database from tetofortunes
|
||||
rm tetofortunes.dat # delete the old database if it extists.
|
||||
strfile -c % tetofortunes tetofortunes.dat
|
||||
git commit -m "Update fortune files"
|
||||
git push -u origin main
|
||||
7
automakefortune/makefortune.service
Normal file
7
automakefortune/makefortune.service
Normal file
@@ -0,0 +1,7 @@
|
||||
[Unit]
|
||||
Description=tetofortunes autoupdater
|
||||
Wants=makefortune.timer
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=%h/.local/bin/automakefortune.sh
|
||||
10
automakefortune/makefortune.timer
Normal file
10
automakefortune/makefortune.timer
Normal file
@@ -0,0 +1,10 @@
|
||||
[Unit]
|
||||
Description=Run automakefortune.sh once a week
|
||||
|
||||
[Timer]
|
||||
OnCalendar=Sun *-*-* 03:00:00
|
||||
Persistent=true
|
||||
Unit=makefortune.service
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
||||
@@ -4,4 +4,4 @@ Wants=tetosong.timer
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/bin/bash -c "curl -s file:///home/eric/GitHub/TetoSongOfTheDay/autoupdater/updater.sh | bash"
|
||||
ExecStart=/usr/bin/bash -c "curl -s https://raw.githubusercontent.com/eric5949/tetosong/refs/heads/main/autoupdater/updater.sh | bash"
|
||||
|
||||
@@ -2,14 +2,21 @@
|
||||
# download custom fortunes and config file
|
||||
echo "Updating tetosong..."
|
||||
# check if the config file exists, if not download it and prompt the user for options.
|
||||
if [ ! -f ~/.local/share/tetosong/tetosong.config ]; then
|
||||
echo "Config file not found, downloading default..."
|
||||
curl -sLo ~/.local/share/tetosong/tetosong.config https://raw.githubusercontent.com/eric5949/tetosong/refs/heads/main/tetosong.config
|
||||
fi
|
||||
mkdir -p ~/.local/share/tetosong
|
||||
curl -sLo ~/.local/share/tetosong/tetofortunes https://raw.githubusercontent.com/eric5949/tetosong/refs/heads/main/tetofortunes
|
||||
curl -sLo ~/.local/share/tetosong/tetofortunes.dat https://raw.githubusercontent.com/eric5949/tetosong/refs/heads/main/tetofortunes.dat
|
||||
curl -sLo ~/.local/share/tetosong/sv2SOTD.wav https://raw.githubusercontent.com/eric5949/tetosong/refs/heads/main/sv2SOTD.wav
|
||||
|
||||
|
||||
mkdir -p ~/.local/share/tetosong/fortunes
|
||||
mkdir -p ~/.local/share/tetosong/fortunes/tetosotd
|
||||
curl -sLo ~/.local/share/tetosong/fortunes/tetosotd/tetofortunes https://raw.githubusercontent.com/eric5949/tetosong/refs/heads/main/fortunes/tetosotd/tetofortunes
|
||||
curl -sLo ~/.local/sharetetosong/fortunes/tetosotd/tetofortunes.dat https://raw.githubusercontent.com/eric5949/tetosong/refs/heads/main/fortunes/tetosotd/tetofortunes.dat
|
||||
AUDIO="$(. ~/.local/share/tetosong/tetosong.config; echo $AUDIO)"
|
||||
if [ "$AUDIO" = "YES" ]; then
|
||||
curl -sLo ~/.local/share/tetosong/SOTD.zip https://raw.githubusercontent.com/eric5949/tetosong/refs/heads/main/audio/teto/SOTD.zip
|
||||
mkdir -p ~/.local/share/tetosong/audio/
|
||||
mkdir -p ~/.local/share/tetosong/audio/teto/
|
||||
unzip -o ~/.local/share/tetosong/SOTD.zip -d ~/.local/share/tetosong/audio/teto/
|
||||
rm ~/.local/share/tetosong/SOTD.zip
|
||||
fi
|
||||
|
||||
# set up autoupdater
|
||||
# # i use systemd, so i use systemd timers. I'll figure out something for non-systemd users later.
|
||||
|
||||
33
installer.sh
33
installer.sh
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
# check which fortune command is installed if any.
|
||||
if ! [ -x "$(command -v fortune)" ]; then
|
||||
echo 'fortune is not installed, checking for misfortune'm
|
||||
@@ -15,24 +15,33 @@ fi
|
||||
# download custom fortunes and config file
|
||||
echo "Downloading custom fortunes and config file..."
|
||||
# download the config file and prompt the user for options.
|
||||
|
||||
curl -sLo ~/.local/share/tetosong/tetosong.config https://raw.githubusercontent.com/eric5949/tetosong/refs/heads/main/tetosong.config
|
||||
mkdir -p ~/.local/share/tetosong
|
||||
curl -sLo ~/.local/share/tetosong/tetosong.config https://raw.githubusercontent.com/eric5949/tetosong/refs/heads/test/tetosong.config
|
||||
read -p "Do you want to hear Teto in your terminal? (y/n) " yn
|
||||
case $yn in
|
||||
[Yy]* ) sed -i 's|^AUDIO=.*|AUDIO="YES"|' ~/.local/share/tetosong/tetosong.config ;;
|
||||
[Yy]* )
|
||||
sed -i 's|^AUDIO=.*|AUDIO="YES"|' ~/.local/share/tetosong/tetosong.config
|
||||
curl -sLo /tmp/SOTD.zip https://raw.githubusercontent.com/eric5949/tetosong/refs/heads/test/audio/teto/SOTD.zip
|
||||
mkdir -p ~/.local/share/tetosong/audio/
|
||||
mkdir -p ~/.local/share/tetosong/audio/teto/
|
||||
unzip -o /tmp/SOTD.zip -d ~/.local/share/tetosong/audio/teto/
|
||||
rm /tmp/SOTD.zip
|
||||
;;
|
||||
[Nn]* ) sed -i 's|^AUDIO=.*|AUDIO="NO"|' ~/.local/share/tetosong/tetosong.config ;;
|
||||
* ) echo "Please answer yes or no.";;
|
||||
esac
|
||||
read -p "Do you want to enable automatic updates? (y/n) " yn
|
||||
case $yn in
|
||||
[Yy]* ) sed -i 's|^AUTOUPDATE=.*|AUTOUPDATE="YES"|' ~/.local/share/tetosong/tetosong.config ;;
|
||||
[Yy]* )
|
||||
sed -i 's|^AUTOUPDATE=.*|AUTOUPDATE="YES"|' ~/.local/share/tetosong/tetosong.config ;;
|
||||
[Nn]* ) sed -i 's|^AUTOUPDATE=.*|AUTOUPDATE="NO"|' ~/.local/share/tetosong/tetosong.config ;;
|
||||
* ) echo "Please answer yes or no.";;
|
||||
esac
|
||||
mkdir -p ~/.local/share/tetosong
|
||||
curl -sLo ~/.local/share/tetosong/tetofortunes https://raw.githubusercontent.com/eric5949/tetosong/refs/heads/main/tetofortunes
|
||||
curl -sLo ~/.local/share/tetosong/tetofortunes.dat https://raw.githubusercontent.com/eric5949/tetosong/refs/heads/main/tetofortunes.dat
|
||||
curl -sLo ~/.local/share/tetosong/sv2SOTD.wav https://raw.githubusercontent.com/eric5949/tetosong/refs/heads/main/sv2SOTD.wav
|
||||
|
||||
mkdir -p ~/.local/share/tetosong/fortunes
|
||||
mkdir -p ~/.local/share/tetosong/fortunes/tetosotd
|
||||
curl -sLo ~/.local/share/tetosong/fortunes/tetosotd/tetofortunes https://raw.githubusercontent.com/eric5949/tetosong/refs/heads/test/fortunes/tetosotd/tetofortunes
|
||||
curl -sLo ~/.local/share/tetosong/fortunes/tetosotd/tetofortunes.dat https://raw.githubusercontent.com/eric5949/tetosong/refs/heads/test/fortunes/tetosotd/tetofortunes.dat
|
||||
|
||||
# set up autoupdater
|
||||
# i use systemd, so i use systemd timers. I'll figure out something for non-systemd users later.
|
||||
@@ -41,8 +50,8 @@ if [ "$AUTOUPDATE" = "YES" ]; then
|
||||
# write and enable systemd service file and timer user services
|
||||
echo "Autoupdater enabled, updating service..."
|
||||
mkdir -p ~/.config/systemd/user
|
||||
curl -sLo ~/.config/systemd/user/tetosong.service https://raw.githubusercontent.com/eric5949/tetosong/refs/heads/main/autoupdater/tetosong.service
|
||||
curl -sLo ~/.config/systemd/user/tetosong.timer https://raw.githubusercontent.com/eric5949/tetosong/refs/heads/main/autoupdater/tetosong.timer
|
||||
curl -sLo ~/.config/systemd/user/tetosong.service https://raw.githubusercontent.com/eric5949/tetosong/refs/heads/test/autoupdater/tetosong.service
|
||||
curl -sLo ~/.config/systemd/user/tetosong.timer https://raw.githubusercontent.com/eric5949/tetosong/refs/heads/test/autoupdater/tetosong.timer
|
||||
systemctl --user daemon-reload
|
||||
systemctl --user enable tetosong.timer
|
||||
systemctl --user start tetosong.timer
|
||||
@@ -52,6 +61,6 @@ fi
|
||||
# write tetosong to ~/.local/bin and tell the user how to use it.
|
||||
echo "writing tetosong to ~/.local/bin"
|
||||
mkdir -p ~/.local/bin
|
||||
curl -sLo ~/.local/bin/tetosong https://raw.githubusercontent.com/eric5949/tetosong/refs/heads/main/tetosong
|
||||
curl -sLo ~/.local/bin/tetosong https://raw.githubusercontent.com/eric5949/tetosong/refs/heads/test/tetosong
|
||||
chmod +x ~/.local/bin/tetosong
|
||||
echo "Make sure ~/.local/bin is in your PATH and you can get your Teto Song Of the Day by typing in tetosong or adding it to your bashrc :)"
|
||||
|
||||
47
tetosong
47
tetosong
@@ -2,12 +2,12 @@
|
||||
# argument handling
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
-u|--update)
|
||||
echo "Downloading tetosong updater..."
|
||||
bash <(curl -s https://raw.githubusercontent.com/eric5949/tetosong/refs/heads/main/autoupdater/updater.sh)
|
||||
shift
|
||||
exit 0
|
||||
;;
|
||||
-u|--update)
|
||||
echo "Downloading tetosong updater..."
|
||||
bash <(curl -s https://raw.githubusercontent.com/eric5949/tetosong/refs/heads/main/autoupdater/updater.sh)
|
||||
shift
|
||||
exit 0
|
||||
;;
|
||||
-h|--help)
|
||||
echo "--- TETOSONG HELP ---"
|
||||
echo ""
|
||||
@@ -25,8 +25,8 @@ done
|
||||
|
||||
# check if the config file exists, if not download it
|
||||
if [ ! -f ~/.local/share/tetosong/tetosong.config ]; then
|
||||
echo "Config file not found, downloading default..."
|
||||
curl -sLo ~/.local/share/tetosong/tetosong.config https://raw.githubusercontent.com/eric5949/tetosong/refs/heads/main/tetosong.config
|
||||
echo "Config file not found, downloading default..."
|
||||
curl -sLo ~/.local/share/tetosong/tetosong.config https://raw.githubusercontent.com/eric5949/tetosong/refs/heads/main/tetosong.config
|
||||
fi
|
||||
# check if the user wants to play audio
|
||||
AUDIO="$(. ~/.local/share/tetosong/tetosong.config; echo $AUDIO)"
|
||||
@@ -37,14 +37,35 @@ if ! [ -x "$(command -v fortune)" ]; then
|
||||
echo 'No fortune commmand is installed, exiting!'
|
||||
exit 1
|
||||
else
|
||||
if [ "$AUDIO" = "YES" ]; then
|
||||
nohup ffplay -nodisp -autoexit -v quiet ~/.local/share/tetosong/sv2SOTD.wav 2>/dev/null >/dev/null &
|
||||
misfortune ~/.local/share/tetosong/fortunes/*/* >> /tmp/fortune # fortune and misfortune handle directories differently
|
||||
if [ "$AUDIO" = "YES" ]; then # i guess i could foregoe checking and just run the audio either way since i dont download it unless the user enables it, but i want them to be ableto turn it off if they choose to
|
||||
if grep -q "SV2" /tmp/fortune; then
|
||||
nohup ffplay -nodisp -autoexit -v quiet ~/.local/share/tetosong/audio/teto/sv2SOTD.wav 2>/dev/null >/dev/null &
|
||||
elif grep -q "SV" /tmp/fortune; then
|
||||
nohup ffplay -nodisp -autoexit -v quiet ~/.local/share/tetosong/audio/teto/svSOTD.wav 2>/dev/null >/dev/null &
|
||||
elif grep -q "重音テト" /tmp/fortune; then
|
||||
nohup ffplay -nodisp -autoexit -v quiet ~/.local/share/tetosong/audio/teto/utSOTD.wav 2>/dev/null >/dev/null &
|
||||
else
|
||||
nohup ffplay -nodisp -autoexit -v quiet ~/.local/share/tetosong/audio/teto/sv2SOTD.wav 2>/dev/null >/dev/null &
|
||||
fi
|
||||
fi
|
||||
misfortune ~/.local/share/tetosong/* # fortune doesnt care if you give it a directory, apparently misfortune does. watch this be a problem when i go to add SynthV Teto in a separate file.
|
||||
cat /tmp/fortune
|
||||
rm /tmp/fortune
|
||||
fi
|
||||
else
|
||||
fortune ~/.local/share/tetosong/fortunes/* >> /tmp/fortune
|
||||
if [ "$AUDIO" = "YES" ]; then
|
||||
nohup ffplay -nodisp -autoexit -v quiet ~/.local/share/tetosong/sv2SOTD.wav 2>/dev/null >/dev/null &
|
||||
if grep -q "SV2" /tmp/fortune; then
|
||||
nohup ffplay -nodisp -autoexit -v quiet ~/.local/share/tetosong/audio/teto/sv2SOTD.wav 2>/dev/null >/dev/null &
|
||||
elif grep -q "SV" /tmp/fortune; then
|
||||
nohup ffplay -nodisp -autoexit -v quiet ~/.local/share/tetosong/audio/teto/svSOTD.wav 2>/dev/null >/dev/null &
|
||||
elif grep -q "重音テト" /tmp/fortune; then
|
||||
nohup ffplay -nodisp -autoexit -v quiet ~/.local/share/tetosong/audio/teto/utSOTD.wav 2>/dev/null >/dev/null &
|
||||
else
|
||||
nohup ffplay -nodisp -autoexit -v quiet ~/.local/share/tetosong/audio/teto/sv2SOTD.wav 2>/dev/null >/dev/null &
|
||||
fi
|
||||
fi
|
||||
fortune ~/.local/share/tetosong
|
||||
|
||||
cat /tmp/fortune
|
||||
rm /tmp/fortune
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user