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
d64468fb
Commit
d64468fb
authored
Oct 19, 2015
by
Hugo Beauzée-Luyssen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
AlbumTrack: Remove title field, as it already is exposed by the media
parent
e57a323f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
8 additions
and
27 deletions
+8
-27
include/IAlbumTrack.h
include/IAlbumTrack.h
+0
-2
src/AlbumTrack.cpp
src/AlbumTrack.cpp
+5
-20
src/AlbumTrack.h
src/AlbumTrack.h
+0
-3
src/metadata_services/vlc/VLCMetadataService.cpp
src/metadata_services/vlc/VLCMetadataService.cpp
+2
-1
test/VLCMetadataServices.cpp
test/VLCMetadataServices.cpp
+1
-1
No files found.
include/IAlbumTrack.h
View file @
d64468fb
...
...
@@ -34,10 +34,8 @@ class IAlbumTrack
virtual
unsigned
int
id
()
const
=
0
;
virtual
const
std
::
string
&
genre
()
=
0
;
virtual
const
std
::
string
&
title
()
=
0
;
virtual
unsigned
int
trackNumber
()
=
0
;
virtual
std
::
shared_ptr
<
IAlbum
>
album
()
=
0
;
virtual
std
::
vector
<
MediaPtr
>
files
()
=
0
;
};
#endif // IALBUMTRACK_H
src/AlbumTrack.cpp
View file @
d64468fb
...
...
@@ -36,17 +36,15 @@ AlbumTrack::AlbumTrack( DBConnection dbConnection, sqlite3_stmt* stmt )
{
m_id
=
sqlite
::
Traits
<
unsigned
int
>::
Load
(
stmt
,
0
);
m_mediaId
=
sqlite
::
Traits
<
unsigned
int
>::
Load
(
stmt
,
1
);
m_title
=
sqlite
::
Traits
<
std
::
string
>::
Load
(
stmt
,
2
);
m_genre
=
sqlite
::
Traits
<
std
::
string
>::
Load
(
stmt
,
3
);
m_trackNumber
=
sqlite
::
Traits
<
unsigned
int
>::
Load
(
stmt
,
4
);
m_albumId
=
sqlite
::
Traits
<
unsigned
int
>::
Load
(
stmt
,
5
);
m_genre
=
sqlite
::
Traits
<
std
::
string
>::
Load
(
stmt
,
2
);
m_trackNumber
=
sqlite
::
Traits
<
unsigned
int
>::
Load
(
stmt
,
3
);
m_albumId
=
sqlite
::
Traits
<
unsigned
int
>::
Load
(
stmt
,
4
);
}
//FIXME: constify media
AlbumTrack
::
AlbumTrack
(
Media
*
media
,
unsigned
int
trackNumber
,
unsigned
int
albumId
)
:
m_id
(
0
)
,
m_mediaId
(
media
->
id
()
)
,
m_title
(
media
->
name
()
)
,
m_trackNumber
(
trackNumber
)
,
m_albumId
(
albumId
)
,
m_album
(
nullptr
)
...
...
@@ -63,7 +61,6 @@ bool AlbumTrack::createTable( DBConnection dbConnection )
static
const
std
::
string
req
=
"CREATE TABLE IF NOT EXISTS "
+
policy
::
AlbumTrackTable
::
Name
+
"("
"id_track INTEGER PRIMARY KEY AUTOINCREMENT,"
"media_id INTEGER,"
"title TEXT,"
"genre TEXT,"
"track_number UNSIGNED INTEGER,"
"album_id UNSIGNED INTEGER NOT NULL,"
...
...
@@ -79,8 +76,8 @@ std::shared_ptr<AlbumTrack> AlbumTrack::create(DBConnection dbConnection, unsign
{
auto
self
=
std
::
make_shared
<
AlbumTrack
>
(
media
,
trackNb
,
albumId
);
static
const
std
::
string
req
=
"INSERT INTO "
+
policy
::
AlbumTrackTable
::
Name
+
"(media_id,
title,
track_number, album_id) VALUES(?, ?,
?,
?)"
;
if
(
_Cache
::
insert
(
dbConnection
,
self
,
req
,
media
->
id
(),
media
->
name
(),
trackNb
,
albumId
)
==
false
)
+
"(media_id, track_number, album_id) VALUES(?, ?, ?)"
;
if
(
_Cache
::
insert
(
dbConnection
,
self
,
req
,
media
->
id
(),
trackNb
,
albumId
)
==
false
)
return
nullptr
;
self
->
m_dbConnection
=
dbConnection
;
return
self
;
...
...
@@ -101,11 +98,6 @@ bool AlbumTrack::setGenre(const std::string& genre)
return
true
;
}
const
std
::
string
&
AlbumTrack
::
title
()
{
return
m_title
;
}
unsigned
int
AlbumTrack
::
trackNumber
()
{
return
m_trackNumber
;
...
...
@@ -119,10 +111,3 @@ std::shared_ptr<IAlbum> AlbumTrack::album()
}
return
m_album
;
}
std
::
vector
<
MediaPtr
>
AlbumTrack
::
files
()
{
static
const
std
::
string
req
=
"SELECT * FROM "
+
policy
::
MediaTable
::
Name
+
" WHERE album_track_id = ? "
;
return
Media
::
fetchAll
(
m_dbConnection
,
req
,
m_id
);
}
src/AlbumTrack.h
View file @
d64468fb
...
...
@@ -55,10 +55,8 @@ class AlbumTrack : public IAlbumTrack, public Cache<AlbumTrack, IAlbumTrack, pol
virtual
unsigned
int
id
()
const
override
;
virtual
const
std
::
string
&
genre
()
override
;
bool
setGenre
(
const
std
::
string
&
genre
);
virtual
const
std
::
string
&
title
()
override
;
virtual
unsigned
int
trackNumber
()
override
;
virtual
std
::
shared_ptr
<
IAlbum
>
album
()
override
;
virtual
std
::
vector
<
MediaPtr
>
files
()
override
;
static
bool
createTable
(
DBConnection
dbConnection
);
static
std
::
shared_ptr
<
AlbumTrack
>
create
(
DBConnection
dbConnection
,
unsigned
int
albumId
,
...
...
@@ -68,7 +66,6 @@ class AlbumTrack : public IAlbumTrack, public Cache<AlbumTrack, IAlbumTrack, pol
DBConnection
m_dbConnection
;
unsigned
int
m_id
;
unsigned
int
m_mediaId
;
std
::
string
m_title
;
std
::
string
m_genre
;
unsigned
int
m_trackNumber
;
unsigned
int
m_albumId
;
...
...
src/metadata_services/vlc/VLCMetadataService.cpp
View file @
d64468fb
...
...
@@ -234,9 +234,10 @@ std::shared_ptr<AlbumTrack> VLCMetadataService::handleTrack(std::shared_ptr<Albu
if
(
title
.
length
()
==
0
)
{
LOG_WARN
(
"Failed to get track title"
);
title
=
"
Unknown t
rack #"
;
title
=
"
T
rack #"
;
title
+=
trackNbStr
;
}
media
->
setName
(
title
);
unsigned
int
trackNb
=
std
::
stoi
(
trackNbStr
);
auto
track
=
std
::
static_pointer_cast
<
AlbumTrack
>
(
album
->
addTrack
(
media
,
trackNb
)
);
if
(
track
==
nullptr
)
...
...
test/VLCMetadataServices.cpp
View file @
d64468fb
...
...
@@ -108,7 +108,7 @@ TEST_F( VLCMetadataServices, ParseAlbum )
file
=
std
::
static_pointer_cast
<
Media
>
(
ml
->
file
(
"mr-zebra.mp3"
)
);
auto
track
=
file
->
albumTrack
();
ASSERT_NE
(
track
,
nullptr
);
ASSERT_EQ
(
track
->
titl
e
(),
"Mr. Zebra"
);
ASSERT_EQ
(
file
->
nam
e
(),
"Mr. Zebra"
);
ASSERT_EQ
(
track
->
genre
(),
"Rock"
);
auto
artists
=
file
->
artists
();
ASSERT_EQ
(
artists
.
size
(),
1u
);
...
...
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