Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-1.1
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-1.1
Commits
d112d7e9
Commit
d112d7e9
authored
Aug 21, 2007
by
Pierre d'Herbemont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
input/meta.c: * Remove psz_name
* Use filename sanitization at the lower level
parent
40ad7fd9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
46 deletions
+43
-46
src/input/meta.c
src/input/meta.c
+43
-46
No files found.
src/input/meta.c
View file @
d112d7e9
...
@@ -118,19 +118,19 @@ int input_ArtFind( playlist_t *p_playlist, input_item_t *p_item )
...
@@ -118,19 +118,19 @@ int input_ArtFind( playlist_t *p_playlist, input_item_t *p_item )
{
{
int
i_ret
=
VLC_EGENERIC
;
int
i_ret
=
VLC_EGENERIC
;
module_t
*
p_module
;
module_t
*
p_module
;
char
*
psz_
name
,
*
psz_
title
,
*
psz_artist
,
*
psz_album
;
char
*
psz_title
,
*
psz_artist
,
*
psz_album
;
if
(
!
p_item
->
p_meta
)
if
(
!
p_item
->
p_meta
)
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
psz_name
=
input_item_GetName
(
p_item
);
psz_title
=
input_item_GetTitle
(
p_item
);
psz_artist
=
input_item_GetArtist
(
p_item
);
psz_artist
=
input_item_GetArtist
(
p_item
);
psz_album
=
input_item_GetAlbum
(
p_item
);
psz_title
=
input_item_GetTitle
(
p_item
);
if
(
!
psz_title
)
psz_title
=
input_item_GetName
(
p_item
);
if
(
!
psz_
name
&&
!
psz_
title
&&
!
psz_artist
&&
!
psz_album
)
if
(
!
psz_title
&&
!
psz_artist
&&
!
psz_album
)
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
free
(
psz_name
);
free
(
psz_title
);
free
(
psz_title
);
/* If we already checked this album in this session, skip */
/* If we already checked this album in this session, skip */
...
@@ -174,8 +174,10 @@ int input_ArtFind( playlist_t *p_playlist, input_item_t *p_item )
...
@@ -174,8 +174,10 @@ int input_ArtFind( playlist_t *p_playlist, input_item_t *p_item )
p_playlist
->
p_private
=
p_item
;
p_playlist
->
p_private
=
p_item
;
psz_album
=
input_item_GetAlbum
(
p_item
);
psz_album
=
input_item_GetAlbum
(
p_item
);
psz_artist
=
input_item_GetArtist
(
p_item
);
psz_artist
=
input_item_GetArtist
(
p_item
);
psz_name
=
input_item_GetName
(
p_item
);
psz_title
=
input_item_GetTitle
(
p_item
);
psz_title
=
input_item_GetTitle
(
p_item
);
if
(
!
psz_title
)
psz_title
=
input_item_GetName
(
p_item
);
if
(
psz_album
&&
psz_artist
)
if
(
psz_album
&&
psz_artist
)
{
{
msg_Dbg
(
p_playlist
,
"searching art for %s - %s"
,
msg_Dbg
(
p_playlist
,
"searching art for %s - %s"
,
...
@@ -184,10 +186,9 @@ int input_ArtFind( playlist_t *p_playlist, input_item_t *p_item )
...
@@ -184,10 +186,9 @@ int input_ArtFind( playlist_t *p_playlist, input_item_t *p_item )
else
else
{
{
msg_Dbg
(
p_playlist
,
"searching art for %s"
,
msg_Dbg
(
p_playlist
,
"searching art for %s"
,
psz_title
?
psz_title
:
psz_name
);
psz_title
);
}
}
free
(
psz_title
);
free
(
psz_title
);
free
(
psz_name
);
p_module
=
module_Need
(
p_playlist
,
"art finder"
,
0
,
VLC_FALSE
);
p_module
=
module_Need
(
p_playlist
,
"art finder"
,
0
,
VLC_FALSE
);
...
@@ -239,11 +240,13 @@ static void ArtCacheCreateDir( const char *psz_dir )
...
@@ -239,11 +240,13 @@ static void ArtCacheCreateDir( const char *psz_dir )
}
}
}
}
static
char
*
ArtCacheCreateString
(
const
char
*
psz
)
static
char
*
ArtCacheGetSanitizedFileName
(
const
char
*
psz
)
{
{
char
*
dup
=
strdup
(
psz
);
char
*
dup
=
strdup
(
psz
);
int
i
;
int
i
;
filename_sanitize
(
dup
);
/* Doesn't create a filename with invalid characters
/* Doesn't create a filename with invalid characters
* TODO: several filesystems forbid several characters: list them all
* TODO: several filesystems forbid several characters: list them all
*/
*/
...
@@ -255,43 +258,47 @@ static char *ArtCacheCreateString( const char *psz )
...
@@ -255,43 +258,47 @@ static char *ArtCacheCreateString( const char *psz )
return
dup
;
return
dup
;
}
}
#define ArtCacheGetDir
Name(a,b,c,d,e) __ArtCacheGetDirName
(VLC_OBJECT(a),b,c,d,e)
#define ArtCacheGetDir
Path(a,b,c,d,e) __ArtCacheGetDirPath
(VLC_OBJECT(a),b,c,d,e)
static
void
__ArtCacheGetDir
Name
(
vlc_object_t
*
p_obj
,
static
void
__ArtCacheGetDir
Path
(
vlc_object_t
*
p_obj
,
char
*
psz_dir
,
char
*
psz_dir
,
char
*
psz_title
,
c
onst
c
har
*
psz_title
,
c
har
*
psz_artist
,
char
*
psz_album
)
c
onst
char
*
psz_artist
,
const
char
*
psz_album
)
{
{
if
(
!
EMPTY_STR
(
psz_artist
)
&&
!
EMPTY_STR
(
psz_album
)
)
if
(
!
EMPTY_STR
(
psz_artist
)
&&
!
EMPTY_STR
(
psz_album
)
)
{
{
filename_sanitize
(
psz_title
);
char
*
psz_album_sanitized
=
ArtCacheGetSanitizedFileName
(
psz_album
);
filename_sanitiz
e
(
psz_artist
);
char
*
psz_artist_sanitized
=
ArtCacheGetSanitizedFileNam
e
(
psz_artist
);
snprintf
(
psz_dir
,
MAX_PATH
,
"%s"
DIR_SEP
CONFIG_DIR
DIR_SEP
snprintf
(
psz_dir
,
MAX_PATH
,
"%s"
DIR_SEP
CONFIG_DIR
DIR_SEP
"art"
DIR_SEP
"artistalbum"
DIR_SEP
"%s"
DIR_SEP
"%s"
,
"art"
DIR_SEP
"artistalbum"
DIR_SEP
"%s"
DIR_SEP
"%s"
,
p_obj
->
p_libvlc
->
psz_homedir
,
p_obj
->
p_libvlc
->
psz_homedir
,
psz_artist
,
psz_album
);
psz_artist_sanitized
,
psz_album_sanitized
);
free
(
psz_album_sanitized
);
free
(
psz_artist_sanitized
);
}
}
else
else
{
{
filename_sanitiz
e
(
psz_title
);
char
*
psz_title_sanitized
=
ArtCacheGetSanitizedFileNam
e
(
psz_title
);
snprintf
(
psz_dir
,
MAX_PATH
,
"%s"
DIR_SEP
CONFIG_DIR
DIR_SEP
snprintf
(
psz_dir
,
MAX_PATH
,
"%s"
DIR_SEP
CONFIG_DIR
DIR_SEP
"art"
DIR_SEP
"title"
DIR_SEP
"%s"
,
"art"
DIR_SEP
"title"
DIR_SEP
"%s"
,
p_obj
->
p_libvlc
->
psz_homedir
,
psz_title
);
p_obj
->
p_libvlc
->
psz_homedir
,
psz_title_sanitized
);
free
(
psz_title_sanitized
);
}
}
}
}
#define ArtCacheGetFile
Name(a,b,c,d,e,f) __ArtCacheGetFileName
(VLC_OBJECT(a),b,c,d,e,f)
#define ArtCacheGetFile
Path(a,b,c,d,e,f) __ArtCacheGetFilePath
(VLC_OBJECT(a),b,c,d,e,f)
static
void
__ArtCacheGetFile
Name
(
vlc_object_t
*
p_obj
,
static
void
__ArtCacheGetFile
Path
(
vlc_object_t
*
p_obj
,
char
*
psz_filename
,
char
*
psz_filename
,
char
*
psz_title
,
c
onst
c
har
*
psz_title
,
c
har
*
psz_artist
,
char
*
psz_album
,
c
onst
char
*
psz_artist
,
const
char
*
psz_album
,
const
char
*
psz_extension
)
const
char
*
psz_extension
)
{
{
char
psz_dir
[
MAX_PATH
+
1
];
char
psz_dir
[
MAX_PATH
+
1
];
char
*
psz_ext
;
char
*
psz_ext
;
ArtCacheGetDir
Name
(
p_obj
,
psz_dir
,
psz_title
,
psz_artist
,
psz_album
);
ArtCacheGetDir
Path
(
p_obj
,
psz_dir
,
psz_title
,
psz_artist
,
psz_album
);
if
(
psz_extension
)
if
(
psz_extension
)
{
{
...
@@ -331,7 +338,7 @@ static int __input_FindArtInCache( vlc_object_t *p_obj, input_item_t *p_item )
...
@@ -331,7 +338,7 @@ static int __input_FindArtInCache( vlc_object_t *p_obj, input_item_t *p_item )
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
}
}
ArtCacheGetDir
Name
(
p_obj
,
psz_dirname
,
psz_title
,
ArtCacheGetDir
Path
(
p_obj
,
psz_dirname
,
psz_title
,
psz_artist
,
psz_album
);
psz_artist
,
psz_album
);
free
(
psz_artist
);
free
(
psz_artist
);
...
@@ -371,14 +378,14 @@ int input_DownloadAndCacheArt( playlist_t *p_playlist, input_item_t *p_item )
...
@@ -371,14 +378,14 @@ int input_DownloadAndCacheArt( playlist_t *p_playlist, input_item_t *p_item )
char
*
psz_artist
=
NULL
;
char
*
psz_artist
=
NULL
;
char
*
psz_album
=
NULL
;
char
*
psz_album
=
NULL
;
char
*
psz_title
=
NULL
;
char
*
psz_title
=
NULL
;
char
*
psz_name
=
NULL
;
char
*
psz_arturl
;
char
*
psz_arturl
;
char
*
psz_type
;
char
*
psz_type
;
psz_artist
=
input_item_GetArtist
(
p_item
);
psz_artist
=
input_item_GetArtist
(
p_item
);
psz_album
=
input_item_GetAlbum
(
p_item
);
psz_album
=
input_item_GetAlbum
(
p_item
);
psz_title
=
input_item_GetTitle
(
p_item
);
psz_title
=
input_item_GetTitle
(
p_item
);
psz_name
=
input_item_GetName
(
p_item
);
if
(
!
psz_title
)
psz_title
=
input_item_GetName
(
p_item
);
if
(
!
psz_title
&&
(
!
psz_artist
||
!
psz_album
)
)
if
(
!
psz_title
&&
(
!
psz_artist
||
!
psz_album
)
)
{
{
...
@@ -404,10 +411,10 @@ int input_DownloadAndCacheArt( playlist_t *p_playlist, input_item_t *p_item )
...
@@ -404,10 +411,10 @@ int input_DownloadAndCacheArt( playlist_t *p_playlist, input_item_t *p_item )
/* Warning: psz_title, psz_artist, psz_album may change in ArtCache*() */
/* Warning: psz_title, psz_artist, psz_album may change in ArtCache*() */
ArtCacheGetDir
Name
(
p_playlist
,
psz_filename
,
psz_title
,
psz_artist
,
ArtCacheGetDir
Path
(
p_playlist
,
psz_filename
,
psz_title
,
psz_artist
,
psz_album
);
psz_album
);
ArtCacheCreateDir
(
psz_filename
);
ArtCacheCreateDir
(
psz_filename
);
ArtCacheGetFile
Name
(
p_playlist
,
psz_filename
,
psz_title
,
psz_artist
,
ArtCacheGetFile
Path
(
p_playlist
,
psz_filename
,
psz_title
,
psz_artist
,
psz_album
,
psz_type
);
psz_album
,
psz_type
);
free
(
psz_artist
);
free
(
psz_artist
);
...
@@ -458,7 +465,6 @@ void input_ExtractAttachmentAndCacheArt( input_thread_t *p_input )
...
@@ -458,7 +465,6 @@ void input_ExtractAttachmentAndCacheArt( input_thread_t *p_input )
char
*
psz_album
=
NULL
;
char
*
psz_album
=
NULL
;
char
*
psz_title
=
NULL
;
char
*
psz_title
=
NULL
;
char
*
psz_type
=
NULL
;
char
*
psz_type
=
NULL
;
char
*
psz_artist_m
,
*
psz_album_m
,
*
psz_title_m
,
*
psz_name_m
;
char
psz_filename
[
MAX_PATH
+
1
];
char
psz_filename
[
MAX_PATH
+
1
];
FILE
*
f
;
FILE
*
f
;
input_attachment_t
*
p_attachment
;
input_attachment_t
*
p_attachment
;
...
@@ -503,20 +509,11 @@ void input_ExtractAttachmentAndCacheArt( input_thread_t *p_input )
...
@@ -503,20 +509,11 @@ void input_ExtractAttachmentAndCacheArt( input_thread_t *p_input )
goto
end
;
goto
end
;
}
}
psz_artist_m
=
input_item_GetArtist
(
p_item
);
psz_artist
=
input_item_GetArtist
(
p_item
);
psz_album_m
=
input_item_GetAlbum
(
p_item
);
psz_album
=
input_item_GetAlbum
(
p_item
);
psz_title_m
=
input_item_GetTitle
(
p_item
);
psz_title
=
input_item_GetTitle
(
p_item
);
psz_name_m
=
input_item_GetName
(
p_item
);
if
(
!
psz_title
)
psz_title
=
input_item_GetName
(
p_item
);
if
(
psz_artist_m
)
psz_artist
=
ArtCacheCreateString
(
psz_artist_m
);
if
(
psz_album_m
)
psz_album
=
ArtCacheCreateString
(
psz_album_m
);
if
(
psz_title_m
)
psz_title
=
ArtCacheCreateString
(
psz_title_m
);
else
if
(
psz_name_m
)
psz_title
=
ArtCacheCreateString
(
psz_name_m
);
free
(
psz_artist_m
);
free
(
psz_album_m
);
free
(
psz_title_m
);
free
(
psz_name_m
);
if
(
(
!
psz_artist
||
!
psz_album
)
&&
!
psz_title
)
if
(
(
!
psz_artist
||
!
psz_album
)
&&
!
psz_title
)
goto
end
;
goto
end
;
...
@@ -524,9 +521,9 @@ void input_ExtractAttachmentAndCacheArt( input_thread_t *p_input )
...
@@ -524,9 +521,9 @@ void input_ExtractAttachmentAndCacheArt( input_thread_t *p_input )
/* */
/* */
psz_type
=
strrchr
(
psz_arturl
,
'.'
);
psz_type
=
strrchr
(
psz_arturl
,
'.'
);
ArtCacheGetDir
Name
(
p_input
,
psz_filename
,
psz_title
,
psz_artist
,
psz_album
);
ArtCacheGetDir
Path
(
p_input
,
psz_filename
,
psz_title
,
psz_artist
,
psz_album
);
ArtCacheCreateDir
(
psz_filename
);
ArtCacheCreateDir
(
psz_filename
);
ArtCacheGetFile
Name
(
p_input
,
psz_filename
,
psz_title
,
psz_artist
,
psz_album
,
psz_type
);
ArtCacheGetFile
Path
(
p_input
,
psz_filename
,
psz_title
,
psz_artist
,
psz_album
,
psz_type
);
/* Check if we already dumped it */
/* Check if we already dumped it */
if
(
!
utf8_stat
(
psz_filename
+
7
,
&
s
)
)
if
(
!
utf8_stat
(
psz_filename
+
7
,
&
s
)
)
...
...
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