Commit a21552ae authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

ShowEpisode: Remove title/name

It duplicates media.title
parent ae32bfcb
......@@ -35,7 +35,6 @@ class IShowEpisode
virtual int64_t id() const = 0;
virtual unsigned int episodeNumber() const = 0;
virtual const std::string& name() const = 0;
virtual unsigned int seasonNumber() const = 0;
virtual const std::string& shortSummary() const = 0;
virtual const std::string& tvdbId() const = 0;
......
......@@ -129,9 +129,9 @@ bool Show::setTvdbId( const std::string& tvdbId )
return true;
}
std::shared_ptr<ShowEpisode> Show::addEpisode( Media& media, const std::string& title, unsigned int episodeNumber)
std::shared_ptr<ShowEpisode> Show::addEpisode( Media& media, unsigned int episodeNumber)
{
auto episode = ShowEpisode::create( m_ml, media.id(), title, episodeNumber, m_id );
auto episode = ShowEpisode::create( m_ml, media.id(), episodeNumber, m_id );
media.setShowEpisode( episode );
media.save();
return episode;
......
......@@ -62,7 +62,7 @@ class Show : public IShow, public DatabaseHelpers<Show, policy::ShowTable>
bool setArtworkMrl( const std::string& artworkMrl );
virtual const std::string& tvdbId() const override;
bool setTvdbId( const std::string& summary );
std::shared_ptr<ShowEpisode> addEpisode( Media& media, const std::string& title, unsigned int episodeNumber );
std::shared_ptr<ShowEpisode> addEpisode( Media& media, unsigned int episodeNumber );
virtual Query<IShowEpisode> episodes() const override;
virtual uint32_t nbSeasons() const override;
virtual uint32_t nbEpisodes() const override;
......
......@@ -43,19 +43,18 @@ ShowEpisode::ShowEpisode( MediaLibraryPtr ml, sqlite::Row& row )
row >> m_id
>> m_mediaId
>> m_episodeNumber
>> m_name
>> m_seasonNumber
>> m_shortSummary
>> m_tvdbId
>> m_showId;
}
ShowEpisode::ShowEpisode( MediaLibraryPtr ml, int64_t mediaId, const std::string& name, unsigned int episodeNumber, int64_t showId )
ShowEpisode::ShowEpisode( MediaLibraryPtr ml, int64_t mediaId,
unsigned int episodeNumber, int64_t showId )
: m_ml( ml )
, m_id( 0 )
, m_mediaId( mediaId )
, m_episodeNumber( episodeNumber )
, m_name( name )
, m_seasonNumber( 0 )
, m_showId( showId )
{
......@@ -71,11 +70,6 @@ unsigned int ShowEpisode::episodeNumber() const
return m_episodeNumber;
}
const std::string& ShowEpisode::name() const
{
return m_name;
}
unsigned int ShowEpisode::seasonNumber() const
{
return m_seasonNumber;
......@@ -144,7 +138,6 @@ void ShowEpisode::createTable( sqlite::Connection* dbConnection )
"id_episode INTEGER PRIMARY KEY AUTOINCREMENT,"
"media_id UNSIGNED INTEGER NOT NULL,"
"episode_number UNSIGNED INT,"
"title TEXT,"
"season_number UNSIGNED INT,"
"episode_summary TEXT,"
"tvdb_id TEXT,"
......@@ -160,12 +153,13 @@ void ShowEpisode::createTable( sqlite::Connection* dbConnection )
sqlite::Tools::executeRequest( dbConnection, indexReq );
}
std::shared_ptr<ShowEpisode> ShowEpisode::create( MediaLibraryPtr ml, int64_t mediaId, const std::string& title, unsigned int episodeNumber, int64_t showId )
std::shared_ptr<ShowEpisode> ShowEpisode::create( MediaLibraryPtr ml, int64_t mediaId,
unsigned int episodeNumber, int64_t showId )
{
auto episode = std::make_shared<ShowEpisode>( ml, mediaId, title, episodeNumber, showId );
auto episode = std::make_shared<ShowEpisode>( ml, mediaId, episodeNumber, showId );
static const std::string req = "INSERT INTO " + policy::ShowEpisodeTable::Name
+ "(media_id, episode_number, title, show_id) VALUES(?, ? , ?, ?)";
if ( insert( ml, episode, req, mediaId, episodeNumber, title, showId ) == false )
+ "(media_id, episode_number, show_id) VALUES(?, ?, ?)";
if ( insert( ml, episode, req, mediaId, episodeNumber, showId ) == false )
return nullptr;
return episode;
}
......
......@@ -50,11 +50,10 @@ class ShowEpisode : public IShowEpisode, public DatabaseHelpers<ShowEpisode, pol
{
public:
ShowEpisode( MediaLibraryPtr ml, sqlite::Row& row );
ShowEpisode( MediaLibraryPtr ml, int64_t mediaId, const std::string& name, unsigned int episodeNumber, int64_t showId );
ShowEpisode( MediaLibraryPtr ml, int64_t mediaId, unsigned int episodeNumber, int64_t showId );
virtual int64_t id() const override;
virtual unsigned int episodeNumber() const override;
virtual const std::string& name() const override;
unsigned int seasonNumber() const override;
bool setSeasonNumber(unsigned int seasonNumber);
virtual const std::string& shortSummary() const override;
......@@ -65,7 +64,7 @@ class ShowEpisode : public IShowEpisode, public DatabaseHelpers<ShowEpisode, pol
virtual Query<IMedia> media() override;
static void createTable( sqlite::Connection* dbConnection );
static std::shared_ptr<ShowEpisode> create( MediaLibraryPtr ml, int64_t mediaId, const std::string& title, unsigned int episodeNumber, int64_t showId );
static std::shared_ptr<ShowEpisode> create( MediaLibraryPtr ml, int64_t mediaId, unsigned int episodeNumber, int64_t showId );
static ShowEpisodePtr fromMedia( MediaLibraryPtr ml, int64_t mediaId );
private:
......@@ -73,7 +72,6 @@ class ShowEpisode : public IShowEpisode, public DatabaseHelpers<ShowEpisode, pol
int64_t m_id;
int64_t m_mediaId;
unsigned int m_episodeNumber;
std::string m_name;
unsigned int m_seasonNumber;
std::string m_shortSummary;
std::string m_tvdbId;
......
......@@ -401,7 +401,7 @@ bool MetadataAnalyzer::parseVideoFile( IItem& item ) const
if ( episode != 0 )
{
std::shared_ptr<Show> s = std::static_pointer_cast<Show>( show );
s->addEpisode( *media, title, episode );
s->addEpisode( *media, episode );
}
}
else
......
......@@ -119,12 +119,11 @@ TEST_F( Shows, AddEpisode )
{
auto show = ml->createShow( "show" );
auto media = std::static_pointer_cast<Media>( ml->addMedia( "episode.avi" ) );
auto e = show->addEpisode( *media, "episode 1", 1 );
auto e = show->addEpisode( *media, 1 );
ASSERT_NE( e, nullptr );
ASSERT_EQ( e->episodeNumber(), 1u );
ASSERT_EQ( e->show(), show );
ASSERT_EQ( e->name(), "episode 1" );
auto episodes = show->episodes()->all();
ASSERT_EQ( episodes.size(), 1u );
......@@ -135,7 +134,7 @@ TEST_F( Shows, FetchShowFromEpisode )
{
auto s = ml->createShow( "show" );
auto f = std::static_pointer_cast<Media>( ml->addMedia( "file.avi" ) );
auto e = s->addEpisode( *f, "episode 1", 1 );
auto e = s->addEpisode( *f, 1 );
f->save();
auto e2 = f->showEpisode();
......@@ -156,7 +155,7 @@ TEST_F( Shows, SetEpisodeSeasonNumber )
{
auto show = ml->createShow( "show" );
auto media = std::static_pointer_cast<Media>( ml->addMedia( "episode.mkv" ) );
auto e = show->addEpisode( *media, "episode 1", 1 );
auto e = show->addEpisode( *media, 1 );
bool res = e->setSeasonNumber( 42 );
ASSERT_TRUE( res );
ASSERT_EQ( e->seasonNumber(), 42u );
......@@ -172,7 +171,7 @@ TEST_F( Shows, SetEpisodeSummary )
{
auto show = ml->createShow( "show" );
auto media = std::static_pointer_cast<Media>( ml->addMedia( "episode.mkv" ) );
auto e = show->addEpisode( *media, "episode 1", 1 );
auto e = show->addEpisode( *media, 1 );
bool res = e->setShortSummary( "Insert spoilers here" );
ASSERT_TRUE( res );
ASSERT_EQ( e->shortSummary(), "Insert spoilers here" );
......@@ -188,7 +187,7 @@ TEST_F( Shows, SetEpisodeTvdbId )
{
auto show = ml->createShow( "show" );
auto media = std::static_pointer_cast<Media>( ml->addMedia( "episode.mkv" ) );
auto e = show->addEpisode( *media, "episode 1", 1 );
auto e = show->addEpisode( *media, 1 );
bool res = e->setTvdbId( "TVDBID" );
ASSERT_TRUE( res );
ASSERT_EQ( e->tvdbId(), "TVDBID" );
......@@ -210,7 +209,7 @@ TEST_F( Shows, FileSetShowEpisode )
auto f = std::static_pointer_cast<Media>( ml->addMedia( "file.avi" ) );
ASSERT_EQ( f->showEpisode(), nullptr );
auto e = show->addEpisode( *f, "episode 1", 1 );
auto e = show->addEpisode( *f, 1 );
ASSERT_EQ( f->showEpisode(), e );
......@@ -219,6 +218,5 @@ TEST_F( Shows, FileSetShowEpisode )
f = ml->media( f->id() );
auto e2 = f->showEpisode();
ASSERT_NE( e2, nullptr );
ASSERT_EQ( e2->name(), "episode 1" );
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment