Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
VideoLAN
medialibrary
Commits
a2da976e
Commit
a2da976e
authored
Jan 04, 2016
by
Hugo Beauzée-Luyssen
Browse files
Artist: Add a musicbrainzId field
parent
6ff9e16c
Changes
4
Hide whitespace changes
Inline
Side-by-side
include/IArtist.h
View file @
a2da976e
...
...
@@ -37,4 +37,5 @@ public:
virtual
std
::
vector
<
AlbumPtr
>
albums
()
const
=
0
;
virtual
std
::
vector
<
MediaPtr
>
media
()
const
=
0
;
virtual
const
std
::
string
&
artworkMrl
()
const
=
0
;
virtual
const
std
::
string
&
musicBrainzId
()
const
=
0
;
};
src/Artist.cpp
View file @
a2da976e
...
...
@@ -40,6 +40,7 @@ Artist::Artist( DBConnection dbConnection, sqlite::Row& row )
>>
m_shortBio
>>
m_artworkMrl
>>
m_nbAlbums
>>
m_mbId
>>
m_isPresent
;
}
...
...
@@ -162,6 +163,23 @@ std::shared_ptr<Album> Artist::unknownAlbum()
return
album
;
}
const
std
::
string
&
Artist
::
musicBrainzId
()
const
{
return
m_mbId
;
}
bool
Artist
::
setMusicBrainzId
(
const
std
::
string
&
mbId
)
{
static
const
std
::
string
req
=
"UPDATE "
+
policy
::
ArtistTable
::
Name
+
" SET mb_id = ? WHERE id_artist = ?"
;
if
(
mbId
==
m_mbId
)
return
true
;
if
(
sqlite
::
Tools
::
executeUpdate
(
m_dbConnection
,
req
,
mbId
,
m_id
)
==
false
)
return
false
;
m_mbId
=
mbId
;
return
true
;
}
bool
Artist
::
createTable
(
DBConnection
dbConnection
)
{
static
const
std
::
string
req
=
"CREATE TABLE IF NOT EXISTS "
+
...
...
@@ -172,6 +190,7 @@ bool Artist::createTable( DBConnection dbConnection )
"shortbio TEXT,"
"artwork_mrl TEXT,"
"nb_albums UNSIGNED INT DEFAULT 0,"
"mb_id TEXT,"
"is_present BOOLEAN NOT NULL DEFAULT 1"
")"
;
static
const
std
::
string
reqRel
=
"CREATE TABLE IF NOT EXISTS MediaArtistRelation("
...
...
src/Artist.h
View file @
a2da976e
...
...
@@ -57,6 +57,8 @@ public:
bool
setArtworkMrl
(
const
std
::
string
&
artworkMrl
);
bool
updateNbAlbum
(
int
increment
);
std
::
shared_ptr
<
Album
>
unknownAlbum
();
virtual
const
std
::
string
&
musicBrainzId
()
const
override
;
bool
setMusicBrainzId
(
const
std
::
string
&
musicBrainzId
);
static
bool
createTable
(
DBConnection
dbConnection
);
static
bool
createTriggers
(
DBConnection
dbConnection
);
...
...
@@ -71,6 +73,7 @@ private:
std
::
string
m_artworkMrl
;
unsigned
int
m_nbAlbums
;
bool
m_isPresent
;
std
::
string
m_mbId
;
friend
struct
policy
::
ArtistTable
;
};
test/unittest/ArtistTests.cpp
View file @
a2da976e
...
...
@@ -173,3 +173,20 @@ TEST_F( Artists, UnknownAlbum )
ASSERT_NE
(
nullptr
,
album2
);
ASSERT_EQ
(
album2
->
id
(),
album
->
id
()
);
}
TEST_F
(
Artists
,
MusicBrainzId
)
{
auto
a
=
ml
->
createArtist
(
"Otters Never Say Die"
);
ASSERT_NE
(
a
,
nullptr
);
ASSERT_EQ
(
a
->
musicBrainzId
(),
""
);
std
::
string
mbId
(
"{this-id-an-id}"
);
a
->
setMusicBrainzId
(
mbId
);
ASSERT_EQ
(
a
->
musicBrainzId
(),
mbId
);
Reload
();
auto
a2
=
ml
->
artist
(
"Otters Never Say Die"
);
ASSERT_NE
(
a2
,
nullptr
);
ASSERT_EQ
(
a2
->
musicBrainzId
(),
mbId
);
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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