#!/bin/bash
# Released under GNU General Public License 3 by celeste:crystalfaery 2011-02-07 00:33:18+00:00
# http://www.crystalfaeries.net/linux/bin/mediabookmarks
# mediabookmarks updates http://www.crystalfaeries.net/lsl/bookmarks <-- THIS HAS TO BE CHANGED AS LSL IS GONE (WHY?)
# a file used in Second Life (TM) "televisions" at Celestial Abode
# and updates http://www.crystalfaeries.net/Stations
# a file used by http://www.crystalfaeries.net/lsl/relax_radio_remote_command.2.7.lsl  <-- THIS HAS TO BE CHANGED AS LSL IS GONE (WHY?)

exit	1	# Debugging Exit

cat	/home/kahealani/audio/playlists/shoutcast2sl.txt	| tr -d '\r' | sort -u >	/tmp/stations.$$.txt
mv	/tmp/stations.$$.txt	/home/kahealani/audio/playlists/shoutcast2sl.txt

let i=0
cp	/dev/null						/tmp/bookmarks.$$.txt
cp	/dev/null						/home/www/lsl/Stations
for s in `cat /home/kahealani/audio/playlists/shoutcast2sl.txt`	;	do
	let i++
	echo -n	"$i|"					>>	/tmp/bookmarks.$$.txt
	echo -n	"r$i="					>>	/home/www/lsl/Stations
	echo	"$s"					>>	/tmp/bookmarks.$$.txt
	echo	"$s"					>>	/home/www/lsl/Stations
done

cp	/dev/null	/tmp/files.$$.txt
find	/home/www/audio/	-type f	\! -iname "*.html"	-exec basename {} \;	\
	|	grep -v "CACHEDIR.TAG"	|	grep -v ".directory"	\
	|	sed 's/\....$//'	|	sort -u	>	/tmp/media.$$.txt

for	f	in	`cat	/tmp/media.$$.txt`						;	do
	for g	in	`find	/home/www/audio/	-iname	"*$f*" | sed 's/\/var\/www\///'`	;	do
		echo -n	"$f|http://www.crystalfaeries.net/"	>>	/tmp/bookmarks.$$.txt
		echo	"$g"				>>	/tmp/bookmarks.$$.txt
	done
done

cp	/dev/null	/tmp/files.$$.txt
find	/home/www/meditation/		-type f	\! -iname "*.html"	-exec basename {} \;	\
	|	grep -v "CACHEDIR.TAG"	|	grep -v ".directory"	\
	|	sed 's/\....$//'	|	sort -u	>	/tmp/media.$$.txt

for	f	in	`tac	/tmp/media.$$.txt`						;	do
	for g	in	`find	/home/www/meditation/	-iname	"*$f*" | sed 's/\/var\/www\///'`	;	do
		echo -n	"$f|http://www.crystalfaeries.net/"	>>	/tmp/bookmarks.$$.txt
		echo	"$g"				>>	/tmp/bookmarks.$$.txt
	done
done

for	f	in	`tac	/tmp/media.$$.txt`						;	do
	for g	in	`find	/home/www/video/	-iname	"*$f*" | sed 's/\/var\/www\///'`	;	do
		echo -n	"$f|http://www.crystalfaeries.net/"	>>	/tmp/bookmarks.$$.txt
		echo	"$g"				>>	/tmp/bookmarks.$$.txt
	done
done

mv /tmp/bookmarks.$$.txt /home/www/lsl/bookmarks
#for f in `cat audio/playlists/shoutcast2sl.txt`;do let i=$i+1; echo r"$i"="$f" >> /tmp/playlist.txt; done


syntax highlighted by Code2HTML, v. 0.9.1