Script to build web page of movies from directories
Hello! I'm new to linux. I installed DD-WRT onto a router and have it serving movies over http. I'd like to build a web page of all the movie poster art so my kids can easily choose a movie from the home page.
All movies are in /mnt/Videos. Some movies are in the root directory, but there are sub-directories with movies (/mnt/Videos/Barney, /mnt/Videos/Sesame Street, etc). For each movie there is a jpg image of the DVD cover, named exactly the same as the movie (i.e., Toy Story.m4v and Toy Story.jpg) How do I make a script that reads in all videos (including sub-directores), then builds an index.html of movie art jpg in two columns with as many rows as necessary (n x 2)? When the kids click on the picture, it should link to the movie file. BTW, the media server works very well and uses hardly any power. I wrote up the install at: http://www.dd-wrt.com/phpBB2/viewtop...=asc&start=315 |
this is a place where you get help ,if you have something that you have done we can assist but we rarely complete everything for you...
|
Wow. Thanks for the warm welcome on my first post here. I was expecting some guidance like "use this command," not go someplace else.
Here's what I was thinking... #!/opt/bin/sh rm index.html <<don't need help with code to build html header and table>> i=0 for file in /mnt/Videos/*jpg do i=i+1 <<code to assign row/column of movie poseter based on i>> new variable = need help figuring our how change the ".jpg" in $file to ".m4v" need help with writing to a file <a href="new variable"</a> done I also toyed around with using "find . -name *m4v > names.txt" then looping through the file to create the html code. I'm asking for your help strategizing the best methods and commands to use, not to write the script for me. |
No need to get offended by what he said, he was just giving you feedback saying that you would most likely not get a good response unless you post what you have attempted/have so far. This isn't really a place to have people do things for you, its a community of people helping/learning.
That said, I am not entirely sure how you should tackle this, and not a linux guru, but my first thought was something like this: ##EDIT: I like my second one better. This will list out the poster and movie as it comes across them. But I am pretty sure after writing this, there is some logical flaws with doing it this way. Code:
#!/bin/bash I left in the echos, i was just using them to test. Code:
#!/bin/bash Hope it helps, |
I ended up using find to create a list of all files on the drive. I think looked at the last four characters to see if the string was the movie (ending in m4v). The script works great. Thanks for the help.
!/bin/bash rm sorted_names rm movies.html find | sort -n > sorted_names FILENAME=sorted_names while read LINE do ext=$(echo $LINE | tail -c -4) if [[ "$ext" == "m4v" ]] then echo "<a href=\"$LINE\" >" >> movies.html echo "<img src=\"${LINE%????}.jpg\" width=\"360\" height=\"510\" />" >> movies.html fi done < $FILENAME rm sorted_names |
Ok ... so the second thing to cover is, please use [code][/code] tags around data and code as it will preserve formatting and make it easier to read.
You are on to some better ideas so let us see if we can get you over the line. How about something like: Code:
#!/bin/bash |
The solution posted by grail works iff all JPEGs in the directory tree are associated with a movie file. The more rigorous solution would find all movies, and from that, compose the respective JPEG filename. Actually, I see that is the algorithm used by montel, but merely using a temporary file to store the list of found files. It isn't stated in the original question, but montel's algorithm could also flag any movies that do not have an associated JPEG, and perhaps put a dummy image into the HTML output.
Always a good idea to assume the possibility of errors. --- rod. |
this seems related (although not html).
http://www.linuxquestions.org/questi...4/#post3508846 have you considered using xbmc ? |
hmmm ... so you have marked the problem as solved but given no ideas on what your solution is?
Remember from the first 2 posts, you were advised that we are here to help each other and when someone new searches the site they get the benefit of learning from you :) |
The LinuxCommand tutorial exercise is all about automating the building of an html page. It should help you out.
|
One thing to consider is using PHP on the server to create the page dynamically each time it is requested. PHP would be a better tool than Bash to accomplish what you have in mind. Have a look at: http://www.howtogeek.com/howto/progr...n-a-directory/
Regards, Stefan |
All times are GMT -5. The time now is 03:34 AM. |