Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
VideoLAN
medialibrary
Commits
9ddc617c
Commit
9ddc617c
authored
Oct 14, 2015
by
Hugo Beauzée-Luyssen
Browse files
VLCMetadataService: Link artists and album
parent
d1a6bbe5
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/metadata_services/vlc/VLCMetadataService.cpp
View file @
9ddc617c
...
...
@@ -30,6 +30,7 @@
#include "IFile.h"
#include "IAlbum.h"
#include "IAlbumTrack.h"
#include "IArtist.h"
#include "IShow.h"
#include "File.h"
...
...
@@ -124,12 +125,14 @@ bool VLCMetadataService::parseAudioFile( FilePtr file, VLC::Media& media ) const
auto
albumTitle
=
media
.
meta
(
libvlc_meta_Album
);
if
(
albumTitle
.
length
()
==
0
)
return
true
;
auto
newAlbum
=
false
;
auto
album
=
m_ml
->
album
(
albumTitle
);
if
(
album
==
nullptr
)
{
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
)
);
...
...
@@ -171,22 +174,7 @@ bool VLCMetadataService::parseAudioFile( FilePtr file, VLC::Media& media ) const
if
(
genre
.
length
()
!=
0
)
track
->
setGenre
(
genre
);
auto
artistName
=
media
.
meta
(
libvlc_meta_Artist
);
if
(
artistName
.
length
()
!=
0
)
{
auto
artist
=
m_ml
->
artist
(
artistName
);
if
(
artist
==
nullptr
)
{
artist
=
m_ml
->
createArtist
(
artistName
);
if
(
artist
==
nullptr
)
{
LOG_ERROR
(
"Failed to create new artist "
,
artistName
);
// Consider this a minor failure and go on nevertheless
return
true
;
}
}
track
->
addArtist
(
artist
);
}
return
handleArtist
(
album
,
track
,
media
,
newAlbum
);
return
true
;
}
...
...
@@ -226,3 +214,32 @@ bool VLCMetadataService::parseVideoFile( FilePtr file, VLC::Media& media ) const
}
return
true
;
}
bool
VLCMetadataService
::
handleArtist
(
AlbumPtr
album
,
AlbumTrackPtr
track
,
VLC
::
Media
&
media
,
bool
newAlbum
)
const
{
auto
newArtist
=
false
;
auto
artistName
=
media
.
meta
(
libvlc_meta_Artist
);
if
(
artistName
.
length
()
!=
0
)
{
auto
artist
=
m_ml
->
artist
(
artistName
);
if
(
artist
==
nullptr
)
{
artist
=
m_ml
->
createArtist
(
artistName
);
if
(
artist
==
nullptr
)
{
LOG_ERROR
(
"Failed to create new artist "
,
artistName
);
// Consider this a minor failure and go on nevertheless
return
true
;
}
newArtist
=
true
;
}
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
->
addArtist
(
artist
)
==
false
)
LOG_WARN
(
"Failed to add artist "
,
artist
->
name
(),
" to album "
,
album
->
title
()
);
}
}
return
true
;
}
src/metadata_services/vlc/VLCMetadataService.h
View file @
9ddc617c
...
...
@@ -53,6 +53,7 @@ class VLCMetadataService : public IMetadataService
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
handleArtist
(
AlbumPtr
album
,
AlbumTrackPtr
track
,
VLC
::
Media
&
media
,
bool
newAlbum
)
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