Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
058b871e
Commit
058b871e
authored
May 13, 2014
by
Francois Cartegnie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finder/fetcher: always use scripts doing local access
parent
8301e1ea
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
103 additions
and
53 deletions
+103
-53
include/vlc_art_finder.h
include/vlc_art_finder.h
+8
-0
modules/lua/demux.c
modules/lua/demux.c
+2
-2
modules/lua/extension.c
modules/lua/extension.c
+2
-2
modules/lua/meta.c
modules/lua/meta.c
+55
-31
modules/lua/vlc.c
modules/lua/vlc.c
+1
-1
modules/lua/vlc.h
modules/lua/vlc.h
+14
-4
src/playlist/fetcher.c
src/playlist/fetcher.c
+19
-9
src/playlist/preparser.c
src/playlist/preparser.c
+2
-4
No files found.
include/vlc_art_finder.h
View file @
058b871e
...
...
@@ -21,10 +21,18 @@
#ifndef VLC_ART_FINDER_H
#define VLC_ART_FINDER_H 1
typedef
enum
meta_fetcher_scope_t
{
FETCHER_SCOPE_LOCAL
,
FETCHER_SCOPE_NETWORK
,
FETCHER_SCOPE_ANY
}
meta_fetcher_scope_t
;
typedef
struct
art_finder_t
{
VLC_COMMON_MEMBERS
input_item_t
*
p_item
;
meta_fetcher_scope_t
e_scope
;
}
art_finder_t
;
#endif
modules/lua/demux.c
View file @
058b871e
...
...
@@ -126,9 +126,9 @@ static const luaL_Reg p_reg_parse[] =
* the script pointed by psz_filename.
*****************************************************************************/
static
int
probe_luascript
(
vlc_object_t
*
p_this
,
const
char
*
psz_filename
,
void
*
user_data
)
const
luabatch_context_t
*
p_context
)
{
VLC_UNUSED
(
user_data
);
VLC_UNUSED
(
p_context
);
demux_t
*
p_demux
=
(
demux_t
*
)
p_this
;
p_demux
->
p_sys
->
psz_filename
=
strdup
(
psz_filename
);
...
...
modules/lua/extension.c
View file @
058b871e
...
...
@@ -67,7 +67,7 @@ static const char caps[][20] = {
static
int
ScanExtensions
(
extensions_manager_t
*
p_this
);
static
int
ScanLuaCallback
(
vlc_object_t
*
p_this
,
const
char
*
psz_script
,
void
*
dummy
);
const
struct
luabatch_context_t
*
);
static
int
Control
(
extensions_manager_t
*
,
int
,
va_list
);
static
int
GetMenuEntries
(
extensions_manager_t
*
p_mgr
,
extension_t
*
p_ext
,
char
***
pppsz_titles
,
uint16_t
**
ppi_ids
);
...
...
@@ -275,7 +275,7 @@ static int vlclua_extension_require( lua_State *L )
* @param dummy: unused
**/
int
ScanLuaCallback
(
vlc_object_t
*
p_this
,
const
char
*
psz_filename
,
void
*
dummy
)
const
struct
luabatch_context_t
*
dummy
)
{
VLC_UNUSED
(
dummy
);
extensions_manager_t
*
p_mgr
=
(
extensions_manager_t
*
)
p_this
;
...
...
modules/lua/meta.c
View file @
058b871e
...
...
@@ -89,7 +89,8 @@ static lua_State * init( vlc_object_t *p_this, input_item_t * p_item, const char
* Run a lua entry point function
*****************************************************************************/
static
int
run
(
vlc_object_t
*
p_this
,
const
char
*
psz_filename
,
lua_State
*
L
,
const
char
*
luafunction
)
lua_State
*
L
,
const
char
*
luafunction
,
const
luabatch_context_t
*
p_context
)
{
/* Ugly hack to delete previous versions of the fetchart()
* functions. */
...
...
@@ -104,6 +105,26 @@ static int run( vlc_object_t *p_this, const char * psz_filename,
goto
error
;
}
meta_fetcher_scope_t
e_scope
=
FETCHER_SCOPE_NETWORK
;
/* default to restricted one */
lua_getglobal
(
L
,
"descriptor"
);
if
(
lua_isfunction
(
L
,
lua_gettop
(
L
)
)
&&
!
lua_pcall
(
L
,
0
,
1
,
0
)
)
{
lua_getfield
(
L
,
-
1
,
"scope"
);
char
*
psz_scope
=
luaL_strdupornull
(
L
,
-
1
);
if
(
psz_scope
&&
!
strcmp
(
psz_scope
,
"local"
)
)
e_scope
=
FETCHER_SCOPE_LOCAL
;
free
(
psz_scope
);
lua_pop
(
L
,
1
);
}
lua_pop
(
L
,
1
);
if
(
p_context
&&
p_context
->
pf_validator
&&
!
p_context
->
pf_validator
(
p_context
,
e_scope
)
)
{
msg_Dbg
(
p_this
,
"skipping script (unmatched scope) %s"
,
psz_filename
);
goto
error
;
}
lua_getglobal
(
L
,
luafunction
);
if
(
!
lua_isfunction
(
L
,
lua_gettop
(
L
)
)
)
...
...
@@ -131,16 +152,22 @@ error:
* Called through lua_scripts_batch_execute to call 'fetch_art' on the script
* pointed by psz_filename.
*****************************************************************************/
static
int
fetch_art
(
vlc_object_t
*
p_this
,
const
char
*
psz_filename
,
void
*
user_data
)
static
bool
validate_scope
(
const
luabatch_context_t
*
p_context
,
meta_fetcher_scope_t
e_scope
)
{
input_item_t
*
p_item
=
user_data
;
if
(
p_context
->
e_scope
==
FETCHER_SCOPE_ANY
)
return
true
;
else
return
(
p_context
->
e_scope
==
e_scope
);
}
lua_State
*
L
=
init
(
p_this
,
p_item
,
psz_filename
);
static
int
fetch_art
(
vlc_object_t
*
p_this
,
const
char
*
psz_filename
,
const
luabatch_context_t
*
p_context
)
{
lua_State
*
L
=
init
(
p_this
,
p_context
->
p_item
,
psz_filename
);
if
(
!
L
)
return
VLC_EGENERIC
;
int
i_ret
=
run
(
p_this
,
psz_filename
,
L
,
"fetch_art"
);
int
i_ret
=
run
(
p_this
,
psz_filename
,
L
,
"fetch_art"
,
p_context
);
if
(
i_ret
!=
VLC_SUCCESS
)
{
lua_close
(
L
);
...
...
@@ -157,7 +184,7 @@ static int fetch_art( vlc_object_t *p_this, const char * psz_filename,
if
(
psz_value
&&
*
psz_value
!=
0
)
{
lua_Dbg
(
p_this
,
"setting arturl: %s"
,
psz_value
);
input_item_SetArtURL
(
p_item
,
psz_value
);
input_item_SetArtURL
(
p_
context
->
p_
item
,
psz_value
);
lua_close
(
L
);
return
VLC_SUCCESS
;
}
...
...
@@ -182,14 +209,17 @@ static int fetch_art( vlc_object_t *p_this, const char * psz_filename,
* pointed by psz_filename.
*****************************************************************************/
static
int
read_meta
(
vlc_object_t
*
p_this
,
const
char
*
psz_filename
,
void
*
user_data
)
const
luabatch_context_t
*
p_context
)
{
input_item_t
*
p_item
=
user_data
;
lua_State
*
L
=
init
(
p_this
,
p_item
,
psz_filename
);
/* FIXME: merge with finder */
demux_meta_t
*
p_demux_meta
=
(
demux_meta_t
*
)
p_this
;
VLC_UNUSED
(
p_context
);
lua_State
*
L
=
init
(
p_this
,
p_demux_meta
->
p_item
,
psz_filename
);
if
(
!
L
)
return
VLC_EGENERIC
;
int
i_ret
=
run
(
p_this
,
psz_filename
,
L
,
"read_meta"
);
int
i_ret
=
run
(
p_this
,
psz_filename
,
L
,
"read_meta"
,
NULL
);
lua_close
(
L
);
// Continue even if an error occurred: all "meta reader" are always run.
...
...
@@ -202,14 +232,13 @@ static int read_meta( vlc_object_t *p_this, const char * psz_filename,
* pointed by psz_filename.
*****************************************************************************/
static
int
fetch_meta
(
vlc_object_t
*
p_this
,
const
char
*
psz_filename
,
void
*
user_data
)
const
luabatch_context_t
*
p_context
)
{
input_item_t
*
p_item
=
user_data
;
lua_State
*
L
=
init
(
p_this
,
p_item
,
psz_filename
);
lua_State
*
L
=
init
(
p_this
,
p_context
->
p_item
,
psz_filename
);
if
(
!
L
)
return
VLC_EGENERIC
;
int
ret
=
run
(
p_this
,
psz_filename
,
L
,
"fetch_meta"
);
int
ret
=
run
(
p_this
,
psz_filename
,
L
,
"fetch_meta"
,
p_context
);
lua_close
(
L
);
return
ret
;
...
...
@@ -219,13 +248,10 @@ static int fetch_meta( vlc_object_t *p_this, const char * psz_filename,
* Read meta.
*****************************************************************************/
int
ReadMeta
(
vlc_object
_t
*
p_this
)
int
ReadMeta
(
demux_meta
_t
*
p_this
)
{
demux_meta_t
*
p_demux_meta
=
(
demux_meta_t
*
)
p_this
;
input_item_t
*
p_item
=
p_demux_meta
->
p_item
;
return
vlclua_scripts_batch_execute
(
p_this
,
"meta"
DIR_SEP
"reader"
,
&
read_meta
,
p_item
);
return
vlclua_scripts_batch_execute
(
VLC_OBJECT
(
p_this
),
"meta"
DIR_SEP
"reader"
,
(
void
*
)
&
read_meta
,
NULL
);
}
...
...
@@ -233,25 +259,23 @@ int ReadMeta( vlc_object_t *p_this )
* Read meta.
*****************************************************************************/
int
FetchMeta
(
vlc_object_t
*
p_this
)
int
FetchMeta
(
art_finder_t
*
p_finder
)
{
demux_meta_t
*
p_demux_meta
=
(
demux_meta_t
*
)
p_this
;
input_item_t
*
p_item
=
p_demux_meta
->
p_item
;
luabatch_context_t
context
=
{
p_finder
->
p_item
,
p_finder
->
e_scope
,
validate_scope
};
return
vlclua_scripts_batch_execute
(
p_this
,
"meta"
DIR_SEP
"fetcher"
,
&
fetch_meta
,
p_item
);
return
vlclua_scripts_batch_execute
(
VLC_OBJECT
(
p_finder
)
,
"meta"
DIR_SEP
"fetcher"
,
&
fetch_meta
,
(
void
*
)
&
context
);
}
/*****************************************************************************
* Module entry point for art.
*****************************************************************************/
int
FindArt
(
vlc_object_t
*
p_this
)
int
FindArt
(
art_finder_t
*
p_finder
)
{
art_finder_t
*
p_finder
=
(
art_finder_t
*
)
p_this
;
input_item_t
*
p_item
=
p_finder
->
p_item
;
luabatch_context_t
context
=
{
p_finder
->
p_item
,
p_finder
->
e_scope
,
validate_scope
};
return
vlclua_scripts_batch_execute
(
p_this
,
"meta"
DIR_SEP
"art"
,
&
fetch_art
,
p_item
);
return
vlclua_scripts_batch_execute
(
VLC_OBJECT
(
p_finder
)
,
"meta"
DIR_SEP
"art"
,
&
fetch_art
,
(
void
*
)
&
context
);
}
modules/lua/vlc.c
View file @
058b871e
...
...
@@ -262,7 +262,7 @@ void vlclua_dir_list_free( char **ppsz_dir_list )
*****************************************************************************/
int
vlclua_scripts_batch_execute
(
vlc_object_t
*
p_this
,
const
char
*
luadirname
,
int
(
*
func
)(
vlc_object_t
*
,
const
char
*
,
void
*
),
int
(
*
func
)(
vlc_object_t
*
,
const
char
*
,
const
luabatch_context_t
*
),
void
*
user_data
)
{
char
**
ppsz_dir_list
=
NULL
;
...
...
modules/lua/vlc.h
View file @
058b871e
...
...
@@ -32,9 +32,11 @@
#include <vlc_input.h>
#include <vlc_playlist.h>
#include <vlc_meta.h>
#include <vlc_art_finder.h>
#include <vlc_url.h>
#include <vlc_strings.h>
#include <vlc_stream.h>
#include <vlc_demux.h>
#define LUA_COMPAT_MODULE
#include <lua.h>
/* Low level lua C API */
...
...
@@ -49,9 +51,9 @@
/*****************************************************************************
* Module entry points
*****************************************************************************/
int
ReadMeta
(
vlc_object
_t
*
);
int
FetchMeta
(
vlc_object
_t
*
);
int
FindArt
(
vlc_object
_t
*
);
int
ReadMeta
(
demux_meta
_t
*
);
int
FetchMeta
(
art_finder
_t
*
);
int
FindArt
(
art_finder
_t
*
);
int
Import_LuaPlaylist
(
vlc_object_t
*
);
void
Close_LuaPlaylist
(
vlc_object_t
*
);
...
...
@@ -126,8 +128,16 @@ int vlclua_push_ret( lua_State *, int i_error );
* Will execute func on all scripts in luadirname, and stop if func returns
* success.
*****************************************************************************/
typedef
struct
luabatch_context_t
luabatch_context_t
;
struct
luabatch_context_t
{
input_item_t
*
p_item
;
meta_fetcher_scope_t
e_scope
;
bool
(
*
pf_validator
)(
const
luabatch_context_t
*
,
meta_fetcher_scope_t
);
};
int
vlclua_scripts_batch_execute
(
vlc_object_t
*
p_this
,
const
char
*
luadirname
,
int
(
*
func
)(
vlc_object_t
*
,
const
char
*
,
void
*
),
int
(
*
func
)(
vlc_object_t
*
,
const
char
*
,
const
luabatch_context_t
*
),
void
*
user_data
);
int
vlclua_dir_list
(
const
char
*
luadirname
,
char
***
pppsz_dir_list
);
void
vlclua_dir_list_free
(
char
**
ppsz_dir_list
);
...
...
src/playlist/fetcher.c
View file @
058b871e
...
...
@@ -53,6 +53,7 @@ struct playlist_fetcher_t
input_item_t
**
pp_waiting
;
DECL_ARRAY
(
playlist_album_t
)
albums
;
meta_fetcher_scope_t
e_scope
;
};
static
void
*
Thread
(
void
*
);
...
...
@@ -73,6 +74,13 @@ playlist_fetcher_t *playlist_fetcher_New( vlc_object_t *parent )
p_fetcher
->
b_live
=
false
;
p_fetcher
->
i_waiting
=
0
;
p_fetcher
->
pp_waiting
=
NULL
;
int
i_policy
=
var_InheritInteger
(
parent
,
"album-art"
);
if
(
i_policy
==
ALBUM_ART_ALL
)
p_fetcher
->
e_scope
=
FETCHER_SCOPE_ANY
;
else
p_fetcher
->
e_scope
=
FETCHER_SCOPE_LOCAL
;
ARRAY_INIT
(
p_fetcher
->
albums
);
return
p_fetcher
;
...
...
@@ -224,6 +232,7 @@ static int FindArt( playlist_fetcher_t *p_fetcher, input_item_t *p_item )
module_t
*
p_module
;
p_finder
->
p_item
=
p_item
;
p_finder
->
e_scope
=
p_fetcher
->
e_scope
;
p_module
=
module_need
(
p_finder
,
"art finder"
,
NULL
,
false
);
if
(
p_module
)
...
...
@@ -332,18 +341,19 @@ error:
*/
static
void
FetchMeta
(
playlist_fetcher_t
*
p_fetcher
,
input_item_t
*
p_item
)
{
demux_meta_t
*
p_demux_meta
=
vlc_custom_create
(
p_fetcher
->
object
,
sizeof
(
*
p_demux_meta
),
"demux meta
"
);
if
(
!
p_demux_meta
)
art_finder_t
*
p_finder
=
vlc_custom_create
(
p_fetcher
->
object
,
sizeof
(
*
p_finder
),
"art finder
"
);
if
(
!
p_finder
)
return
;
p_demux_meta
->
p_demux
=
NULL
;
p_demux_meta
->
p_item
=
p_item
;
p_finder
->
e_scope
=
p_fetcher
->
e_scope
;
p_finder
->
p_item
=
p_item
;
module_t
*
p_module
=
module_need
(
p_finder
,
"meta fetcher"
,
NULL
,
false
);
if
(
p_module
)
module_unneed
(
p_finder
,
p_module
);
module_t
*
p_meta_fetcher
=
module_need
(
p_demux_meta
,
"meta fetcher"
,
NULL
,
false
);
if
(
p_meta_fetcher
)
module_unneed
(
p_demux_meta
,
p_meta_fetcher
);
vlc_object_release
(
p_demux_meta
);
vlc_object_release
(
p_finder
);
}
static
void
*
Thread
(
void
*
p_data
)
...
...
src/playlist/preparser.c
View file @
058b871e
...
...
@@ -171,10 +171,8 @@ static void Art( playlist_preparser_t *p_preparser, input_item_t *p_item )
const
char
*
psz_arturl
=
vlc_meta_Get
(
p_item
->
p_meta
,
vlc_meta_ArtworkURL
);
const
char
*
psz_name
=
vlc_meta_Get
(
p_item
->
p_meta
,
vlc_meta_Title
);
if
(
p_preparser
->
i_art_policy
==
ALBUM_ART_ALL
&&
(
!
psz_arturl
||
(
strncmp
(
psz_arturl
,
"file://"
,
7
)
&&
strncmp
(
psz_arturl
,
"attachment://"
,
13
)
)
)
)
if
(
!
psz_arturl
||
(
strncmp
(
psz_arturl
,
"file://"
,
7
)
&&
strncmp
(
psz_arturl
,
"attachment://"
,
13
)
)
)
{
msg_Dbg
(
obj
,
"meta ok for %s, need to fetch art"
,
psz_name
?
psz_name
:
"(null)"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment