Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
VideoLAN
medialibrary
Commits
ca1d7d4f
Commit
ca1d7d4f
authored
May 11, 2014
by
Hugo Beauzée-Luyssen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ShowEpisode
parent
0f6d92e0
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
146 additions
and
19 deletions
+146
-19
CMakeLists.txt
CMakeLists.txt
+1
-0
include/IFile.h
include/IFile.h
+0
-1
include/ISHowEpisode.h
include/ISHowEpisode.h
+2
-2
src/Album.cpp
src/Album.cpp
+1
-1
src/AlbumTrack.cpp
src/AlbumTrack.cpp
+1
-1
src/File.cpp
src/File.cpp
+14
-8
src/File.h
src/File.h
+1
-1
src/Label.cpp
src/Label.cpp
+2
-2
src/Show.cpp
src/Show.cpp
+1
-1
src/ShowEpisode.cpp
src/ShowEpisode.cpp
+80
-0
src/ShowEpisode.h
src/ShowEpisode.h
+41
-0
src/SqliteTools.cpp
src/SqliteTools.cpp
+1
-1
src/SqliteTools.h
src/SqliteTools.h
+1
-1
No files found.
CMakeLists.txt
View file @
ca1d7d4f
...
...
@@ -24,6 +24,7 @@ list(APPEND SRC_LIST ${HEADERS_LIST}
src/Show.cpp
src/Label.cpp
src/AlbumTrack.cpp
src/ShowEpisode.cpp
)
find_package
(
Sqlite3 REQUIRED
)
...
...
include/IFile.h
View file @
ca1d7d4f
...
...
@@ -16,7 +16,6 @@ class IFile
virtual
~
IFile
()
{}
virtual
IAlbumTrack
*
albumTrack
()
=
0
;
virtual
const
std
::
string
&
artworkUrl
()
=
0
;
virtual
unsigned
int
duration
()
=
0
;
virtual
IShowEpisode
*
showEpisode
()
=
0
;
virtual
int
playCount
()
=
0
;
...
...
include/ISHowEpisode.h
View file @
ca1d7d4f
...
...
@@ -3,6 +3,8 @@
class
IShow
;
#include <string>
class
IShowEpisode
{
public:
...
...
@@ -14,9 +16,7 @@ class IShowEpisode
virtual
const
std
::
string
&
name
()
=
0
;
virtual
unsigned
int
seasonNuber
()
=
0
;
virtual
const
std
::
string
&
shortSummary
()
=
0
;
virtual
bool
shouldBeDisplayed
()
=
0
;
virtual
const
std
::
string
&
tvdbId
()
=
0
;
virtual
bool
isUnread
()
=
0
;
virtual
IShow
*
show
()
=
0
;
};
...
...
src/Album.cpp
View file @
ca1d7d4f
...
...
@@ -54,7 +54,7 @@ bool Album::CreateTable(sqlite3* dbConnection)
"id_album INTEGER PRIMARY KEY AUTOINCREMENT,"
"name TEXT, UNSIGNED INTEGER release_year, TEXT short_summary,"
"TEXT artwork_url, UNSIGNED INTEGER last_sync_date)"
;
return
SqliteTools
::
C
reateTable
(
dbConnection
,
req
);
return
SqliteTools
::
c
reateTable
(
dbConnection
,
req
);
}
Album
*
Album
::
fetch
(
sqlite3
*
dbConnection
,
unsigned
int
albumTrackId
)
...
...
src/AlbumTrack.cpp
View file @
ca1d7d4f
...
...
@@ -23,7 +23,7 @@ bool AlbumTrack::createTable(sqlite3* dbConnection)
"album_id UNSIGNED INTEGER NOT NULL,"
"FOREIGN KEY (album_id) REFERENCES Album(id_album) ON DELETE CASCADE"
")"
;
return
SqliteTools
::
C
reateTable
(
dbConnection
,
req
);
return
SqliteTools
::
c
reateTable
(
dbConnection
,
req
);
}
AlbumTrack
*
AlbumTrack
::
fetch
(
sqlite3
*
dbConnection
,
unsigned
int
idTrack
)
...
...
src/File.cpp
View file @
ca1d7d4f
#include <cassert>
#include "Album.h"
#include "AlbumTrack.h"
#include "File.h"
#include "Label.h"
#include "ShowEpisode.h"
#include "SqliteTools.h"
#include "Album.h"
File
::
File
(
sqlite3
*
dbConnection
,
sqlite3_stmt
*
stmt
)
:
m_dbConnection
(
dbConnection
)
...
...
@@ -17,6 +18,7 @@ File::File( sqlite3* dbConnection, sqlite3_stmt* stmt )
m_duration
=
sqlite3_column_int
(
stmt
,
2
);
m_albumTrackId
=
sqlite3_column_int
(
stmt
,
3
);
m_playCount
=
sqlite3_column_int
(
stmt
,
4
);
m_showEpisodeId
=
sqlite3_column_int
(
stmt
,
5
);
}
File
::
File
()
...
...
@@ -52,10 +54,6 @@ IAlbumTrack* File::albumTrack()
return
m_albumTrack
;
}
const
std
::
string
&
File
::
artworkUrl
()
{
}
unsigned
int
File
::
duration
()
{
return
m_duration
;
...
...
@@ -63,6 +61,12 @@ unsigned int File::duration()
IShowEpisode
*
File
::
showEpisode
()
{
if
(
m_showEpisode
==
NULL
&&
m_showEpisodeId
!=
0
)
{
const
char
*
req
=
"SELECT * FROM ShowEpisode WHERE id_episode = ?"
;
m_showEpisode
=
SqliteTools
::
fetchOne
<
ShowEpisode
>
(
m_dbConnection
,
req
,
m_showEpisodeId
);
}
return
m_showEpisode
;
}
std
::
vector
<
ILabel
*>
File
::
labels
()
...
...
@@ -79,7 +83,7 @@ std::vector<ILabel*> File::labels()
int
File
::
playCount
()
{
return
m_playCount
;
}
bool
File
::
CreateTable
(
sqlite3
*
connection
)
...
...
@@ -88,6 +92,8 @@ bool File::CreateTable(sqlite3* connection)
"id_media INTEGER PRIMARY KEY AUTOINCREMENT,"
"type INTEGER, duration UNSIGNED INTEGER,"
"album_track_id UNSIGNED INTEGER,"
"play_count UNSIGNED INTEGER)"
;
return
SqliteTools
::
CreateTable
(
connection
,
req
);
"play_count UNSIGNED INTEGER"
"show_episode_id UNSIGNED INTEGER"
")"
;
return
SqliteTools
::
createTable
(
connection
,
req
);
}
src/File.h
View file @
ca1d7d4f
...
...
@@ -26,7 +26,6 @@ class File : public IFile
bool
insert
(
sqlite3
*
dbConnection
);
virtual
IAlbumTrack
*
albumTrack
();
virtual
const
std
::
string
&
artworkUrl
();
virtual
unsigned
int
duration
();
virtual
IShowEpisode
*
showEpisode
();
virtual
std
::
vector
<
ILabel
*>
labels
();
...
...
@@ -43,6 +42,7 @@ class File : public IFile
unsigned
int
m_duration
;
unsigned
int
m_albumTrackId
;
unsigned
int
m_playCount
;
unsigned
int
m_showEpisodeId
;
// Auto fetched related properties
Album
*
m_album
;
...
...
src/Label.cpp
View file @
ca1d7d4f
...
...
@@ -34,7 +34,7 @@ bool Label::createTable(sqlite3* dbConnection)
"id_label INTEGER PRIMARY KEY AUTO INCREMENT, "
"name TEXT"
")"
;
if
(
SqliteTools
::
C
reateTable
(
dbConnection
,
req
)
)
if
(
SqliteTools
::
c
reateTable
(
dbConnection
,
req
)
)
return
false
;
req
=
"CREATE TABLE IF NOT EXISTS LabelFileRelation("
"id_label INTEGER,"
...
...
@@ -42,5 +42,5 @@ bool Label::createTable(sqlite3* dbConnection)
"PRIMARY KEY (id_label, id_file)"
"FOREIGN KEY(id_label) REFERENCES Label(id_label) ON DELETE CASCADE,"
"FOREIGN KEY(id_file) REFERENCES File(id_file) ON DELETE CASCADE);"
;
return
SqliteTools
::
C
reateTable
(
dbConnection
,
req
);
return
SqliteTools
::
c
reateTable
(
dbConnection
,
req
);
}
src/Show.cpp
View file @
ca1d7d4f
...
...
@@ -56,5 +56,5 @@ bool Show::CreateTable(sqlite3* dbConnection)
"id_show INTEGER PRIMARY KEY AUTOINCREMENT,"
"name TEXT, UNSIGNED INTEGER release_year, TEXT short_summary,"
"TEXT artwork_url, UNSIGNED INTEGER last_sync_date, TEXT tvdb_id)"
;
return
SqliteTools
::
C
reateTable
(
dbConnection
,
req
);
return
SqliteTools
::
c
reateTable
(
dbConnection
,
req
);
}
src/ShowEpisode.cpp
0 → 100644
View file @
ca1d7d4f
#include "ShowEpisode.h"
#include "SqliteTools.h"
#include "Show.h"
ShowEpisode
::
ShowEpisode
(
sqlite3
*
dbConnection
,
sqlite3_stmt
*
stmt
)
:
m_dbConnection
(
dbConnection
)
{
m_id
=
sqlite3_column_int
(
stmt
,
1
);
m_artworkUrl
=
(
const
char
*
)
sqlite3_column_text
(
stmt
,
2
);
m_episodeNumber
=
sqlite3_column_int
(
stmt
,
3
);
m_lastSyncDate
=
sqlite3_column_int
(
stmt
,
4
);
m_name
=
(
const
char
*
)
sqlite3_column_text
(
stmt
,
5
);
m_seasonNumber
=
sqlite3_column_int
(
stmt
,
6
);
m_shortSummary
=
(
const
char
*
)
sqlite3_column_text
(
stmt
,
7
);
m_tvdbId
=
(
const
char
*
)
sqlite3_column_text
(
stmt
,
8
);
m_showId
=
sqlite3_column_int
(
stmt
,
9
);
}
const
std
::
string
&
ShowEpisode
::
artworkUrl
()
{
return
m_artworkUrl
;
}
unsigned
int
ShowEpisode
::
episodeNumber
()
{
return
m_episodeNumber
;
}
time_t
ShowEpisode
::
lastSyncDate
()
{
return
m_lastSyncDate
;
}
const
std
::
string
&
ShowEpisode
::
name
()
{
return
m_name
;
}
unsigned
int
ShowEpisode
::
seasonNuber
()
{
return
m_seasonNumber
;
}
const
std
::
string
&
ShowEpisode
::
shortSummary
()
{
return
m_shortSummary
;
}
const
std
::
string
&
ShowEpisode
::
tvdbId
()
{
return
m_tvdbId
;
}
IShow
*
ShowEpisode
::
show
()
{
if
(
m_show
==
NULL
&&
m_showId
!=
0
)
{
const
char
*
req
=
"SELECT * FROM Show WHERE id_show = ?"
;
m_show
=
SqliteTools
::
fetchOne
<
Show
>
(
m_dbConnection
,
req
,
m_showId
);
}
return
m_show
;
}
bool
ShowEpisode
::
createTable
(
sqlite3
*
dbConnection
)
{
const
char
*
req
=
"CREATE TABLE IF NOT EXISTS ("
"id_episode INTEGER PRIMARY KEY AUTO INCREMENT,"
"artwork_url TEXT,"
"episode_number UNSIGNED INT,"
"last_sync_date UNSIGNED INT,"
"name TEXT,"
"season_number UNSIGNED INT,"
"episode_summary TEXT,"
"tvdb_id TEXT,"
"show_id UNSIGNED INT,"
"FOREIGN KEY(show_id) REFERENCES Show(id_show)"
")"
;
SqliteTools
::
createTable
(
dbConnection
,
req
);
}
src/ShowEpisode.h
0 → 100644
View file @
ca1d7d4f
#ifndef SHOWEPISODE_H
#define SHOWEPISODE_H
class
Show
;
#include <string>
#include <sqlite3.h>
#include "IShowEpisode.h"
class
ShowEpisode
:
public
IShowEpisode
{
public:
ShowEpisode
(
sqlite3
*
dbConnection
,
sqlite3_stmt
*
stmt
);
virtual
const
std
::
string
&
artworkUrl
();
virtual
unsigned
int
episodeNumber
();
virtual
time_t
lastSyncDate
();
virtual
const
std
::
string
&
name
();
virtual
unsigned
int
seasonNuber
();
virtual
const
std
::
string
&
shortSummary
();
virtual
const
std
::
string
&
tvdbId
();
virtual
IShow
*
show
();
static
bool
createTable
(
sqlite3
*
dbConnection
);
private:
sqlite3
*
m_dbConnection
;
unsigned
int
m_id
;
std
::
string
m_artworkUrl
;
unsigned
int
m_episodeNumber
;
time_t
m_lastSyncDate
;
std
::
string
m_name
;
unsigned
int
m_seasonNumber
;
std
::
string
m_shortSummary
;
std
::
string
m_tvdbId
;
unsigned
int
m_showId
;
Show
*
m_show
;
};
#endif // SHOWEPISODE_H
src/SqliteTools.cpp
View file @
ca1d7d4f
...
...
@@ -2,7 +2,7 @@
#include "SqliteTools.h"
bool
SqliteTools
::
C
reateTable
(
sqlite3
*
db
,
const
char
*
request
)
bool
SqliteTools
::
c
reateTable
(
sqlite3
*
db
,
const
char
*
request
)
{
sqlite3_stmt
*
stmt
;
int
res
=
sqlite3_prepare_v2
(
db
,
request
,
-
1
,
&
stmt
,
NULL
);
...
...
src/SqliteTools.h
View file @
ca1d7d4f
...
...
@@ -8,7 +8,7 @@
class
SqliteTools
{
public:
static
bool
C
reateTable
(
sqlite3
*
db
,
const
char
*
request
);
static
bool
c
reateTable
(
sqlite3
*
db
,
const
char
*
request
);
template
<
typename
T
,
typename
U
>
static
bool
fetchAll
(
sqlite3
*
dbConnection
,
const
char
*
req
,
unsigned
int
foreignKey
,
std
::
vector
<
U
*>*&
results
)
...
...
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