/[drupal]/contributions/modules/video_filter/video_filter.codecs.inc
ViewVC logotype

Contents of /contributions/modules/video_filter/video_filter.codecs.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.6 - (show annotations) (download) (as text)
Thu Oct 22 21:01:10 2009 UTC (4 weeks, 6 days ago) by blackdog
Branch: MAIN
CVS Tags: HEAD
Changes since 1.5: +12 -3 lines
File MIME type: text/x-php
[#611312] by blackdog - new gametrailers regexp. Reported by superfedya.
1 <?php
2 // $Id: video_filter.codecs.inc,v 1.5 2009/09/20 15:30:31 blackdog Exp $
3
4 /**
5 * @file
6 * This file contains all codecs provided by Video Filter.
7 */
8
9 function video_filter_codec_info() {
10 $codecs = array();
11
12 $codecs['youtube'] = array(
13 'name' => t('YouTube'),
14 'callback' => 'video_filter_youtube',
15 'regexp' => '/youtube\.com\/watch\?v=([a-z0-9\-_]+)/i',
16 'ratio' => 425 / 355,
17 );
18 $codecs['google'] = array(
19 'name' => t('Google Video'),
20 'callback' => 'video_filter_google',
21 'regexp' => '/video\.google\.[a-z]+\/videoplay\?docid=(\-?[0-9]+)/',
22 'ratio' => 400 / 326,
23 );
24 $codecs['tangle'] = array(
25 'name' => t('Tangle'),
26 'callback' => 'video_filter_tangle',
27 'regexp' => array(
28 '/tangle\.com\/view_video\.php\?viewkey=([a-z0-9]+)/',
29 '/tangle\.com\/view_video\?viewkey=([a-z0-9]+)/',
30 ),
31 'ratio' => 330 / 270,
32 );
33 $codecs['dailymotion'] = array(
34 'name' => t('DailyMotion'),
35 'callback' => 'video_filter_dailymotion',
36 'regexp' => '/dailymotion\.com\/.*video\/([a-z0-9]+)/i',
37 'ratio' => 420 / 336,
38 );
39 $codecs['eyespot'] = array(
40 'name' => t('Eyespot'),
41 'callback' => 'video_filter_eyespot',
42 'regexp' => '/eyespot\.com\/.*r=([a-z0-9]+)/i',
43 'ratio' => 432 / 407,
44 );
45 $codecs['revver'] = array(
46 'name' => t('Revver'),
47 'callback' => 'video_filter_revver',
48 'regexp' => '/revver\.com\/video\/([0-9]+)/',
49 'ratio' => 408 / 324,
50 );
51 $codecs['vimeo'] = array(
52 'name' => t('Vimeo'),
53 'callback' => 'video_filter_vimeo',
54 'regexp' => '/vimeo\.com\/([0-9]+)/',
55 'ratio' => 400 / 225,
56 );
57 $codecs['flickr_slideshows'] = array(
58 'name' => t('Flickr Slideshows'),
59 'callback' => 'video_filter_flickr_slideshows',
60 'regexp' => '/flickr\.com\/photos\/([a-zA-Z0-9@_\-]+)\/sets\/([0-9]+)\/?[show]?\/?/i',
61 'ratio' => 400 / 300,
62 );
63 $codecs['flickr_video'] = array(
64 'name' => t('Flickr Video'),
65 'callback' => 'video_filter_flickr_video',
66 'regexp' => '/flickr\.com\/photos\/([a-zA-Z0-9@_\-]+)\/([0-9]+)/',
67 'ratio' => 400 / 226,
68 );
69 $codecs['gamevideos'] = array(
70 'name' => t('Game Videos'),
71 'callback' => 'video_filter_gamevideos',
72 'regexp' => '/gamevideos\.1up\.com\/video\/id\/([0-9]+)/',
73 'ratio' => 500 / 319,
74 );
75 $codecs['metacafe'] = array(
76 'name' => t('Meta Cafe'),
77 'callback' => 'video_filter_metacafe',
78 'regexp' => '/metacafe\.com\/watch\/([a-z0-9\-_]+)\/([a-z0-9\-_]+)/i',
79 'ratio' => 400 / 345,
80 );
81 $codecs['gametrailers'] = array(
82 'name' => t('Game Trailers'),
83 'callback' => 'video_filter_gametrailers',
84 'regexp' => array(
85 '/gametrailers\.com\/player\/([0-9]+)/',
86 '/gametrailers\.com\/video\/([a-z0-9\-_]+)\/([0-9]+)/',
87 ),
88 'ratio' => 480 / 392,
89 );
90 $codecs['collegehumor'] = array(
91 'name' => t('College Humor'),
92 'callback' => 'video_filter_collegehumor',
93 'regexp' => '/collegehumor\.com\/video\:([0-9]+)/',
94 'ratio' => 480 / 360,
95 );
96 $codecs['myspace'] = array(
97 'name' => t('MySpace'),
98 'callback' => 'video_filter_myspace',
99 'regexp' => '/vids\.myspace\.com\/.*VideoID=([0-9]+)/i',
100 'ratio' => 425 / 360,
101 );
102 $codecs['capped'] = array(
103 'name' => t('Capped'),
104 'callback' => 'video_filter_capped',
105 'regexp' => '/capped\.tv\/([a-zA-Z0-9\-_]+)/',
106 'ratio' => 425 / 355,
107 );
108 $codecs['bliptv'] = array(
109 'name' => t('Blip.tv'),
110 'callback' => 'video_filter_bliptv',
111 'regexp' => array(
112 '@blip\.tv/rss/flash/([^"\&\?/]+)@i',
113 '@blip\.tv/file/view/([^"\&\?/]+)@i',
114 '@blip\.tv/file/([^"\&\?/]+)@i',
115 '@blip\.tv/play/([^"\&\?/]+)@i',
116 ),
117 'ratio' => 480 / 335,
118 );
119 $codecs['slideshare'] = array(
120 'name' => t('Slideshare'),
121 'callback' => 'video_filter_slideshare',
122 'instructions' => t('You need to construct your own URL, using the "Wordpress Embed" code from Slideshare, extract the "id" and "doc" parts, and form the URL like this: slideshare.net/?id=1759622&amp;doc=usingdrupal-090723103440-phpapp01.'),
123 'regexp' => '/slideshare\.net\/\?id=([a-z0-9]+).*doc=([a-z0-9-]+)/',
124 'ratio' => 500 / 410,
125 );
126 $codecs['picasa_slideshows'] = array(
127 'name' => t('Picasa Slideshows'),
128 'callback' => 'video_filter_picasa_slideshows',
129 'instructions' => t('You must use the URL of the RSS feed for the Picasa album:') .
130 '<ol>' .
131 '<li>' . t('View the album in Picasa (you should see thumbnails, not a slideshow).') . '</li>' .
132 '<li>' . t('Find the "RSS" link and click it.') . '</li>' .
133 '<li>' . t('Copy the resulting URL from the browser address bar. Example:') . '<br />' .
134 '<code>[video: http://picasaweb.google.com/data/feed/base/user/USER_NAME/albumid/5568104935784209834?alt=rss&kind=photo&hl=en_US]</code>' .
135 '</li>' .
136 '</ol>',
137 'regexp' => '/picasaweb\.google\.com\/data\/feed\/base\/user\/([a-zA-Z0-9@_\-]+)\/albumid\/([a-z0-9]+)/i',
138 'ratio' => 800 / 600,
139 );
140
141 return $codecs;
142 }
143
144 function video_filter_youtube($video) {
145 $video['source'] = 'http://www.youtube.com/v/' . $video['codec']['matches'][1] . ($video['autoplay'] ? '&amp;autoplay=1' : '') . '&amp;fs=1' . ($video['related'] ? '' : '&amp;rel=0');
146
147 return video_filter_flash($video);
148 }
149
150 function video_filter_google($video) {
151 $video['source'] = 'http://video.google.com/googleplayer.swf?docId=' . $video['codec']['matches'][1];
152
153 return video_filter_flash($video);
154 }
155
156 function video_filter_tangle($video) {
157 $video['source'] = 'http://www.tangle.com/flash/swf/flvplayer.swf?viewkey=' . $video['codec']['matches'][1];
158
159 return video_filter_flash($video);
160 }
161
162 function video_filter_dailymotion($video) {
163 $video['source'] = 'http://www.dailymotion.com/swf/' . $video['codec']['matches'][1];
164
165 return video_filter_flash($video);
166 }
167
168 function video_filter_eyespot($video) {
169 $video['source'] = 'http://eyespot.com/flash/medialoader.swf?vurl=http%3A%2F%2Fdownloads.eyespot.com%2Fplay%3Fr%3D' . $video['codec']['matches'][1] . '&amp;_autoPlay=' . ($video['autoplay'] ? 'true' : 'false');
170
171 return video_filter_flash($video);
172 }
173
174 function video_filter_revver($video) {
175 $output = '<script src="http://flash.revver.com/player/1.0/player.js?mediaId:' . $video['codec']['matches'][1] . ';width:' . $video['width'] . ';height:' . $video['height'] . ';" type="text/javascript"></script>';
176
177 return $output;
178 }
179
180 function video_filter_vimeo($video) {
181 $video['source'] = 'http://www.vimeo.com/moogaloop.swf?clip_id=' . $video['codec']['matches'][1] . '&amp;server=www.vimeo.com&amp;fullscreen=1&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;autoplay=' . $video['autoplay'];
182
183 return video_filter_flash($video);
184 }
185
186 function video_filter_flickr_slideshows($video) {
187 $slideshow_player_url = 'http://www.flickr.com/apps/slideshow/show.swf?v=67348';
188 $video['source'] = $slideshow_player_url . ($video['autoplay'] ? '&amp;autoplay=1' : '');
189
190 $user_name = $video['codec']['matches'][1];
191 $set_id = $video['codec']['matches'][2];
192
193 $params['flashvars'] = "&amp;offsite=true&amp;lang=en-us&amp;page_show_url=%2Fphotos%2F$user_name%2Fsets%2F$set_id%2Fshow%2F&amp;page_show_back_url=%2Fphotos%2F$user_name%2Fsets%2F$set_id%2F&amp;set_id=$set_id&amp;jump_to=";
194
195 return video_filter_flash($video, $params);
196 }
197
198 function video_filter_flickr_video($video) {
199 $video['source'] = 'http://www.flickr.com/apps/video/stewart.swf?v=1.161';
200
201 $params['flashvars'] = '&amp;photo_id=' . $video['codec']['matches'][2] . '&amp;flickr_show_info_box=true';
202
203 return video_filter_flash($video, $params);
204 }
205
206 function video_filter_gamevideos($video) {
207 $video['source'] = 'http://gamevideos.1up.com/swf/gamevideos12.swf?embedded=1&amp;fullscreen=1&amp;autoplay=0&amp;src=http://gamevideos.1up.com/do/videoListXML%3Fid%3D' . $video['codec']['matches'][1];
208
209 return video_filter_flash($video);
210 }
211
212 function video_filter_metacafe($video) {
213 $video['source'] = 'http://metacafe.com/fplayer/' . $video['codec']['matches'][1] . '/' . $video['codec']['matches'][2] . '.swf';
214
215 return video_filter_flash($video);
216 }
217
218 function video_filter_gametrailers($video) {
219 if (is_numeric($video['codec']['matches'][1])) {
220 $match = $video['codec']['matches'][1];
221 }
222 elseif (is_numeric($video['codec']['matches'][2])) {
223 $match = $video['codec']['matches'][2];
224 }
225 $video['source'] = 'http://www.gametrailers.com/remote_wrap.php?mid='.$match;
226
227 return video_filter_flash($video, $params);
228 }
229
230 function video_filter_collegehumor($video) {
231 $video['source'] = 'http://www.collegehumor.com/moogaloop/moogaloop.swf?clip_id=' . $video['codec']['matches'][1] . '&amp;fullscreen=1';
232
233 return video_filter_flash($video);
234 }
235
236 function video_filter_myspace($video) {
237 $video['source'] = 'http://mediaservices.myspace.com/services/media/embed.aspx/m=' . $video['codec']['matches'][1];
238
239 return video_filter_flash($video, $params);
240 }
241
242 function video_filter_capped($video) {
243 $video['source'] = 'http://capped.micksam7.com/playeralt.swf?vid=' . $video['codec']['matches'][1];
244
245 return video_filter_flash($video);
246 }
247
248 function video_filter_bliptv($video) {
249 $id = $video['codec']['matches'][1];
250
251 // Since video ID in URL is different than in embed code, use API
252 // to lookup the embed code video ID. Adapted from emfield.module.
253 $result = drupal_http_request('http://blip.tv/file/' . $id . '?skin=api');
254
255 if ($result->code == 200) {
256 $parser = drupal_xml_parser_create($result->data);
257 $vals = array();
258 $index = array();
259 xml_parse_into_struct($parser, $result->data, $vals, $index);
260 xml_parser_free($parser);
261
262 $response = array();
263 $response['_emfield_arghash'] = $arghash;
264 $level = array();
265 $start_level = 1;
266 foreach ($vals as $xml_elem) {
267 if ($xml_elem['type'] == 'open') {
268 if (array_key_exists('attributes', $xml_elem)) {
269 list($level[$xml_elem['level']], $extra) = array_values($xml_elem['attributes']);
270 }
271 else {
272 $level[$xml_elem['level']] = $xml_elem['tag'];
273 }
274 }
275 if ($xml_elem['type'] == 'complete') {
276 $php_stmt = '$response';
277 while ($start_level < $xml_elem['level']) {
278 $php_stmt .= '[$level[' . $start_level . ']]';
279 $start_level++;
280 }
281 $php_stmt .= '[$xml_elem[\'tag\']][] = $xml_elem[\'value\'];' . $php_stmt . '[$xml_elem[\'tag\']][] = $xml_elem[\'attributes\'];';
282 eval($php_stmt);
283 $start_level--;
284 }
285 }
286 $id = $response['EMBEDLOOKUP'][0];
287 }
288
289 $video['source'] = 'http://blip.tv/play/' . $id;
290 $params = array(
291 'allowscriptaccess' => 'always',
292 );
293
294 return video_filter_flash($video, $params);
295 }
296
297 function video_filter_slideshare($video) {
298 $video['source'] = 'http://static.slideshare.net/swf/ssplayer2.swf?id=' . $video['codec']['matches'][1] . '&amp;doc=' . ($video['codec']['matches'][2]);
299
300 return video_filter_flash($video);
301 }
302
303 function video_filter_picasa_slideshows($video) {
304 $video['source'] = 'http://picasaweb.google.com/s/c/bin/slideshow.swf';
305
306 $user_name = $video['codec']['matches'][1];
307 $set_id = $video['codec']['matches'][2];
308
309 $params['flashvars'] = "host=picasaweb.google.com&amp;&amp;feat=flashalbum&amp;RGB=0x000000&amp;feed=http%3A%2F%2Fpicasaweb.google.com%2Fdata%2Ffeed%2Fapi%2Fuser%2F" . $user_name . "%2Falbumid%2F" . $set_id . "%3Falt%3Drss%26kind%3Dphoto%26" . ($video['autoplay'] ? '' : '&amp;noautoplay=1');
310
311 return video_filter_flash($video, $params);
312 }

  ViewVC Help
Powered by ViewVC 1.1.2