Myślę, że najlepiej byłoby zrobić generalnie tak, że na kompie, na którym masz filmy postawisz serwer z PHP.
Jeżeli te wszystkie katalogi z filmami masz w jednym zbiorczym katalogu, to możesz go podlinkować do katalogu, w którym byłby localhost serwera. Wted katalog np. /var/www/filmy wskazywałby na ten właściwy, do którego zasysasz.
Wygenerowaniem zaś stronki zająłby się już PHP.
W zasadzie całość w bashu też można zrobić, nawet nie jest to masakra... Tylko absolutnie nie znam się na sieciach i nie wiem, jak mają wyglądać linki do tych filmów. Tzn. załóżmy ponownie, że masz jeden zbiorczy katalog, np.:
./filmy
a w nim jakieś katalogi typu
./filmy/blabla1/
./filmy/cośtamxxx/
to czy jeżeli linki w kodzie strony będą typu:
href="./blabla/film.avi"
to czy Cię ratuje? Czy hrefy mają być jakieś inne?
Ok, jeżeli tak, to napisałem:
Kod: Zaznacz cały
#!/bin/bash
#genfilm; written by Outslider, idea by CzAroli
#As free as Public Domain
#Please, don't remove this comments...
#Just for Christmas
#general config
link_prefix="."
tmp="/tmp/genfilm_generator"
img_width="150"
img_height="220"
#/general config
#cmdline options check
opts="- $@"
help=`echo $opts|grep " -h"`
dir=`echo $opts|sed 's/-[a-Z]* /\n/g'|tail -1`
if [ "$help" != "" ]; then
echo -e "\ngenfilm; written by Outslider, idea by CzAroli"
echo -e "As free as Public Domain\n"
echo -e "synopsis: genfilm [options] path/to/directory/with/films\n"
echo -e "Given directory should contain subdirs containig two files: xxxxx.avi and yyyyy.jpg, where is no matter, what are xxx and yyy\n"
echo -e "options:\n"
echo -e "-h\tdisplay this help"
echo -e "\nThere is no more opts yet..."
echo -e ""
echo -e "known bugs:\n\n\tdirs' names cannot contain string: \" -h\" and spaces"
# echo -e "\tdirs' names cannot contain any spaces"
exit 0
fi
#/cmdline options check
#tmp check
if [ -d "$tmp" ]; then
rm -r "$tmp"
fi
mkdir "$tmp"
#/tmp check
#to the dir!!!
if [ -d "$dir" ]; then
echo -e "Ok:\tdirectory \"$dir\" found"
else
echo -e "E: \tdirectory \"$dir\" not found"
exit 1
fi
cd "$dir"
#/to the dir!!!
#list dirs
ls -F|grep -r '/$' > "$tmp/listof_files"
numof_films=`cat "$tmp/listof_files"|wc -l`
echo -e "Ok:\tfound $numof_films subdir(s)"
#/list dirs
#make HTML file... head
echo '<!DOCTYPE html
PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl" lang="pl">
<head>
<title>Personal Video Center</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" />
<meta name="Description" content="Personal Video Center generated by GenFilm - written by Outslider, idea by CzAroli" />
</head>
' > "$tmp/html_output.html"
#/make HTML file... head
#make HTML file... body
echo '<body>' >> "$tmp/html_output.html"
Li=1
until [ "$Li" -gt "$numof_films" ]; do
subdir=`cat "$tmp/listof_files"|head -$Li|tail -1`
echo $subdir
img=`ls ./"$subdir"|grep ".jpg"`
echo $img
vid=`ls ./"$subdir"|grep ".avi"`
echo $vid
echo '<img src=./'"$subdir""$img"' />'
echo '<div style="width: '$(($img_width+20))'px; height:' $(($img_height+30))'px; margin: 20px; text-align: center; float: left; background-color: black; color: white;">' >> "$tmp/html_output.html"
echo '<a style="color: white; text-decoration: none;" href="./'"$subdir""$vid"'">' >> "$tmp/html_output.html"
echo '<img style="width: '$img_width'px; height:' $img_height'px; margin: 10px;" src="./'"$subdir""$img"'" />' >> "$tmp/html_output.html"
echo "$vid" >> "$tmp/html_output.html"
echo '</a>' >> "$tmp/html_output.html"
echo '</div>' >> "$tmp/html_output.html"
Li=$(($Li+1))
done
#/make HTML file... body
#move (actually cp...) tmp-html where it has to be
echo -e "</body>\n<html>" >> "$tmp/html_output.html"
cp "$tmp/html_output.html" ./index.html
#/move tmp-html where it has to be
#and make clean!
rm -r "$tmp"
#and make clean!
exit
Krótki opis:
Masz taki układ katalogów, jak powyżej, każdy subfolder musi zawierać plik xxxx.jpg z okładką i yyyyy.avi z filmem. Nazwy folderów (chyba plików też) nie mogą zawierać spacyj (nie chciało mi się naprawiać tego buga;p)
Skrypt odpalasz z konsoli podając mu ścieżkę do katalogu z subfolderami. Opcja -h wyświetla minipomoc, acz w niej jest to, co tu napisałem.
W katalogu tworzony jest index.html, o który chodziło. Oczywiśie po przeniesieniu htmla do innego katalogu NIE BĘDZIE działał poprawnie, bo linki nie będą się zgadzać.
Wesołych Świąt!