Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
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-2-2
Commits
40ad7fd9
Commit
40ad7fd9
authored
Aug 21, 2007
by
Pierre d'Herbemont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
input/meta.c: Better art finding.
parent
18cff171
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
86 additions
and
86 deletions
+86
-86
src/input/meta.c
src/input/meta.c
+86
-86
No files found.
src/input/meta.c
View file @
40ad7fd9
...
@@ -222,97 +222,88 @@ int input_ArtFind( playlist_t *p_playlist, input_item_t *p_item )
...
@@ -222,97 +222,88 @@ int input_ArtFind( playlist_t *p_playlist, input_item_t *p_item )
#ifndef MAX_PATH
#ifndef MAX_PATH
# define MAX_PATH 250
# define MAX_PATH 250
#endif
#endif
#define ArtCacheCreateName(a,b,c,d,e,f) __ArtCacheCreateName(VLC_OBJECT(a),b,c,d,e,f)
static
void
ArtCacheCreateDir
(
const
char
*
psz_dir
)
static
void
__ArtCacheCreateName
(
vlc_object_t
*
p_obj
,
char
psz_filename
[
MAX_PATH
+
1
],
char
*
psz_title
,
char
*
psz_artist
,
char
*
psz_album
,
const
char
*
psz_extension
)
{
{
char
*
psz_ext
;
char
newdir
[
MAX_PATH
+
1
];
if
(
psz_extension
)
strcpy
(
newdir
,
psz_dir
);
{
char
*
psz_newdir
=
newdir
;
psz_ext
=
strndup
(
psz_extension
,
6
);
char
*
psz
=
psz_newdir
;
filename_sanitize
(
psz_ext
);
}
while
(
*
psz_newdir
)
else
psz_ext
=
strdup
(
""
);
if
(
!
EMPTY_STR
(
psz_artist
)
&&
!
EMPTY_STR
(
psz_album
)
)
{
{
filename_sanitize
(
psz_title
);
while
(
*
psz
&&
*
psz
!=
'/'
)
psz
++
;
filename_sanitize
(
psz_artist
);
if
(
!*
psz
)
break
;
snprintf
(
psz_filename
,
MAX_PATH
,
*
psz
=
0
;
"file://%s"
DIR_SEP
CONFIG_DIR
DIR_SEP
"art"
DIR_SEP
"artistalbum"
if
(
!
EMPTY_STR
(
psz_newdir
)
)
utf8_mkdir
(
psz_newdir
);
DIR_SEP
"%s"
DIR_SEP
"%s"
DIR_SEP
"art%s"
,
psz_newdir
=
psz
+
1
;
p_obj
->
p_libvlc
->
psz_homedir
,
psz_artist
,
psz_album
,
psz_ext
);
}
}
else
}
static
char
*
ArtCacheCreateString
(
const
char
*
psz
)
{
char
*
dup
=
strdup
(
psz
);
int
i
;
/* Doesn't create a filename with invalid characters
* TODO: several filesystems forbid several characters: list them all
*/
for
(
i
=
0
;
dup
[
i
]
!=
'\0'
;
i
++
)
{
{
/* We will use the psz_title name to store the art */
if
(
dup
[
i
]
==
'/'
)
filename_sanitize
(
psz_title
);
dup
[
i
]
=
' '
;
snprintf
(
psz_filename
,
MAX_PATH
,
"file://%s"
DIR_SEP
CONFIG_DIR
DIR_SEP
"art"
DIR_SEP
"title"
DIR_SEP
"%s"
DIR_SEP
"art%s"
,
p_obj
->
p_libvlc
->
psz_homedir
,
psz_title
,
psz_ext
);
}
}
free
(
psz_ext
)
;
return
dup
;
}
}
#define ArtCacheCreatePath(a,b,c,d) __ArtCacheCreatePath(VLC_OBJECT(a),b,c,d)
static
void
__ArtCacheCreatePath
(
vlc_object_t
*
p_obj
,
#define ArtCacheGetDirName(a,b,c,d,e) __ArtCacheGetDirName(VLC_OBJECT(a),b,c,d,e)
static
void
__ArtCacheGetDirName
(
vlc_object_t
*
p_obj
,
char
*
psz_dir
,
char
*
psz_title
,
char
*
psz_title
,
char
*
psz_artist
,
char
*
psz_album
)
char
*
psz_artist
,
char
*
psz_album
)
{
{
char
psz_dir
[
MAX_PATH
+
1
];
snprintf
(
psz_dir
,
MAX_PATH
,
"%s"
DIR_SEP
CONFIG_DIR
,
p_obj
->
p_libvlc
->
psz_homedir
);
utf8_mkdir
(
psz_dir
);
snprintf
(
psz_dir
,
MAX_PATH
,
"%s"
DIR_SEP
CONFIG_DIR
DIR_SEP
"art"
,
p_obj
->
p_libvlc
->
psz_homedir
);
utf8_mkdir
(
psz_dir
);
if
(
!
EMPTY_STR
(
psz_artist
)
&&
!
EMPTY_STR
(
psz_album
)
)
if
(
!
EMPTY_STR
(
psz_artist
)
&&
!
EMPTY_STR
(
psz_album
)
)
{
{
snprintf
(
psz_dir
,
MAX_PATH
,
"%s"
DIR_SEP
CONFIG_DIR
DIR_SEP
filename_sanitize
(
psz_title
);
"art"
DIR_SEP
"artistalbum"
,
filename_sanitize
(
psz_artist
);
p_obj
->
p_libvlc
->
psz_homedir
);
utf8_mkdir
(
psz_dir
);
snprintf
(
psz_dir
,
MAX_PATH
,
"%s"
DIR_SEP
CONFIG_DIR
DIR_SEP
"art"
DIR_SEP
"artistalbum"
DIR_SEP
"%s"
,
p_obj
->
p_libvlc
->
psz_homedir
,
psz_artist
);
utf8_mkdir
(
psz_dir
);
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
,
psz_album
);
utf8_mkdir
(
psz_dir
);
}
}
else
else
{
{
snprintf
(
psz_dir
,
MAX_PATH
,
"%s"
DIR_SEP
CONFIG_DIR
DIR_SEP
filename_sanitize
(
psz_title
);
"art"
DIR_SEP
"title"
,
p_obj
->
p_libvlc
->
psz_homedir
);
utf8_mkdir
(
psz_dir
);
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
);
utf8_mkdir
(
psz_dir
);
}
}
}
}
static
char
*
ArtCacheCreateString
(
const
char
*
psz
)
#define ArtCacheGetFileName(a,b,c,d,e,f) __ArtCacheGetFileName(VLC_OBJECT(a),b,c,d,e,f)
static
void
__ArtCacheGetFileName
(
vlc_object_t
*
p_obj
,
char
*
psz_filename
,
char
*
psz_title
,
char
*
psz_artist
,
char
*
psz_album
,
const
char
*
psz_extension
)
{
{
char
*
dup
=
strdup
(
psz
);
char
psz_dir
[
MAX_PATH
+
1
];
int
i
;
char
*
psz_ext
;
ArtCacheGetDirName
(
p_obj
,
psz_dir
,
psz_title
,
psz_artist
,
psz_album
);
/* Doesn't create a filename with invalid characters
if
(
psz_extension
)
* TODO: several filesystems forbid several characters: list them all
*/
for
(
i
=
0
;
dup
[
i
]
!=
'\0'
;
i
++
)
{
{
if
(
dup
[
i
]
==
'/'
)
psz_ext
=
strndup
(
psz_extension
,
6
);
dup
[
i
]
=
' '
;
filename_sanitize
(
psz_ext
)
;
}
}
return
dup
;
else
psz_ext
=
strdup
(
""
);
snprintf
(
psz_filename
,
MAX_PATH
,
"file://%s"
DIR_SEP
"art%s"
,
psz_dir
,
psz_ext
);
free
(
psz_ext
);
}
}
static
int
__input_FindArtInCache
(
vlc_object_t
*
p_obj
,
input_item_t
*
p_item
)
static
int
__input_FindArtInCache
(
vlc_object_t
*
p_obj
,
input_item_t
*
p_item
)
...
@@ -320,10 +311,10 @@ static int __input_FindArtInCache( vlc_object_t *p_obj, input_item_t *p_item )
...
@@ -320,10 +311,10 @@ static int __input_FindArtInCache( vlc_object_t *p_obj, input_item_t *p_item )
char
*
psz_artist
;
char
*
psz_artist
;
char
*
psz_album
;
char
*
psz_album
;
char
*
psz_title
;
char
*
psz_title
;
char
psz_dirname
[
MAX_PATH
+
1
];
char
psz_filename
[
MAX_PATH
+
1
];
char
psz_filename
[
MAX_PATH
+
1
];
int
i
;
struct
dirent
*
p_de
;
struct
stat
a
;
DIR
*
p_dir
;
const
char
*
ppsz_type
[]
=
{
".jpg"
,
".png"
,
".gif"
,
".bmp"
,
""
};
if
(
!
p_item
->
p_meta
)
return
VLC_EGENERIC
;
if
(
!
p_item
->
p_meta
)
return
VLC_EGENERIC
;
...
@@ -339,24 +330,32 @@ static int __input_FindArtInCache( vlc_object_t *p_obj, input_item_t *p_item )
...
@@ -339,24 +330,32 @@ static int __input_FindArtInCache( vlc_object_t *p_obj, input_item_t *p_item )
free
(
psz_title
);
free
(
psz_title
);
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
}
}
free
(
psz_title
);
for
(
i
=
0
;
i
<
5
;
i
++
)
ArtCacheGetDirName
(
p_obj
,
psz_dirname
,
psz_title
,
{
psz_artist
,
psz_album
);
ArtCacheCreateName
(
p_obj
,
psz_filename
,
psz_title
/* Used if none artist nor album is defined */
,
psz_artist
,
psz_album
,
ppsz_type
[
i
]
);
free
(
psz_artist
);
free
(
psz_album
);
free
(
psz_title
);
/* Check if file exists */
/* Check if file exists */
if
(
utf8_stat
(
psz_filename
+
7
,
&
a
)
==
0
)
p_dir
=
utf8_opendir
(
psz_dirname
);
if
(
!
p_dir
)
return
VLC_EGENERIC
;
while
(
(
p_de
=
readdir
(
p_dir
))
)
{
if
(
strncmp
(
p_de
->
d_name
,
"art"
,
3
)
)
{
{
snprintf
(
psz_filename
,
MAX_PATH
,
"%s"
DIR_SEP
"%s"
,
psz_dirname
,
p_de
->
d_name
);
input_item_SetArtURL
(
p_item
,
psz_filename
);
input_item_SetArtURL
(
p_item
,
psz_filename
);
free
(
psz_artist
);
closedir
(
p_dir
);
free
(
psz_album
);
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
}
}
}
}
free
(
psz_artist
);
free
(
psz_album
);
closedir
(
p_dir
);
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
}
}
...
@@ -403,14 +402,14 @@ int input_DownloadAndCacheArt( playlist_t *p_playlist, input_item_t *p_item )
...
@@ -403,14 +402,14 @@ int input_DownloadAndCacheArt( playlist_t *p_playlist, input_item_t *p_item )
if
(
strlen
(
psz_type
)
>
5
)
if
(
strlen
(
psz_type
)
>
5
)
psz_type
=
NULL
;
/* remove extension if it's > to 4 characters */
psz_type
=
NULL
;
/* remove extension if it's > to 4 characters */
/* */
/* Warning: psz_title, psz_artist, psz_album may change in ArtCache*() */
ArtCacheCreateName
(
p_playlist
,
psz_filename
,
psz_title
/* Used only if needed*/
,
psz_artist
,
psz_album
,
psz_type
);
/* */
ArtCacheGetDirName
(
p_playlist
,
psz_filename
,
psz_title
,
psz_artist
,
ArtCacheCreatePath
(
p_playlist
,
psz_title
,
psz_artist
,
psz_album
);
psz_album
);
ArtCacheCreateDir
(
psz_filename
);
ArtCacheGetFileName
(
p_playlist
,
psz_filename
,
psz_title
,
psz_artist
,
psz_album
,
psz_type
);
/* */
free
(
psz_artist
);
free
(
psz_artist
);
free
(
psz_album
);
free
(
psz_album
);
free
(
psz_title
);
free
(
psz_title
);
...
@@ -524,14 +523,15 @@ void input_ExtractAttachmentAndCacheArt( input_thread_t *p_input )
...
@@ -524,14 +523,15 @@ void input_ExtractAttachmentAndCacheArt( input_thread_t *p_input )
/* */
/* */
psz_type
=
strrchr
(
psz_arturl
,
'.'
);
psz_type
=
strrchr
(
psz_arturl
,
'.'
);
ArtCacheCreateName
(
p_input
,
psz_filename
,
psz_title
,
psz_artist
,
psz_album
,
psz_type
);
ArtCacheGetDirName
(
p_input
,
psz_filename
,
psz_title
,
psz_artist
,
psz_album
);
ArtCacheCreateDir
(
psz_filename
);
ArtCacheGetFileName
(
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
)
)
goto
end
;
goto
end
;
ArtCacheCreatePath
(
p_input
,
psz_title
,
psz_artist
,
psz_album
);
f
=
utf8_fopen
(
psz_filename
+
7
,
"w"
);
f
=
utf8_fopen
(
psz_filename
+
7
,
"w"
);
if
(
f
)
if
(
f
)
{
{
...
...
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