CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Need a Custom or Prewritten Perl Program?: I need a program that...:
Play you tube vids

 



Tsalagi
Novice

Jun 9, 2010, 5:49 AM

Post #1 of 2 (1555 views)
Play you tube vids Can't Post

I would like a script that allows a user to enter a you tube embed script into a HTML form input box and have the video play on the same page after the form has been saved.


Zhris
User

Jun 15, 2010, 9:27 PM

Post #2 of 2 (1459 views)
Re: [Tsalagi] Play you tube vids [In reply to] Can't Post

A very rough script which performs your specified task:


Code
#! /usr/bin/perl 
use strict;
use CGI ':standard';
$CGI::POST_MAX = 1000000;
print "content-type: text/html\n\n";
#####
my $mysubmit = param('mysubmit');
my $mytextarea = param('mytextarea');
#####
if ($mysubmit) {
if ($mytextarea =~ m/^<object.+<\/object>/) {
#Commented line below will autoplay video
#$mytextarea =~ s/(<embed src=\"[^\"]+)/$1&autoplay=1/;
print qq($mytextarea);
}
else {
print qq(<p>Invalid embed code</p>);
}
}
#####
print qq(<form action="script.pl" method="post"><textarea name="mytextarea">$mytextarea</textarea><input type="submit" name="mysubmit" value="Play Video" /></form>);


Chris


(This post was edited by Zhris on Jun 15, 2010, 9:49 PM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives