You are not logged in.

#1 2009-08-11 04:41:41

Wintervenom
Member
Registered: 2008-08-20
Posts: 1,011

Filesystem-Based Music Library Views

This is a script I wrote to make virtual views from music collection.  I thought someome might find this useful, especially people who don't use a library-based media player for their music.  It may (will) have to be changed to likings. This currently depends on the library pool being in "$artist/$album/$title.$extension" format.

fmv-update:

#!/bin/bash

### Filesytem-based Music Library Views #########################
# Version 0.3 by Scott Garrett <wintervenom [(a)] archlinux.us> #
#################################################################

library="$HOME/Music/Library"
tmp="/dev/shm/fmv"

echo 'Looking for and deleting missing symlinks...'
find -L "$library/"{Artist,Album,Format,All} -type l -print0 | xargs -0 --no-run-if-empty rm

echo 'Deleting empty directories...'
find "$library" -depth -type d -empty -exec rmdir {} \;

echo 'Updating virtual libraries...'
mkdir -p "$library/"{Artist,Album,All,Format,Playlists}
mkdir -p "$tmp"

find "$library/Root" -type f > $tmp/list
sed -i "s:$library/Root/::" $tmp/list

((sl = `wc -l $tmp/list | cut -d' ' -f1` / 4 + 1))
split -l $sl $tmp/list $tmp/list.
rm $tmp/list

fmv-add a &
fmv-add b &
fmv-add c &
fmv-add d &

while [ "$(ls -A $tmp)" ]; do
    sleep 2
done
rm -rf $tmp

echo 'Done.'

fmv-add:

#!/bin/bash

### Filesytem-based Music Library Views - Add List ##############
# Version 0.3 by Scott Garrett <wintervenom [(a)] archlinux.us> #
#################################################################

library="$HOME/Music/Library"

IFS=$'\n'
for file in $(cat "/dev/shm/fmv/list.a$1"); do
    artist="${file%%/*}"; title="${file#*/}"
    album="${title%%/*}"; title="${title#*/}"
    title="${title%%/*}"; ext="${title##*.}"
    title="${title%.*}"
    [[ ! -e "$library/All/$title - $artist - $album" ]] && (
        mkdir -p "$library/"{"Artist/$artist","Album/$album","Format/$ext"}
        ln -sf "$library/Root/$file" "$library/Artist/$artist/$title - $artist - $album"
        ln -sf "$library/Root/$file" "$library/Album/$album/$title - $artist - $album"
        ln -sf "$library/Root/$file" "$library/Format/$ext/$title - $artist - $album"
        ln -sf "$library/Root/$file" "$library/All/$title - $artist - $album"
    )
done
rm "/dev/shm/fmv/list.a$1"
IFS=$' '

Last edited by Wintervenom (2009-08-12 02:05:22)

Offline

Board footer

Powered by FluxBB