IPB

Welcome Guest ( Log In | Register )

Movable Type

We're moving to movabletype.org!

At long last, we're moving to forums powered by, well, Movable Type itself. You'll want to bookmark http://forums.movabletype.org/ for future reference, and in the meantime you can view these old forums as a read-only archive of past posts. Thanks for being part of the community!

 
Reply to this topicStart new topic
> Youtube And Google Video Plugin
dwees
post Sep 3 2006, 01:05 PM
Post #1





Group: Members
Posts: 27
Joined: 26-August 06
Member No.: 36,599



Just developed a plugin to embed either Youtube or Google video directly into MT posts. Doesn't currently work with Dynamic publishing mostly because I'm not totally sure how to do so. I know how to write the proper Php code (because this plugin is basically a port of a Wordpress plugin) but not totally sure I know how to make it interact with MT properly. If someone tests my mathematical equation plugin for Dynamic publishing (see another recent post in this forum) maybe they can let me know what changes I need to make?

With this code you can use either use [yt]insert_YouTube_Id_here[/yt] or [yt width="somenumber" height="somenumber"]insert_YouTube_Id_here[/yt] for inserting YouTube videos into your posts OR for Google Video you can use [gv]insert_GoogleVideo_Id_here[/gv] or [gv width="somenumber" height="somenumber"]insert_GoogleVideo_Id_here[/gv].

Notes:

1. GoogleVideo ids sometimes have a - in the front, which is important to include.
2. The standard window sizes for YouTube are width = 425 and height = 350 and for Google Video the standard window sizes are width = 400 and height = 326. When choosing your height and width for either YouTube or Google Video, you'll have to do a bit of math to get the new dimensions correct (so that your video doesn't look distorted).

Installation:

To install this plugin simply save the code below into a file named videoembedding.pl (using a typical text editor like Notepad) and upload the file to your mt/plugins directory. You need to chmod the file to 755 to allow the web server to access it properly. I also suggest that you create a videoembedding directory within your plugins directory (and chmod it to 755) and actually place the file inside that, mostly just to keep your plugins directory organized.

When using the [yt][/yt] tags in your posts, you need to apply the Video filter in the Text Formatting options (which are generally located below your Edit post window).

You can see the results of my plug-in at: http://www.unitorganizer.com/myblog/

CODE
# Quick code + Video
# a text filter plug-in for bb style [codes]
#
# Modified by David Wees
# ver 1.02 Copyright 2004 Crys Clouse;

use MT;

MT->add_text_filter(video => { label => 'Video', on_format => sub { &vcode }, });

sub vcode {
    $_=shift;

    vfullcodes($_);
}

sub vfullcodes {
    $s = $_[0];

    $s =~ s!\[yt\](.*?)\[/yt\]!<object width="425" height="350" type="application/x-shockwave-flash" data="http://www.youtube.com/v/$1"><param name="movie" value="http://www.youtube.com/v/$1" /><param name="wmode" value="transparent" /></object>!gis;
    $s =~ s!\[yt width="(.*?)" height="(.*?)"](.*?)\[\/yt]!<object width="$1" height="$2" type="application/x-shockwave-flash" data="http://www.youtube.com/v/$3"><param name="movie" value="http://www.youtube.com/v/$3" /><param name="wmode" value="transparent" /></object>!gis;
    $s =~ s!\[gv\](.*?)\[/gv\]!<object width="400" height="326" type="application/x-shockwave-flash" data="http://video.google.com/googleplayer.swf?docId=$1"><param name="movie" value="http://video.google.com/googleplayer.swf?docId=$1" /><param name="allowScriptAccess" value="sameDomain" /><param name="quality" value="best" /><param name="scale" value="noScale" /><param name="wmode" value="transparent" /><param name="salign" value="TL" /><param name="FlashVars" value="playerMode=embedded" /></object>!gis;
    $s =~ s!\[gv width="(.*?)" height="(.*?)"\](.*?)\[/gv\]!<object width="$1" height="$2" type="application/x-shockwave-flash" data="http://video.google.com/googleplayer.swf?docId=$3"><param name="movie" value="http://video.google.com/googleplayer.swf?docId=$3" /><param name="allowScriptAccess" value="sameDomain" /><param name="quality" value="best" /><param name="scale" value="noScale" /><param name="wmode" value="transparent" /><param name="salign" value="TL" /><param name="FlashVars" value="playerMode=embedded" /></object>!gis;
    $s = vmaincodes($s);

    #$s =~ s!\*amp;!&!g;

    return $s;

    vmaincodes($_);
}
sub vcommentcodes {
    $s = $_[0];
    $s =~ s!<!\*amp;lt;!g;
    $s =~ s!>!\*amp;gt;!g;

    $s = vmaincodes($s);

    $s =~ s!\*amp;!&!g;

    return $s;
}
sub vmaincodes {
    $s = $_[0];

    $s =~ s!…!…!g;
    $s =~ s!‘!‘!g;
    $s =~ s!’!’!g;
    $s =~ s!“!“!g;
    $s =~ s!”!”!g;
    $s =~ s!–!–!g;
    $s =~ s!—!—!g;

    $s = MT::Util::html_text_transform($_[0]);
    $s =~ s!(<p>.*?</p>)!vsmarty_pnts($1)!geis;
    $s =~ s!<linebreak>!\n!g;

    return $s;
}

sub vsmarty_pnts {
    $s = $_[0];

    my $smarty = $MT::Template::Context::Global_filters{'smarty_pants'};

    if ($smarty)
      {
        return $smarty->($s, '1');
      }
    else
      {
        return $s;
    }
}

1;


This post has been edited by dwees: Sep 3 2006, 01:10 PM
Go to the top of the page
 
+Quote Post
microage97
post Apr 26 2008, 12:00 PM
Post #2





Group: Members
Posts: 48
Joined: 17-April 03
Member No.: 9,915



Works great.

Dave


--------------------
Dave
www.Japanish.org
Go to the top of the page
 
+Quote Post
Emiliano Bruni
post May 28 2008, 06:04 AM
Post #3





Group: Members
Posts: 2
Joined: 28-May 08
Member No.: 52,911



I completely rewrote this plugin for optimize regular expression, include standard movable type plugin interface and I extended support for other video source like vimeo.com and myspace.com.

Every suggestion and bug report is welcome.

Plugin home page:

http://www.ebruni.it/software/os/mtos/videoembedding/

This post has been edited by Emiliano Bruni: May 28 2008, 06:05 AM
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



Lo-Fi Version Time is now: 11.24.09 - 10:09 PM