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
6da22990
Commit
6da22990
authored
Jun 26, 2018
by
Hugo Beauzée-Luyssen
Browse files
IMediaLibrary: Add a shows listing
parent
2788ac76
Changes
6
Hide whitespace changes
Inline
Side-by-side
include/medialibrary/IMediaLibrary.h
View file @
6da22990
...
...
@@ -266,6 +266,7 @@ class IMediaLibrary
virtual
ShowPtr
show
(
int64_t
id
)
const
=
0
;
virtual
MoviePtr
movie
(
int64_t
id
)
const
=
0
;
virtual
ArtistPtr
artist
(
int64_t
id
)
const
=
0
;
virtual
Query
<
IShow
>
shows
(
const
QueryParameters
*
params
=
nullptr
)
const
=
0
;
/**
* @brief artists List all artists that have at least an album.
* Artists that only appear on albums as guests won't be listed from here, but will be
...
...
src/MediaLibrary.cpp
View file @
6da22990
...
...
@@ -580,6 +580,11 @@ std::shared_ptr<Show> MediaLibrary::createShow( const std::string& name )
return
Show
::
create
(
this
,
name
);
}
Query
<
IShow
>
MediaLibrary
::
shows
(
const
QueryParameters
*
params
)
const
{
return
Show
::
listAll
(
this
,
params
);
}
MoviePtr
MediaLibrary
::
movie
(
int64_t
id
)
const
{
return
Movie
::
fetch
(
this
,
id
);
...
...
src/MediaLibrary.h
View file @
6da22990
...
...
@@ -95,6 +95,7 @@ class MediaLibrary : public IMediaLibrary, public IDeviceListerCb
virtual
ShowPtr
show
(
int64_t
id
)
const
override
;
std
::
shared_ptr
<
Show
>
createShow
(
const
std
::
string
&
name
);
virtual
Query
<
IShow
>
shows
(
const
QueryParameters
*
params
=
nullptr
)
const
override
;
virtual
MoviePtr
movie
(
int64_t
id
)
const
override
;
std
::
shared_ptr
<
Movie
>
createMovie
(
Media
&
media
);
...
...
src/Show.cpp
View file @
6da22990
...
...
@@ -177,4 +177,25 @@ std::shared_ptr<Show> Show::create( MediaLibraryPtr ml, const std::string& name
return
show
;
}
Query
<
IShow
>
Show
::
listAll
(
MediaLibraryPtr
ml
,
const
QueryParameters
*
params
)
{
std
::
string
req
=
"FROM "
+
policy
::
ShowTable
::
Name
+
" ORDER BY "
;
SortingCriteria
sort
=
params
!=
nullptr
?
params
->
sort
:
SortingCriteria
::
Default
;
switch
(
sort
)
{
case
SortingCriteria
::
ReleaseDate
:
req
+=
"release_date"
;
break
;
case
SortingCriteria
::
Default
:
case
SortingCriteria
::
Alpha
:
default:
req
+=
"name"
;
break
;
}
if
(
params
!=
nullptr
&&
params
->
desc
==
true
)
req
+=
" DESC"
;
return
make_query
<
Show
,
IShow
>
(
ml
,
"*"
,
req
);
}
}
src/Show.h
View file @
6da22990
...
...
@@ -70,6 +70,8 @@ class Show : public IShow, public DatabaseHelpers<Show, policy::ShowTable>
static
void
createTable
(
sqlite
::
Connection
*
dbConnection
);
static
std
::
shared_ptr
<
Show
>
create
(
MediaLibraryPtr
ml
,
const
std
::
string
&
name
);
static
Query
<
IShow
>
listAll
(
MediaLibraryPtr
ml
,
const
QueryParameters
*
params
);
protected:
MediaLibraryPtr
m_ml
;
...
...
test/unittest/ShowTests.cpp
View file @
6da22990
...
...
@@ -199,6 +199,26 @@ TEST_F( Shows, SetEpisodeTvdbId )
ASSERT_EQ
(
episodes
[
0
]
->
tvdbId
(),
e
->
tvdbId
()
);
}
TEST_F
(
Shows
,
ListAll
)
{
auto
show1
=
ml
->
createShow
(
"aaaa"
);
auto
show2
=
ml
->
createShow
(
"zzzz"
);
auto
show3
=
ml
->
createShow
(
"pppp"
);
auto
shows
=
ml
->
shows
(
nullptr
)
->
all
();
ASSERT_EQ
(
3u
,
shows
.
size
()
);
ASSERT_EQ
(
show1
->
id
(),
shows
[
0
]
->
id
()
);
ASSERT_EQ
(
show3
->
id
(),
shows
[
1
]
->
id
()
);
ASSERT_EQ
(
show2
->
id
(),
shows
[
2
]
->
id
()
);
medialibrary
::
QueryParameters
params
{
SortingCriteria
::
Alpha
,
true
};
shows
=
ml
->
shows
(
&
params
)
->
all
();
ASSERT_EQ
(
3u
,
shows
.
size
()
);
ASSERT_EQ
(
show2
->
id
(),
shows
[
0
]
->
id
()
);
ASSERT_EQ
(
show3
->
id
(),
shows
[
1
]
->
id
()
);
ASSERT_EQ
(
show1
->
id
(),
shows
[
2
]
->
id
()
);
}
////////////////////////////////////////////////////
// Files links:
////////////////////////////////////////////////////
...
...
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