]> git.sesse.net Git - vlc/commitdiff
videoportals.c: Add support for Daily Motion URLs (the webpage's url).
authorAntoine Cellerier <dionoea@videolan.org>
Fri, 11 May 2007 23:08:19 +0000 (23:08 +0000)
committerAntoine Cellerier <dionoea@videolan.org>
Fri, 11 May 2007 23:08:19 +0000 (23:08 +0000)
modules/demux/playlist/videoportals.c

index c1918fe9c30be0d426f9caac7a5e1ff2e92db321..0d18d5dd788e9b8564a81ca97ae76fbf78037af5 100644 (file)
@@ -27,6 +27,7 @@
  *****************************************************************************/
 #include <vlc/vlc.h>
 #include <vlc_demux.h>
+#include <vlc_url.h>
 
 #include <errno.h>                                                 /* ENOMEM */
 #include "playlist.h"
@@ -52,6 +53,9 @@ int E_(Import_VideoPortal)( vlc_object_t *p_this )
     char *psz_cur;
     char *psz_url = NULL;
 
+    byte_t *p_peek;
+    int i_peek;
+
     /* YouTube */
     if( ( psz_cur = strstr( psz_path, "youtube.com" ) ) )
     {
@@ -88,6 +92,31 @@ int E_(Import_VideoPortal)( vlc_object_t *p_this )
             }
         }
     }
+    /* Daily motion */
+    else if( ( psz_cur = strstr( psz_path, "dailymotion.com" ) ) )
+    {
+        i_peek = stream_Peek( p_demux->s, &p_peek, strlen( "<!DOCTYPE" ) );
+        if( !strncmp( (char*)p_peek, "<!DOCTYPE", strlen( "!<DOCTYPE" ) ) )
+        {
+            /* This looks like a (daily motion) webpage */
+            char *psz_line;
+            while( ( psz_line = stream_ReadLine( p_demux->s ) ) )
+            {
+                if( ( psz_cur = strstr( psz_line,
+                      "param name=\"flashvars\" value=\"url=" ) ) )
+                {
+                    char *psz_tmp;
+                    psz_cur += strlen( "param name=\"flashvars\" value=\"url=" );
+                    psz_tmp = strchr( psz_cur, '&' );
+                    *psz_tmp = 0;
+                    psz_url = strdup( psz_cur );
+                    decode_URI( psz_url );
+                    *psz_tmp = '&';
+                    break;
+                }
+            }
+        }
+    }
 
     if( !psz_url )
     {