sunnyman's (sunnyman) wrote in changelog,
sunnyman's
sunnyman
changelog

[livejournal] r19269: OPSC-8992: get_video_ids parameter added...

Committer: vtroitsky
OPSC-8992: get_video_ids parameter added in getevents & getfriendspage LJ XMLRPC functions to enrich <lj-embed> tags being returned with video id and source attributes for selected video hosters.
U   trunk/cgi-bin/LJ/EmbedModule.pm
U   trunk/cgi-bin/ljprotocol.pl
Modified: trunk/cgi-bin/LJ/EmbedModule.pm
===================================================================
--- trunk/cgi-bin/LJ/EmbedModule.pm	2011-06-09 07:36:52 UTC (rev 19268)
+++ trunk/cgi-bin/LJ/EmbedModule.pm	2011-06-09 07:44:53 UTC (rev 19269)
@@ -125,16 +125,26 @@
                 (" target=\"" . $opts{expand_to_link}->{target} . "\"") : ''
             ) .
             ">" . $opts{expand_to_link}->{caption} . "</a>";
-    } elsif ($opts{get_youtube_id}) {
+    } elsif ($opts{get_video_id}) {
         my $code = $class->module_content(moduleid  => $attrs{id}, journalid => $journal->id);        
 
         my $out=  '<lj-embed id="'. $attrs{id} .'" ';
 
+        # LJSUP-8992
         if ($code =~ m!src=["']?http://www\.youtube\.com/embed/([\w\d\_\-]+)['"]?!) {
-            $out .= 'vid="'.$1.'" ';
+            $out .= 'vid="'.$1.'" source="youtube" ';
+        } elsif ($code =~ m!src=["']?http://player\.vimeo\.com/video/(\d+)[?'"]?! || 
+                 $code =~ m!=["']?http://vimeo\.com/moogaloop\.swf\?[\d\w\_\-\&\;\=]*clip_id=(\d+)[&'"]?! ) {
+            $out .= 'vid="'.$1.'" source="vimeo" ';
+        } elsif ($code =~ m!=["']?http://video\.rutube\.ru/([\dabcdef]+)['"]?!) {
+            $out .= 'vid="'.$1.'" source="rutube" ';
+        } elsif ($code =~ m!=["']?http://static\.video\.yandex\.ru/([\d\w\/\-\_\.]+)['"]?!) {
+            $out .= 'vid="'.$1.'" source="yandex" '; 
+        } elsif ($code =~ m!http://img\.mail\.ru.+value=["']?movieSrc=([\w\d\/\_\-\.]+)["']?!) {
+            $out .= 'vid="'.$1.'" source="mail.ru" ';
         }
 
-        $out .= ' />';
+        $out .= '/>';
 
         return $out;
         

Modified: trunk/cgi-bin/ljprotocol.pl
===================================================================
--- trunk/cgi-bin/ljprotocol.pl	2011-06-09 07:36:52 UTC (rev 19268)
+++ trunk/cgi-bin/ljprotocol.pl	2011-06-09 07:44:53 UTC (rev 19269)
@@ -15,6 +15,7 @@
                       LJ::Config
                       LJ::Comment
                       LJ::RateLimit
+                      LJ::EmbedModule
                       );
 
 use LJ::TimeUtil;
@@ -446,6 +447,10 @@
         };
 
         $item_data->{body} = $item->{body} if($item->{body} && $item->{_loaded});
+
+        # add parameters to lj-embed
+        #LJ::EmbedModule->expand_entry($item->{upost}, \$item_data->{body}, get_video_id => 1) if($item->{upost} && $req->{get_video_ids});
+
         $item_data->{subject} = $item->{subject} if($item->{subject} && $item->{_loaded});
    
         if($item->{upost} && $item->{upost}->identity ){
@@ -717,6 +722,9 @@
             read_more => '<a href="' . $comment->url . '"> ...</a>',
         ) if $req->{trim_widgets};
 
+        # add parameters to lj-tags
+        #LJ::EmbedModule->expand_entry($users->{$comment->{posterid}}, \$comment->{text}, get_video_id => 1) if($req->{get_video_ids});
+
         $comment->{text} = LJ::convert_lj_tags_to_links(
             event => $comment->{text},
             embed_url => $comment->url,
@@ -820,6 +828,8 @@
             read_more => '<a href="' . $entry->url . '"> ...</a>',
         ) if $req->{trim_widgets};
 
+        LJ::EmbedModule->expand_entry($entry->poster, \$h{event_raw}, get_video_id => 1) if $req->{get_video_ids};
+
         $h{event_raw} = LJ::convert_lj_tags_to_links(
             event => $h{event_raw},
             embed_url => $entry->url,
@@ -3103,6 +3113,8 @@
             read_more => '<a href="' . $evt->{url} . '"> ...</a>',
         ) if $req->{trim_widgets};
 
+        LJ::EmbedModule->expand_entry($uowner, \$t->[1], get_video_id => 1) if($req->{get_video_ids});
+
         $t->[1] = LJ::convert_lj_tags_to_links(
             event => $t->[1],
             embed_url => $evt->{url},

Tags: livejournal, pl, pm, sunnyman
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments