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

Media: Share the media listing code

parent 0054042f
......@@ -333,6 +333,12 @@ void Media::removeFile( File& file )
}));
}
std::vector<MediaPtr> Media::listAll( MediaLibraryPtr ml, IMedia::Type type )
{
static const std::string req = "SELECT * FROM " + policy::MediaTable::Name + " WHERE type = ? AND is_present = 1 ORDER BY title";
return DatabaseHelpers::fetchAll<IMedia>( ml, req, type );
}
unsigned int Media::id() const
{
return m_id;
......
......@@ -103,6 +103,7 @@ class Media : public IMedia, public DatabaseHelpers<Media, policy::MediaTable>
std::shared_ptr<File> addFile( const fs::IFile& fileFs, Folder& parentFolder, fs::IDirectory& parentFolderFs , IFile::Type type);
void removeFile( File& file );
static std::vector<MediaPtr> listAll( MediaLibraryPtr ml, Type type );
static std::vector<MediaPtr> search( MediaLibraryPtr ml, const std::string& title );
static std::vector<MediaPtr> fetchHistory( MediaLibraryPtr ml );
......
......@@ -228,14 +228,12 @@ void MediaLibrary::setVerbosity(LogLevel v)
std::vector<MediaPtr> MediaLibrary::audioFiles()
{
static const std::string req = "SELECT * FROM " + policy::MediaTable::Name + " WHERE type = ? AND is_present = 1 ORDER BY title";
return Media::fetchAll<IMedia>( this, req, IMedia::Type::AudioType );
return Media::listAll( this, IMedia::Type::AudioType );
}
std::vector<MediaPtr> MediaLibrary::videoFiles()
{
static const std::string req = "SELECT * FROM " + policy::MediaTable::Name + " WHERE type = ? AND is_present = 1 ORDER BY title";
return Media::fetchAll<IMedia>( this, req, IMedia::Type::VideoType );
return Media::listAll( this, IMedia::Type::VideoType );
}
std::shared_ptr<Media> MediaLibrary::addFile( const fs::IFile& fileFs, Folder& parentFolder, fs::IDirectory& parentFolderFs )
......
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