Commit 71eeebf7 authored by dionoea's avatar dionoea

* luaplaylist.c: Change demux2 capability from 0 to 9

* ps.c: Change demux2 capability from 9 to 8
* ty.c: Change demux2 capability from 8 to 6
* playlist/{Modules.am,playlist.c,videoportals.c}: remove video portals C version
parent 906a3f2f
......@@ -14,7 +14,6 @@ SOURCES_playlist = \
qtl.c \
gvp.c \
ifo.c \
videoportals.c \
$(NULL)
SOURCES_luaplaylist = luaplaylist.c
......@@ -60,7 +60,7 @@ vlc_module_begin();
set_shortname( _("Lua Playlist") );
set_description( _("Lua Playlist Parser Interface") );
set_capability( "demux2", 0 );
set_capability( "demux2", 9 );
set_callbacks( E_(Import_LuaPlaylist), E_(Close_LuaPlaylist) );
vlc_module_end();
......
......@@ -116,11 +116,13 @@ vlc_module_begin();
set_description( _("Dummy ifo demux") );
set_capability( "demux2", 12 );
set_callbacks( E_(Import_IFO), E_(Close_IFO) );
#if 0
add_submodule();
set_description( _("Video portal url converter") );
add_shortcut( "videoportal" );
set_capability( "demux2", 10 );
set_callbacks( E_(Import_VideoPortal), E_(Close_VideoPortal) );
#endif
vlc_module_end();
......
/*****************************************************************************
* videoportals.c: Convert video webportal HTML urls to the appropriate video
* stream url.
*****************************************************************************
* Copyright (C) 2007 the VideoLAN team
* $Id$
*
* Authors: Antoine Cellerier <dionoea @t videolan d.t org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <vlc/vlc.h>
#include <vlc_demux.h>
#include <vlc_url.h>
#include <vlc_strings.h>
#include <errno.h> /* ENOMEM */
#include "playlist.h"
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static int Demux( demux_t *p_demux);
static int Control( demux_t *p_demux, int i_query, va_list args );
struct demux_sys_t
{
char *psz_url;
char *psz_title;
};
char *get_html_meta_title( demux_t *p_demux );
char *get_html_meta_title( demux_t *p_demux )
{
char *psz_title;
char *psz_cur;
char *psz_line;
/* Retreive the stream's title from the HTML */
while( ( psz_line = stream_ReadLine( p_demux->s ) ) )
{
if( ( psz_cur = strstr( psz_line,
"<meta name=\"title\" content=\"" ) ) )
{
char *psz_buf;
psz_cur += strlen( "<meta name=\"title\" content=\"" );
psz_buf = strchr( psz_cur, '"' );
if( psz_buf ) *psz_buf = '\0';
psz_title = strdup( psz_cur );
resolve_xml_special_chars( psz_title );
if( psz_buf ) *psz_buf = '"';
return psz_title;
}
}
return NULL;
}
/*****************************************************************************
* Import_VideoPortal: main import function
*****************************************************************************/
int E_(Import_VideoPortal)( vlc_object_t *p_this )
{
demux_t *p_demux = (demux_t *)p_this;
const char *psz_path = p_demux->psz_path;
char *psz_cur;
char *psz_url = NULL;
char *psz_title = NULL;
byte_t *p_peek;
int i_peek;
/* YouTube */
if( ( psz_cur = strstr( psz_path, "youtube.com" ) ) )
{
psz_cur += strlen( "youtube.com" );
psz_cur = strchr( psz_cur, '/' );
if( psz_cur )
{
psz_cur++;
if( !strncmp( psz_cur, "watch?v=", strlen( "watch?v=" ) ) )
{
/* This is the webpage's url */
char *psz_id;
psz_cur += strlen( "watch?v=" );
psz_id = psz_cur;
psz_cur = strchr( psz_cur, '&' );
if( psz_cur ) *psz_cur = '\0';
psz_title = get_html_meta_title( p_demux );
asprintf( &psz_url, "http://www.youtube.com/v/%s", psz_id );
}
else if( !strncmp( psz_cur, "watch_fullscreen?video_id=",
strlen( "watch_fullscreen?video_id=" ) )
|| !strncmp( psz_cur, "p.swf", strlen( "p.swf" ) ) /* Normal size */
|| !strncmp( psz_cur, "player2.swf", strlen( "player2.swf" ) )/* Fullscreen urls */ )
{
/* This is the swf flv player url (which we get after a
* redirect from the http://www.youtube.com/v/video_id url),
* or the fullscreen swf flv player url,
* or the fullscreen webpage url */
char *video_id = strstr( psz_cur, "video_id=" );
char *t = strstr( psz_cur, "t=" );
char *title = strstr( psz_cur, "title=" );
if( video_id && t )
{
char *psz_buf;
video_id += strlen( "video_id=" );
t += strlen( "t=" );
psz_buf = strchr( video_id, '&' );
if( psz_buf ) *psz_buf = '\0';
psz_buf = strchr( t, '&' );
if( psz_buf ) *psz_buf = '\0';
asprintf( &psz_url, "http://www.youtube.com/"
"get_video.php?video_id=%s&t=%s",
video_id, t );
if( title ) /* Comes with fullscreen urls */
{
title += strlen( "title=" );
psz_buf = strchr( title, '&' );
if( psz_buf ) *psz_buf = '\0';
psz_title = strdup( title );
decode_URI( psz_title );
}
}
}
}
}
/* 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 = '&';
}
if( ( psz_cur = strstr( psz_line, "<title>" ) ) )
{
char *psz_tmp;
psz_cur += strlen( "<title>" );
psz_tmp = strchr( psz_cur, '<' );
*psz_tmp = 0;
psz_title = strdup( psz_cur );
decode_URI( psz_title );
*psz_tmp = '<';
}
if( psz_url && psz_title ) break;
}
}
}
/* Google video */
else if( ( psz_cur = strstr( psz_path, "video.google.com" ) )
&& strstr( psz_cur, "videoplay" ) )
{
char *docid = strstr( psz_cur, "docid=" );
if( docid )
{
docid += strlen( "docid=" );
/* This doesn't always work ... */
asprintf( &psz_url,
"http://video.google.com/videogvp?docid=%s",
docid );
}
}
/* metacafe */
else if( ( psz_cur = strstr( psz_path, "metacafe.com" ) ) )
{
if( strstr( psz_cur, "watch/" ) )
{
psz_cur = strstr( psz_cur, "watch/" );
psz_cur += strlen( "watch/" );
if( psz_cur[strlen(psz_cur)-1] == '/' )
psz_cur[strlen(psz_cur)-1] = '\0';
asprintf( &psz_url, "http://www.metacafe.com/fplayer/%s.swf",
psz_cur );
psz_title = get_html_meta_title( p_demux );
}
else if( ( psz_cur = strstr( psz_path, "images.metacafe.com" ) ) )
{
if( ( psz_cur = strstr( psz_cur, "mediaURL=" ) ) )
{
char *psz_tmp;
psz_cur += strlen( "mediaURL=" );
psz_tmp = strchr( psz_cur, '&' );
*psz_tmp = 0;
psz_url = strdup( psz_cur );
*psz_tmp = '&';
}
}
}
if( !psz_url )
{
return VLC_EGENERIC;
}
p_demux->p_sys = (demux_sys_t*)malloc( sizeof( demux_sys_t ) );
if( !p_demux->p_sys )
{
free( psz_url );
free( psz_title );
return VLC_ENOMEM;
}
p_demux->p_sys->psz_url = psz_url;
p_demux->p_sys->psz_title = psz_title;
p_demux->pf_control = Control;
p_demux->pf_demux = Demux;
return VLC_SUCCESS;
}
/*****************************************************************************
* Deactivate: frees unused data
*****************************************************************************/
void E_(Close_VideoPortal)( vlc_object_t *p_this )
{
demux_t *p_demux = (demux_t *)p_this;
free( p_demux->p_sys->psz_url );
free( p_demux->p_sys->psz_title );
free( p_demux->p_sys );
}
static int Demux( demux_t *p_demux )
{
char *psz_url = p_demux->p_sys->psz_url;
char *psz_title = p_demux->p_sys->psz_title;
input_item_t *p_input;
msg_Dbg( p_demux, "Redirecting %s to %s", p_demux->psz_path, psz_url );
INIT_PLAYLIST_STUFF;
if( !psz_title )
{
psz_title = p_current_input->psz_name;
}
p_input = input_ItemNewExt( p_playlist, psz_url, psz_title, 0, NULL, -1 );
playlist_BothAddInput( p_playlist, p_input,
p_item_in_category,
PLAYLIST_APPEND | PLAYLIST_SPREPARSE,
PLAYLIST_END, NULL, NULL, VLC_FALSE );
HANDLE_PLAY_AND_RELEASE;
return -1; /* Needed for correct operation of go back */
}
static int Control( demux_t *p_demux, int i_query, va_list args )
{
return VLC_EGENERIC;
}
......@@ -61,7 +61,7 @@ vlc_module_begin();
add_submodule();
set_description( _("MPEG-PS demuxer") );
set_capability( "demux2", 9 );
set_capability( "demux2", 8 );
set_callbacks( Open, Close );
vlc_module_end();
......
......@@ -70,7 +70,7 @@ vlc_module_begin();
set_description(_("TY Stream audio/video demux"));
set_category( CAT_INPUT );
set_subcategory( SUBCAT_INPUT_DEMUX );
set_capability("demux2", 8);
set_capability("demux2", 6);
/* FIXME: there seems to be a segfault when using PVR access
* and TY demux has a bigger priority than PS
* Something must be wrong.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment