Log in

View Full Version : A script that gets?



spyrule
01-01-2010, 03:28 AM
I'm not too sure where to begin, I have very limited knowledge of web design, and virtually no experience with php... I have an intranet set up in my house for me and my five room mates, and I have ripped our combined DVD collections to avi. I also have a LAMP set up, and so I am building a simple web site that my room mates and I can access that will stream our movies and tv shows from a central server. This makes storage a lot easier, but the web page that I have built is tedious to manage.

On my page I have links to the various videos, and they load new html pages with the videos as embeds which play through Divx Web Player; which streams our avi's perfectly. The problem is that every new video I add (which is a lot) has to have its own html page set up. This can be a pain, especially with just over six hundred individual videos.

Is there a way to make this more automated? My code for the embedded videos looks like this, for example:


<embed type="video/divx" src="http://empire/Cannibal/Movies/The Age of Stupid/The Age of Stupid.avi" custommode="none" width="400" height="260"></embed>

I've already have everything named just the way I want it. The videos are all in a folder with an identical title as the video itself. So, all I need to do is make it so that the link forwards the information to the embed code. Where the only thing that will change is the last portion of the path. "Moulin Rouge," for example, has the path of 'http://empire/Cannibal/Movies/Moulin Rouge/Moulin Rouge.avi'--and the movie "Crank" has the path 'http://empire/Cannibal/Movies/Crank/Crank.avi'... and so on and so on.

I would think this is fairly easy to do, but I don't even know what I'm looking for... Not even sure that it needs to be PHP. So if you could just point me in the right direction (though I'd appreciate a short walkthrough, I have no problems doing my own leg-work), I'd be very grateful :)

Thanks so much!

X96 Web Design
01-01-2010, 05:55 AM
You can use PHP... It would look something like this:

<?php
$url = $_GET['vid'];
echo '<embed type="video/divx" src="http://empire/Cannibal/Movies/' . $url . '/' . $url . '.avi" custommode="none" width="400" height="260"></embed>';
?>

Then, the url would be like this: index.php?vid=Movie Name Here. It would then take the value of vid and insert it into where it says $url. Here's an example:

If the movie was called My Awesome Movie, the URL would be:

http://empire/Cannibal/Movies/index.php?vid=My Awesome Movie
and then PHP would take that and insert it so the code would look like:

<embed type="video/divx" src="http://empire/Cannibal/Movies/My Awesome Movie/My Awesome Movie.avi" custommode="none" width="400" height="260"></embed>

You did say you have LAMP, right? because you'll need PHP installed...

If you run into any problems, don't hesitate to ask! :)

// X96 \\

spyrule
01-01-2010, 05:59 AM
Took me ten seconds to implement... saved me hours. Thank you so much!

X96 Web Design
01-01-2010, 06:00 AM
No problem! :D Glad to be of assistance...

// X96 \\

djr33
01-01-2010, 08:55 AM
In general, just some advice for starting off with PHP, remember that the entire point of PHP is to automate the generation of html. So any things that could be made as repeated tasks in writing html will be good to use PHP for. PHP is not all powerful though-- basically all it does is creating html (after doing more behind the scenes things like working with databases, processing variables, etc.).