Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Audacious - Get Random Albums!
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Multimedia
View previous topic :: View next topic  
Author Message
Holysword
l33t
l33t


Joined: 19 Nov 2006
Posts: 946
Location: Greece

PostPosted: Tue Jul 31, 2012 9:05 am    Post subject: Audacious - Get Random Albums! Reply with quote

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)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Multimedia All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum