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
51658091
Commit
51658091
authored
Jun 29, 2018
by
Hugo Beauzée-Luyssen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show: Allow episodes to be searched
parent
231c688b
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
52 additions
and
0 deletions
+52
-0
include/medialibrary/IShow.h
include/medialibrary/IShow.h
+2
-0
src/Media.cpp
src/Media.cpp
+18
-0
src/Media.h
src/Media.h
+2
-0
src/Show.cpp
src/Show.cpp
+6
-0
src/Show.h
src/Show.h
+2
-0
test/unittest/ShowTests.cpp
test/unittest/ShowTests.cpp
+22
-0
No files found.
include/medialibrary/IShow.h
View file @
51658091
...
...
@@ -39,6 +39,8 @@ class IShow
virtual
const
std
::
string
&
artworkMrl
()
const
=
0
;
virtual
const
std
::
string
&
tvdbId
()
const
=
0
;
virtual
Query
<
IMedia
>
episodes
(
const
QueryParameters
*
params
=
nullptr
)
const
=
0
;
virtual
Query
<
IMedia
>
searchEpisodes
(
const
std
::
string
&
pattern
,
const
QueryParameters
*
params
=
nullptr
)
const
=
0
;
virtual
uint32_t
nbSeasons
()
const
=
0
;
virtual
uint32_t
nbEpisodes
()
const
=
0
;
};
...
...
src/Media.cpp
View file @
51658091
...
...
@@ -758,6 +758,24 @@ Query<IMedia> Media::searchGenreTracks(MediaLibraryPtr ml, const std::string& pa
File
::
Type
::
Main
,
Media
::
SubType
::
AlbumTrack
);
}
Query
<
IMedia
>
Media
::
searchShowEpisodes
(
MediaLibraryPtr
ml
,
const
std
::
string
&
pattern
,
int64_t
showId
,
const
QueryParameters
*
params
)
{
std
::
string
req
=
"FROM "
+
policy
::
MediaTable
::
Name
+
" m "
" INNER JOIN "
+
policy
::
FileTable
::
Name
+
" f ON m.id_media = f.media_id"
" INNER JOIN "
+
policy
::
ShowEpisodeTable
::
Name
+
" ep ON ep.media_id = m.id_media "
" WHERE"
" m.id_media IN (SELECT rowid FROM "
+
policy
::
MediaTable
::
Name
+
"Fts"
" WHERE "
+
policy
::
MediaTable
::
Name
+
"Fts MATCH '*' || ? || '*')"
" AND ep.show_id = ?"
" AND f.is_present = 1"
" AND f.type = ?"
" AND m.subtype = ?"
;
req
+=
sortRequest
(
params
);
return
make_query
<
Media
,
IMedia
>
(
ml
,
"m.*"
,
req
,
pattern
,
showId
,
File
::
Type
::
Main
,
Media
::
SubType
::
ShowEpisode
);
}
Query
<
IMedia
>
Media
::
fetchHistory
(
MediaLibraryPtr
ml
)
{
static
const
std
::
string
req
=
"FROM "
+
policy
::
MediaTable
::
Name
+
" WHERE last_played_date IS NOT NULL"
...
...
src/Media.h
View file @
51658091
...
...
@@ -135,6 +135,8 @@ class Media : public IMedia, public DatabaseHelpers<Media, policy::MediaTable>
int64_t
artistId
,
const
QueryParameters
*
params
);
static
Query
<
IMedia
>
searchGenreTracks
(
MediaLibraryPtr
ml
,
const
std
::
string
&
pattern
,
int64_t
genreId
,
const
QueryParameters
*
params
);
static
Query
<
IMedia
>
searchShowEpisodes
(
MediaLibraryPtr
ml
,
const
std
::
string
&
pattern
,
int64_t
showId
,
const
QueryParameters
*
params
);
static
Query
<
IMedia
>
fetchHistory
(
MediaLibraryPtr
ml
);
static
void
clearHistory
(
MediaLibraryPtr
ml
);
...
...
src/Show.cpp
View file @
51658091
...
...
@@ -162,6 +162,12 @@ Query<IMedia> Show::episodes( const QueryParameters* params ) const
return
make_query
<
Media
,
IMedia
>
(
m_ml
,
"*"
,
req
,
m_id
);
}
Query
<
IMedia
>
Show
::
searchEpisodes
(
const
std
::
string
&
pattern
,
const
QueryParameters
*
params
)
const
{
return
Media
::
searchShowEpisodes
(
m_ml
,
pattern
,
m_id
,
params
);
}
uint32_t
Show
::
nbSeasons
()
const
{
return
0
;
...
...
src/Show.h
View file @
51658091
...
...
@@ -64,6 +64,8 @@ class Show : public IShow, public DatabaseHelpers<Show, policy::ShowTable>
bool
setTvdbId
(
const
std
::
string
&
summary
);
std
::
shared_ptr
<
ShowEpisode
>
addEpisode
(
Media
&
media
,
unsigned
int
episodeNumber
);
virtual
Query
<
IMedia
>
episodes
(
const
QueryParameters
*
params
)
const
override
;
virtual
Query
<
IMedia
>
searchEpisodes
(
const
std
::
string
&
pattern
,
const
QueryParameters
*
params
=
nullptr
)
const
override
;
virtual
uint32_t
nbSeasons
()
const
override
;
virtual
uint32_t
nbEpisodes
()
const
override
;
...
...
test/unittest/ShowTests.cpp
View file @
51658091
...
...
@@ -269,3 +269,25 @@ TEST_F( Shows, FileSetShowEpisode )
ASSERT_NE
(
e2
,
nullptr
);
}
TEST_F
(
Shows
,
SearchEpisodes
)
{
auto
show1
=
ml
->
createShow
(
"Show1"
);
auto
show2
=
ml
->
createShow
(
"show2"
);
auto
m1
=
std
::
static_pointer_cast
<
Media
>
(
ml
->
addMedia
(
"episode.mkv"
)
);
m1
->
setTitleBuffered
(
"cute otters"
);
m1
->
setType
(
IMedia
::
Type
::
Video
);
auto
ep1
=
show1
->
addEpisode
(
*
m1
,
1
);
auto
m2
=
std
::
static_pointer_cast
<
Media
>
(
ml
->
addMedia
(
"other episode.mkv"
)
);
m2
->
setTitleBuffered
(
"fluffy otters"
);
m2
->
setType
(
IMedia
::
Type
::
Video
);
auto
ep2
=
show2
->
addEpisode
(
*
m2
,
1
);
auto
episodes
=
ml
->
searchVideo
(
"otters"
,
nullptr
)
->
all
();
ASSERT_EQ
(
2u
,
episodes
.
size
()
);
episodes
=
show1
->
searchEpisodes
(
"otters"
,
nullptr
)
->
all
();
ASSERT_EQ
(
1u
,
episodes
.
size
()
);
ASSERT_EQ
(
m1
->
id
(),
episodes
[
0
]
->
id
()
);
}
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