Cron jobs - pull media and add to playlists

Read 9834 times
Has anyone found an easy way to setup a cron job for which will pull the new media into the library and then have it add to a certain playlist?  I was able to do so with another program, but have had no success.  Using the command line yields something close, but I do not know how to issue a command in the cron that would input the users password.
Yup, sure can.  This is a fairly common request... the command would look something like:
Code: [Select]
/home/centovacast/system/runascc/runascc exec ccmanage reindex USERNAME --intoplaylistname=KEYWORD
Replace USERNAME with the username for the stream you want to work with, and replace KEYWORD with a keyword matching the playlist you want to import into (eg, for the "Heavy rotation" playlist, use --intoplaylistname=heavy).

As for getting around the password issue, you can either use:
Code: [Select]
echo 'PASSWORD' | /home/centovacast...
...where PASSWORD is the relevant user's password, or if you don't want to have to keep track of each user's password, you can use:
Code: [Select]
echo 'admin|PASSWORD' | /home/centovacast...
...where PASSWORD is the password for the admin account.

Tying it all together, you can create a bash script that looks something like this, which will go through ALL of your accounts and pull any new media into each account's "heavy rotation" playlist:

Code: [Select]
#!/bin/sh
PLAYLISTNAME=heavy
ADMINPASS=secret

cd /home/centovacast/vhosts
for f in `find * -maxdepth 0 -type d`; do
    echo "admin|$ADMINPASS" \
       | /home/centovacast/system/runascc/runascc exec ccmanage reindex $f --intoplaylist=$PLAYLISTNAME
done


Hope that helps..
That helps a ton!  What is the easiest way to include this into a cron job?  You mention a bash script.  Being a new but quick learner of linux, how does one go about creating a bash script?
Also you reference heavy as the name for the playlist.  How do we detemine what the names of each playlist are?  Say we wanted to use a different playlist and name, where do we locate that?
Also is there a way to run the command line and tell it to exclude files?  I have files for station ID that I dont want in the regular playlist.
I played with this a little and determine that when entering the playlist name it is case sensitive and needs to be named exactly the same as your playlist name.... i.e. Heavy Rotation or Station Identification.
Quote
Being a new but quick learner of linux, how does one go about creating a bash script?

Just take the script I posted above and put it into a file named filename.sh (use nano or vim or whatever you normally use to edit files on your server), then save it and make it executable:

Code: (shell) [Select]
chmod a+x filename.sh
Then you can just run it as /path/to/filename.sh.  Obviously pick a better filename. :)  

Quote
How do we detemine what the names of each playlist are?

Login to the account and check the playlist list.  The name is the title of the playlist.

Quote
Also is there a way to run the command line and tell it to exclude files?

Few ways you could do it, but off the top of my head, replace line 6 of the script above with:

Code: (shell) [Select]
for f in `find * -maxdepth 0 -type d | grep -v stationid`; do
Then put all of your station IDs in a subdirectory called "stationid".

Quote
I played with this a little and determine that when entering the playlist name it is case sensitive and needs to be named exactly the same as your playlist name

Not unless something is up with your MySQL server.  I'm looking at the code right now and it just does a query to the effect of:

SELECT ... WHERE title LIKE '%playlistname%' ...

So that should be case-insensitive and it should match partial names as intended, eg. using "heavy" should match "Heavy Rotation".
I ran the script and below is the outcome.  You will notice that one of the first lines it reference "Rotation".  I have also included my .sh script.  Using "Standard Rotation" vs. "standard" is the only way I can get it to run.

[root@srvr1 Scripts]# ./centova.sh
./centova.sh: line 2: Rotation: command not found
Enter password for demo: INF Indexing files...
INF Progress: 8%; indexing Hard House and UK Hard House/Warp Brothers/Unknown Album/Confusion (remix).mp3
INF Progress: 16%; indexing Hard House and UK Hard House/Klubbheads/01 Klubbheads Singles Mix Album 1998/08. BROOKLYN BOUNCE - REAL BASS.mp3
INF Progress: 24%; indexing Hard House and UK Hard House/Klubbheads/04 Hiphopping 2000/03. KLUBBHOPPING.mp3
INF Progress: 32%; indexing Hard House and UK Hard House/Klubbheads/03 Klubbheads in The Mix 1999/04. CARLOS - THE .mp3
INF Progress: 40%; indexing Speed Garage/VOL 2/13. SUPERBEAT - FEEL THE BASS clubb mix.mp3
INF Progress: 49%; indexing Speed Garage/VOL 1/6.BARABAS & OD1 -JACK OF KLUBZ- tidy boys remix.mp3
INF Progress: 57%; indexing Prog House and Trance/SASH - BEST OF CD1 - 15 - TOGETHER AGAIN.mp3
INF Progress: 65%; indexing Prog House and Trance/06-LoveParade - Love Rules. 2003 compilation (CD2)/09-Braunschweig - Hauptbanhof.mp3
INF Progress: 73%; indexing Prog House and Trance/dido - Faithless feat. Dido- Flowerstand Man.mp3
INF Progress: 81%; indexing Prog House and Trance/05-LoveParade - Love Rules. 2003 compilation (CD1)/04-Oliver Cheatham - Song 'Fear And Loathing In Las Vegas'.mp3
INF Progress: 90%; indexing Prog House and Trance/SASH - IT'S MY LIFE - 12 - ECUADOR (BRUCE WAINE MIX).mp3
INF Progress: 98%; indexing Prog House and Trance/VOL 5/DARUDE - HEALING.mp3
INF Progress: 100%; indexing House/7up & Elysium Live @ 2 Red Lounge Part 3.mp3
INF Checking for missing files...
INF Checking for missing album covers...
OK Tracks reindexed
Enter password for lhrdnb: INF Indexing files...
INF Progress: 19%; indexing 6. HIGH CONTRAST - GLOBAL LOVE.mp3
INF Progress: 39%; indexing 8.COPY CAT -2-2-2-2-.mp3
INF Progress: 59%; indexing 11. DJ HYPE - PLAYAZ STYLE.mp3
INF Progress: 78%; indexing PSTERFOLL - THE DJ.mp3
INF Progress: 98%; indexing 12.TOTAL SCIENCE - SQUASH.mp3
INF Progress: 100%; indexing PRODIGY - CLIMPBATAIZE remix.mp3
INF Checking for missing files...
INF Checking for missing album covers...
OK Tracks reindexed
Enter password for lhrhiphop: INF Indexing files...
INF Progress: 40%; indexing hiphop/HipHop/10-Jay-Z-Streets_is_Watching-FUA.mp3
INF Progress: 81%; indexing hiphop/HipHop/24-camron-jamaican_join_ft_diplomats-std.mp3
INF Progress: 100%; indexing hiphop/HipHop/110-r._kelly-fiesta_(remix)_(ft_jay-z_and_boo_and_gotti)-osc.mp3
INF Checking for missing files...
INF Checking for missing album covers...
OK Tracks reindexed
Enter password for lhrrock: INF Indexing files...
INF Progress: 15%; indexing 04-godsmack-make_me_believe-rns.mp3
INF Progress: 31%; indexing Heavy/Disturbed/Indestructible/10 Criminal.mp3
INF Progress: 47%; indexing Heavy/Korn/Korn/07 Shoots and Ladders.mp3
INF Progress: 63%; indexing Heavy/Skindred - Set it off.mp3
INF Progress: 79%; indexing Unwritten Law/Here's To The Mourning/07 I Like The Way.mp3
INF Progress: 95%; indexing Rock/sublime - waiting for my ruca.mp3
INF Progress: 100%; indexing 02-limp_bizkit-eat_you_alive-esc.mp3
INF Checking for missing files...
INF Checking for missing album covers...
OK Tracks reindexed


#!/bin/sh
PLAYLISTNAME=Standard Rotation
ADMINPASS=XXXXXX

cd /home/centovacast/vhosts
for f in `find * -maxdepth 0 -type d`; do
echo "admin|$ADMINPASS" \
| /home/centovacast/system/runascc/runascc exec ccmanage reindex $f --intoplaylist=$PLAYLISTNAME
done
Also after I ran the script, I then checked my playlist and certain MP3's I uploaded were not added to the playlist.  They were in the media library though.
bash requires that strings with spaces are wrapped in quotes... i.e., PLAYLISTNAME="Standard Rotation".
Well I went into the script and changed it and now this is the output.

/home/Scripts$ ./centova.sh
Enter password for demo: INF Indexing files...
ERR The specified playlist does not exist.
Enter password for lhrdnb: INF Indexing files...
ERR The specified playlist does not exist.
Enter password for lhrhiphop: INF Indexing files...
ERR The specified playlist does not exist.
Enter password for lhrrock: INF Indexing files...
ERR The specified playlist does not exist.

I changed it to read PLAYLISTNAME="Standard Rotation"
That's just a typo -- it should be "intoplaylistname" like I wrote in my original post rather than "intoplaylist" which I put in the script.