-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added scripts that combine drives to ~/pikaraoke-songs.
Songs are added via symbolic link. This allows songs in subdirectories to be added as well.
- Loading branch information
1 parent
e550a18
commit f1296fa
Showing
3 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters