Holysword l33t
Joined: 19 Nov 2006 Posts: 946 Location: Greece
|
Posted: Tue Jul 31, 2012 9:05 am Post subject: Audacious - Get Random Albums! |
|
|
Hi there everybody,
Since I've played for the first time with Amarok I have been wanting that feature in which you tell Amarok to choose random albums from your collection to be ported in Audacious. Of course a lot of things would have to be changed, once Audacious does not keep a "Files collection" list. Because of that, I wrote a script which gathers my albums from my Musics folder, chosen them randomly, and just add them to Audacious queue. Prerequisites:
- Your musics collection has to be organized by album folders in your disk
- The album folder must match the wildcard "???? - *". Something like "2000 - Dr. Sin II" or like "1975 - Deep Purple - Come Taste The Band" is perfect.
- All your albums must be in the same root folder.
This is the script:
Code: |
#!/bin/bash
if [ $# -gt 0 ] ; then
TO_BE_CHOSEN=$1
else
TO_BE_CHOSEN=1
fi
MUSICS_DIR="/WHATEVAR IS YOUR DIR"
IFS="$(printf '\n\t')"
COUNTER=0
for ALBUM in `find "$MUSICS_DIR" -iname "???? - *"` ; do
ALBUMS[$COUNTER]="$ALBUM"
COUNTER=$((COUNTER + 1))
done
COUNTER=$((COUNTER-1))
CHOSEN="0"
NUMBER=$((COUNTER+999))
while [ $CHOSEN -lt $TO_BE_CHOSEN ] ; do
while [ $NUMBER -gt $COUNTER ] ; do
NUMBER=$RANDOM
done
# Check if it was not already chosen - it is always possible!
CHOSEN_ALREADY="NO"
for CHOSEN_ONE in $CHOSEN_ALBUMS[$CHOSEN] ; do
if [ "$CHOSEN_ONE" == "${ALBUMS[$NUMBER]}" ] ; then
CHOSEN_ALREADY="YES"
fi
done
if [ "$CHOSEN_ALREADY" == "NO" ] ; then
CHOSEN_ALBUMS[$CHOSEN]=${ALBUMS[$NUMBER]}
CHOSEN=$((CHOSEN +1))
fi
NUMBER=$((COUNTER+999))
done
audacious --enqueue ${CHOSEN_ALBUMS[@]}
|
- Problems: it appends it to your current playlist, so you gotta erase them manually
- This random number generator is not very good.
So any suggestions on how to improve this? "Use Amarok" is not a valid suggestion! =P _________________ "Nolite arbitrari quia venerim mittere pacem in terram non veni pacem mittere sed gladium" (Yeshua Ha Mashiach) |
|