Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
VideoLAN
medialibrary
Commits
440bf54a
Commit
440bf54a
authored
Oct 15, 2015
by
Hugo Beauzée-Luyssen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
VLCMetadataService: Don't stop parsing when failed to get the album name
parent
5bf0e273
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
46 deletions
+53
-46
src/metadata_services/vlc/VLCMetadataService.cpp
src/metadata_services/vlc/VLCMetadataService.cpp
+50
-44
src/metadata_services/vlc/VLCMetadataService.h
src/metadata_services/vlc/VLCMetadataService.h
+3
-2
No files found.
src/metadata_services/vlc/VLCMetadataService.cpp
View file @
440bf54a
...
...
@@ -119,56 +119,30 @@ bool VLCMetadataService::parseAudioFile( FilePtr file, VLC::Media& media ) const
{
file
->
setType
(
IFile
::
Type
::
AudioType
);
auto
albumTitle
=
media
.
meta
(
libvlc_meta_Album
);
if
(
albumTitle
.
length
()
==
0
)
return
true
;
auto
newAlbum
=
false
;
auto
album
=
m_ml
->
a
lbum
(
album
Title
)
;
if
(
album
==
nullptr
)
A
lbum
Ptr
album
;
if
(
album
Title
.
length
()
>
0
)
{
album
=
m_ml
->
createA
lbum
(
albumTitle
);
if
(
album
!
=
nullptr
)
auto
album
=
m_ml
->
a
lbum
(
albumTitle
);
if
(
album
=
=
nullptr
)
{
newAlbum
=
true
;
auto
date
=
media
.
meta
(
libvlc_meta_Date
);
if
(
date
.
length
()
>
0
)
album
->
setReleaseDate
(
std
::
stoul
(
date
)
);
album
=
m_ml
->
createAlbum
(
albumTitle
);
if
(
album
!=
nullptr
)
{
newAlbum
=
true
;
auto
date
=
media
.
meta
(
libvlc_meta_Date
);
if
(
date
.
length
()
>
0
)
album
->
setReleaseDate
(
std
::
stoul
(
date
)
);
}
}
}
if
(
album
==
nullptr
)
{
LOG_ERROR
(
"Failed to create/get album"
);
return
false
;
}
auto
trackNbStr
=
media
.
meta
(
libvlc_meta_TrackNumber
);
if
(
trackNbStr
.
length
()
==
0
)
{
LOG_ERROR
(
"Failed to get track id"
);
return
false
;
}
auto
artwork
=
media
.
meta
(
libvlc_meta_ArtworkURL
);
if
(
artwork
.
length
()
!=
0
)
album
->
setArtworkUrl
(
artwork
);
auto
title
=
media
.
meta
(
libvlc_meta_Title
);
if
(
title
.
length
()
==
0
)
{
LOG_ERROR
(
"Failed to compute track title"
);
title
=
"Unknown track #"
;
title
+=
trackNbStr
;
}
unsigned
int
trackNb
=
std
::
stoi
(
trackNbStr
);
auto
track
=
album
->
addTrack
(
title
,
trackNb
);
if
(
track
==
nullptr
)
AlbumTrackPtr
track
;
if
(
album
!=
nullptr
)
{
LOG_ERROR
(
"Failure while creating album track"
);
return
false
;
track
=
handleTrack
(
album
,
media
);
if
(
track
!=
nullptr
)
file
->
setAlbumTrack
(
track
);
}
file
->
setAlbumTrack
(
track
);
auto
genre
=
media
.
meta
(
libvlc_meta_Genre
);
if
(
genre
.
length
()
!=
0
)
track
->
setGenre
(
genre
);
return
handleArtist
(
album
,
track
,
media
,
newAlbum
);
}
...
...
@@ -230,7 +204,7 @@ bool VLCMetadataService::handleArtist( AlbumPtr album, AlbumTrackPtr track, VLC:
}
track
->
addArtist
(
artist
);
// If this is either a new album or a new artist, we need to add the relationship between the two.
if
(
newAlbum
==
true
||
newArtist
==
true
)
if
(
album
!=
nullptr
&&
(
newAlbum
==
true
||
newArtist
==
true
)
)
{
if
(
album
->
addArtist
(
artist
)
==
false
)
LOG_WARN
(
"Failed to add artist "
,
artist
->
name
(),
" to album "
,
album
->
title
()
);
...
...
@@ -240,3 +214,35 @@ bool VLCMetadataService::handleArtist( AlbumPtr album, AlbumTrackPtr track, VLC:
track
->
addArtist
(
nullptr
);
return
true
;
}
AlbumTrackPtr
VLCMetadataService
::
handleTrack
(
AlbumPtr
album
,
VLC
::
Media
&
media
)
const
{
auto
trackNbStr
=
media
.
meta
(
libvlc_meta_TrackNumber
);
if
(
trackNbStr
.
length
()
==
0
)
{
LOG_WARN
(
"Failed to get track id"
);
return
nullptr
;
}
auto
artwork
=
media
.
meta
(
libvlc_meta_ArtworkURL
);
if
(
artwork
.
length
()
!=
0
)
album
->
setArtworkUrl
(
artwork
);
auto
title
=
media
.
meta
(
libvlc_meta_Title
);
if
(
title
.
length
()
==
0
)
{
LOG_WARN
(
"Failed to get track title"
);
title
=
"Unknown track #"
;
title
+=
trackNbStr
;
}
unsigned
int
trackNb
=
std
::
stoi
(
trackNbStr
);
auto
track
=
album
->
addTrack
(
title
,
trackNb
);
if
(
track
==
nullptr
)
{
LOG_ERROR
(
"Failed to create album track"
);
return
nullptr
;
}
auto
genre
=
media
.
meta
(
libvlc_meta_Genre
);
if
(
genre
.
length
()
!=
0
)
track
->
setGenre
(
genre
);
return
track
;
}
src/metadata_services/vlc/VLCMetadataService.h
View file @
440bf54a
...
...
@@ -51,9 +51,10 @@ class VLCMetadataService : public IMetadataService
private:
ServiceStatus
handleMediaMeta
(
FilePtr
file
,
VLC
::
Media
&
media
)
const
;
bool
parseAudioFile
(
FilePtr
file
,
VLC
::
Media
&
media
)
const
;
bool
parseVideoFile
(
FilePtr
file
,
VLC
::
Media
&
media
)
const
;
bool
parseAudioFile
(
FilePtr
file
,
VLC
::
Media
&
media
)
const
;
bool
parseVideoFile
(
FilePtr
file
,
VLC
::
Media
&
media
)
const
;
bool
handleArtist
(
AlbumPtr
album
,
AlbumTrackPtr
track
,
VLC
::
Media
&
media
,
bool
newAlbum
)
const
;
AlbumTrackPtr
handleTrack
(
AlbumPtr
album
,
VLC
::
Media
&
media
)
const
;
VLC
::
Instance
m_instance
;
IMetadataServiceCb
*
m_cb
;
...
...
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