/[drupal]/contributions/modules/emfield/contrib/video_cck/providers/myspace.inc
ViewVC logotype

Contents of /contributions/modules/emfield/contrib/video_cck/providers/myspace.inc

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


Revision 1.6 - (show annotations) (download) (as text)
Mon May 12 04:10:54 2008 UTC (18 months, 2 weeks ago) by alexua
Branch: MAIN
CVS Tags: DRUPAL-5--1-3, HEAD
Changes since 1.5: +8 -8 lines
File MIME type: text/x-php
Corrected all errors registered by Coder module in preperation for D6 port
1 <?php
2 // $Id: myspace.inc,v 1.5 2008/02/22 18:46:26 aaron Exp $
3
4 define('VIDEO_CCK_MYSPACE_MAIN_URL', 'http://vids.myspace.com/index.cfm?fuseaction=vids.videos');
5
6 function video_cck_myspace_info() {
7 $name = t('MySpace');
8 $features = array(
9 array(t('Autoplay'), t('No'), ''),
10 array(t('RSS Attachment'), t('No'), ''),
11 array(t('Thumbnails'), t('Yes'), ''),
12 );
13 return array(
14 'provider' => 'myspace',
15 'name' => $name,
16 'url' => VIDEO_CCK_MYSPACE_MAIN_URL,
17 'settings_description' => t('These settings specifically affect videos displayed from !provider.', array('!provider' => l($name, VIDEO_CCK_MYSPACE_MAIN_URL, array('target' => '_blank')))),
18 'supported_features' => $features,
19 );
20 }
21
22 function video_cck_myspace_settings() {
23 $form = array();
24 return $form;
25 }
26
27 function video_cck_myspace_request($code, $cacheable = TRUE) {
28 $args = array();
29 return module_invoke('emfield', 'request_xml', 'myspace', "http://vids.myspace.com/index.cfm?fuseaction=vids.individual&videoid=$code", $args, $cacheable);
30 }
31
32 /**
33 * this scrapes the thumbnail from the video page and caches it
34 */
35 function _video_cck_myspace_scrape_thumbnail($video, $cached = true) {
36 if (!$cached || !$cache = cache_get('myspace:thumbnail:'. $video, 'cache')) {
37 $vidid = substr($video, 0, 10);
38 if ($str = file_get_contents("http://vids.myspace.com/index.cfm?fuseaction=vids.individual&videoid=$vidid")) {
39 // grab videos channel-id first
40 $channel_id = preg_replace('/.*tvchanid=([0-9]+);.*/si', '\1', $str);
41
42 if (is_numeric($channel_id)) {
43 // now from channel-page grab videos thumbnail
44 $str2 = file_get_contents("http://vids.myspace.com/index.cfm?fuseaction=vids.viewVideos&channelid=$channel_id");
45
46 if ($str2) {
47 $picturelink = preg_replace('@.*href="[^"]+'. $vidid .'"[^>]+><img[^>]+src="([^"]+)".*@si', '\1', $str2);
48
49 if ($picturelink) {
50 $thumbnail = $picturelink;
51 cache_set('myspace:thumbnail:'. $video, 'cache', $thumbnail, time() + 3600);
52 }
53 }
54 }
55 }
56 }
57 else {
58 $thumbnail = $cache->data;
59 }
60 return $thumbnail;
61 }
62
63 function video_cck_myspace_extract($embed) {
64 // <a href="http://myspacetv.com/index.cfm?fuseaction=vids.individual&videoid=14686340">What's That Floating In The Water Part 1</a><br><embed src="http://lads.myspace.com/videos/vplayer.swf" flashvars="m=14686340&v=2&type=video" type="application/x-shockwave-flash" width="430" height="346"></embed><br><a href="http://myspacetv.com/index.cfm?fuseaction=vids.addToProfileConfirm&videoid=14686340&title=What's That Floating In The Water Part 1">Add to My Profile</a> | <a href="http://myspacetv.com/index.cfm?fuseaction=vids.home">More Videos</a>
65 return array(
66 '@src="myspace\.com/index.cfm\?fuseaction=vids\.individual&videoid=([^&"]+)@i',
67 '@myspace\.com/index\.cfm\?fuseaction=vids\.individual&videoid=([^&"]+)@i',
68 '@src="myspacetv\.com/index.cfm\?fuseaction=vids\.individual&videoid=([^&"]+)"@i',
69 '@myspacetv\.com/index\.cfm\?fuseaction=vids\.individual&videoid=([^&"]+)@i',
70 );
71 }
72
73 function video_cck_myspace_video_link($video_code) {
74 return 'http://vids.myspace.com/index.cfm?fuseaction=vids.individual&videoid='. $video_code;
75 }
76
77 function theme_video_cck_myspace_flash($embed, $width, $height) {
78 static $count = 0;
79 if ($embed) {
80 $output .= " <object type=\"application/x-shockwave-flash\" height=\"$height\" width=\"$width\" data=\"http://lads.myspace.com/videos/vplayer.swf\" id=\"emfield-video-myspace-$count\" >
81 <param name=\"movie\" value=\"http://lads.myspace.com/videos/vplayer.swf\" />
82 <param name=\"allowScriptAcess\" value=\"sameDomain\"/>
83 <param name=\"quality\" value=\"best\"/>
84 <param name=\"bgcolor\" value=\"#FFFFFF\"/>
85 <param name=\"scale\" value=\"noScale\"/>
86 <param name=\"salign\" value=\"TL\"/>
87 <param name=\"FlashVars\" value=\"m=$embed&type=video\" />
88 <param name=\"wmode\" value=\"transparent\" />
89 </object>\n";
90 }
91 $count++;
92 return $output;
93 }
94
95 function video_cck_myspace_thumbnail($field, $item, $formatter, $node, $width, $height) {
96 return _video_cck_myspace_scrape_thumbnail($item['value']);
97 }
98
99 function video_cck_myspace_video($embed, $width, $height, $field, $item) {
100 $output = theme('video_cck_myspace_flash', $embed, $width, $height);
101 return $output;
102 }
103
104 function video_cck_myspace_preview($embed, $width, $height, $field, $item) {
105 $output = theme('video_cck_myspace_flash', $embed, $width, $height);
106 return $output;
107 }

  ViewVC Help
Powered by ViewVC 1.1.2