3 require_once(dirname(__FILE__) . '/../Media_base.php');
5 class Media_teachertube implements MediaBase {
7 private static $base_url = 'http://www.teachertube.com/';
9 private static $default_width = 485;
10 private static $default_height = 300;
12 private static $embed_sources = array(
14 'match' => '#.*teachertube\.com/flvideo/([0-9]+)\.flv.*#',
15 'url' => 'http://www.teachertube.com/skin-p/mediaplayer.swf?file=http://www.teachertube.com/flvideo/$1.flv',
18 'match' => '#.*teachertube\.com/viewVideo\.php\?video_id=(\d+).*#',
19 'url' => 'http://www.teachertube.com/embed/player.swf?file=http://www.teachertube.com/embedFLV.php?pg=video_$1',
22 'match' => '#.*http://(www\.)?teachertube\.com/embed/player\.swf\?file=http://(www\.)?teachertube\.com/embedFLV.php\?pg=video_([0-9]+).*#',
23 'url' => 'http://www.teachertube.com/embed/player.swf?file=http://www.teachertube.com/embedFLV.php?pg=video_$3',
26 'match' => '#.*http://(www\.)?teachertube.com/skin-p/mediaplayer\.swf\?file=http://www.teachertube.com/flvideo/([0-9]+)\.flv.*#',
27 'url' => 'http://www.teachertube.com/skin-p/mediaplayer.swf?file=http://www.teachertube.com/flvideo/$2.flv',
31 public function process_url($input, $width=0, $height=0) {
32 $width = $width ? (int)$width : self::$default_width;
33 $height = $height ? (int)$height : self::$default_height;
35 foreach (self::$embed_sources as $source) {
36 if (preg_match($source['match'], $input)) {
37 $output = preg_replace($source['match'], $source['url'], $input);
50 public function validate_url($input) {
51 foreach (self::$embed_sources as $source) {
52 if (preg_match($source['match'], $input)) {
59 public function get_base_url() {
60 return self::$base_url;