Commit e61a1153 authored by dionoea's avatar dionoea

* luaplaylist.c: add support for meta data info. Playlist items now use .path...

* luaplaylist.c: add support for meta data info. Playlist items now use .path and .name (instead of .url and .title as those are used for meta data).
* luaplaylist/dailymotion.lua: add support for "description" and "arturl" meta data items.
* luaplaylist/*lua: update source to make it work with new playlist conventions.
* luaplaylist/youtube.lua: update help instructions.
parent 23804bd3
......@@ -382,16 +382,16 @@ static int Demux( demux_t *p_demux )
{
const char *psz_url = NULL;
const char *psz_title = NULL;
lua_getfield( p_state, t+2, "url" );
lua_getfield( p_state, t+2, "path" );
if( lua_isstring( p_state, t+3 ) )
{
psz_url = lua_tostring( p_state, t+3 );
printf("URL: %s\n", psz_url );
lua_getfield( p_state, t+2, "title" );
printf("Path: %s\n", psz_url );
lua_getfield( p_state, t+2, "name" );
if( lua_isstring( p_state, t+4 ) )
{
psz_title = lua_tostring( p_state, t+4 );
printf("Title: %s\n", psz_title );
printf("Name: %s\n", psz_title );
}
else
{
......@@ -399,18 +399,47 @@ static int Demux( demux_t *p_demux )
}
p_input = input_ItemNewExt( p_playlist, psz_url,
psz_title, 0, NULL, -1 );
p_input->p_meta = vlc_meta_New();
#define TRY_META( a, b ) \
lua_getfield( p_state, t+2, a ); \
if( lua_isstring( p_state, t+5 ) ) \
{ \
psz_title = lua_tostring( p_state, t+5 ); \
printf( #b ": %s\n", psz_title ); \
vlc_meta_Set ## b ( p_input->p_meta, psz_title ); \
} \
lua_pop( p_state, 1 ); /* pop a */
TRY_META( "title", Title );
TRY_META( "artist", Artist );
TRY_META( "genre", Genre );
TRY_META( "copyright", Copyright );
TRY_META( "album", Album );
TRY_META( "tracknum", Tracknum );
TRY_META( "description", Description );
TRY_META( "rating", Rating );
TRY_META( "date", Date );
TRY_META( "setting", Setting );
TRY_META( "url", URL );
TRY_META( "language", Language );
TRY_META( "nowplaying", NowPlaying );
TRY_META( "publisher", Publisher );
TRY_META( "encodedby", EncodedBy );
TRY_META( "arturl", ArtURL );
TRY_META( "trackid", TrackID );
playlist_BothAddInput(
p_playlist, p_input,
p_item_in_category,
PLAYLIST_APPEND | PLAYLIST_SPREPARSE,
PLAYLIST_END, NULL, NULL, VLC_FALSE );
lua_pop( p_state, 1 ); /* pop "title" */
lua_pop( p_state, 1 ); /* pop "name" */
}
else
{
printf("URL isn't a string\n");
printf("Path isn't a string\n");
}
lua_pop( p_state, 1 ); /* pop "url" */
lua_pop( p_state, 1 ); /* pop "path" */
}
else
{
......
......@@ -15,13 +15,22 @@ function parse()
if not line then break end
if string.match( line, "param name=\"flashvars\" value=\"url=" )
then
url = vlc.decode_uri( string.gsub( line, "^.*param name=\"flashvars\" value=\"url=([^&]*).*$", "%1" ) )
path = vlc.decode_uri( string.gsub( line, "^.*param name=\"flashvars\" value=\"url=([^&]*).*$", "%1" ) )
end
if string.match( line, "<title>" )
--[[ if string.match( line, "<title>" )
then
title = vlc.decode_uri( string.gsub( line, "^.*<title>([^<]*).*$", "%1" ) )
end ]]
if string.match( line, "<meta name=\"description\"" )
then
name = vlc.resolve_xml_special_chars( string.gsub( line, "^.*name=\"description\" content=\"Regarder (.*) sur Dailymotion Partagez Vos Videos\..*$", "%1" ) )
description = vlc.resolve_xml_special_chars( string.gsub( line, "^.*name=\"description\" content=\"Regarder .* sur Dailymotion Partagez Vos Videos\. ([^\"]*)\".*$", "%1" ) )
end
if string.match( line, "<link rel=\"thumbnail\"" )
then
arturl = string.gsub( line, "^.*\"thumbnail\" type=\"([^\"]*)\".*$", "http://%1" ) -- looks like the dailymotion people mixed up type and href here ...
end
if url and title then break end
if path and name and description and arturl then break end
end
return { { url = url; title = title } }
return { { path = path; name = name; description = description; url = vlc.path; arturl = arturl } }
end
......@@ -9,5 +9,5 @@ end
-- Parse function.
function parse()
return { { url = string.gsub( vlc.path, "^.*(docid=[^&]*).*$", "http://video.google.com/videogvp?%1" ) } }
return { { path = string.gsub( vlc.path, "^.*(docid=[^&]*).*$", "http://video.google.com/videogvp?%1" ) } }
end
......@@ -17,12 +17,12 @@ function parse()
line = vlc.readline()
if not line then break end
if string.match( line, "<meta name=\"title\"" ) then
title = string.gsub( line, "^.*content=\"([^\"]*).*$", "%1" )
name = string.gsub( line, "^.*content=\"([^\"]*).*$", "%1" )
break
end
end
return { { url = string.gsub( vlc.path, "^.*watch/(.*[^/])/?$", "http://www.metacafe.com/fplayer/%1.swf" ); title = title } }
return { { path = string.gsub( vlc.path, "^.*watch/(.*[^/])/?$", "http://www.metacafe.com/fplayer/%1.swf" ); name = name } }
else -- This is the flash player's URL
return { { url = string.gsub( vlc.path, "^.*mediaURL=([^&]*).*$", "%1" ) } }
return { { path = string.gsub( vlc.path, "^.*mediaURL=([^&]*).*$", "%1" ) } }
end
end
......@@ -6,14 +6,33 @@ VLC Lua playlist modules should define two functions:
* parse(): read the incoming data and return playlist item(s)
The playlist is a table of playlist objects.
A playlist object has the following members:
.url: the item's full URL
.title: the item's title (OPTIONAL)
.path: the item's full path / URL
.name: the item's name in playlist (OPTIONAL)
.title: the item's Title (OPTIONAL, meta data)
.artist: the item's Artist (OPTIONAL, meta data)
.genre: the item's Genre (OPTIONAL, meta data)
.copyright: the item's Copyright (OPTIONAL, meta data)
.album: the item's Album (OPTIONAL, meta data)
.tracknum: the item's Tracknum (OPTIONAL, meta data)
.description: the item's Description (OPTIONAL, meta data)
.rating: the item's Rating (OPTIONAL, meta data)
.date: the item's Date (OPTIONAL, meta data)
.setting: the item's Setting (OPTIONAL, meta data)
.url: the item's URL (OPTIONAL, meta data)
.language: the item's Language (OPTIONAL, meta data)
.nowplaying: the item's NowPlaying (OPTIONAL, meta data)
.publisher: the item's Publisher (OPTIONAL, meta data)
.encodedby: the item's EncodedBy (OPTIONAL, meta data)
.arturl: the item's ArtURL (OPTIONAL, meta data)
.trackid: the item's TrackID (OPTIONAL, meta data)
Invalid playlist items will be discarded by VLC.
VLC defines a global vlc object with the following members:
* vlc.path: the URL string (without the leading http:// or file:// element)
* vlc.access: the access used ("http" for http://, "file" for file://, etc.)
* vlc.peek( <int> ): return the first <int> characters from the playlist file.
* vlc.read( <int> ): read <int> characters from the playlist file.
THIS FUNCTION SHOULD NOT BE USED IN peek().
* vlc.readline(): return a new line of playlist data on each call.
THIS FUNCTION SHOULD NOT BE USED IN peek().
* vlc.decode_uri( <string> ): decode %xy characters in a string.
......@@ -46,20 +65,20 @@ function parse()
local p = {}
if string.match( vlc.path, "watch%?v=" )
then -- This is the HTML page's URL
p[1] = { url = string.gsub( vlc.path, "^(.*)watch%?v=([^&]*).*$", "http://%1v/%2" ) }
p[1] = { path = string.gsub( vlc.path, "^(.*)watch%?v=([^&]*).*$", "http://%1v/%2" ) }
while true do
-- Try to find the video's title
line = vlc.readline()
if not line then break end
if string.match( line, "<meta name=\"title\"" ) then
p[1].title = string.gsub( line, "^.*content=\"([^\"]*).*$", "%1" )
p[1].name = string.gsub( line, "^.*content=\"([^\"]*).*$", "%1" )
break
end
end
else -- This is the flash player's URL
p[1] = { url = "http://www.youtube.com/get_video.php?video_id="..get_url_param( vlc.path, "video_id" ).."&t="..get_url_param( vlc.patch, "t" ) }
p[1] = { path = "http://www.youtube.com/get_video.php?video_id="..get_url_param( vlc.path, "video_id" ).."&t="..get_url_param( vlc.patch, "t" ) }
if string.match( vlc.path, "title=" ) then
p[1].title = get_url_param( vlc.path, "title" )
p[1].name = get_url_param( vlc.path, "title" )
end
end
return p
......
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