Skip to content

Commit

Permalink
Added scripts that combine drives to ~/pikaraoke-songs.
Browse files Browse the repository at this point in the history
Songs are added via symbolic link.
This allows songs in subdirectories to be added as well.
  • Loading branch information
RecursiveFunctions committed Dec 23, 2023
1 parent e550a18 commit f1296fa
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
42 changes: 42 additions & 0 deletions combine.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash
shopt -s globstar

path="/home/$(logname)/pikaraoke-songs"
combined="/media/unified"
drive_list="/home/$(logname)/pikaraoke/list"
cache="/home/$(logname)/pikaraoke-songs/song_cache"
#ensure directories and files exist
if [[ -d $path ]]; then
echo "$path exists"
else
sudo mkdir -p $path
fi
if [[ -d $combined ]]; then
echo "$combined exists"
else
sudo mkdir -p $path
fi

#get a list of external devices
lsblk -o NAME | grep sd[a-z][0-9] > $drive_list
sed -i 's/^..//' $drive_list


for drive in $(cat $drive_list); do
echo "combining drives"
sudo mount "/dev/$(basename $drive)" "/media/$(basename $drive)"
sudo mount --bind "/media/(basename $drive)" $combined
done

#run plocate and get a list of all song paths in the combined folder
bash /home/$(logname)/pikaraoke/create_database.sh

#add songs to ~/pikaraoke-songs
while IFS= read -r song || [ -n "$song" ]; do
if [[ ! -e "$path/$(basename "$song")" ]]; then
BASE=$(basename "$song")
ln -sf "$song" "/home/pi/pikaraoke-songs/$BASE"
fi
done < <(cat "song_paths")
echo "" > song_paths
#ls $path > $cache
5 changes: 5 additions & 0 deletions create_database.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

#make an updatedb specifically for /media/unified
sudo updatedb -l 0 -U /media/unified -o /home/$(logname)/pikaraoke/plocate.db
plocate media/$(logname) | grep -E "\.(zip|cdg|mp3|mp4)$" > song_paths
1 change: 1 addition & 0 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ if [[ $(cat /etc/os-release | grep -i debian) != "" ]]; then
sudo apt-get install ffmpeg -y
sudo apt-get install chromium-browser -y
sudo apt-get install chromium-chromedriver -y
sudo apt-get install plocate -y
if [ $? -ne 0 ]; then echo "ERROR: Binary dependency installation failed with error code: $?"; exit 1; fi
else
echo "Client is not Debian-based. Skipping binary installation. Please install ffmpeg and chrome manually.";
Expand Down

0 comments on commit f1296fa

Please sign in to comment.