Commit afc732ff authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen
Browse files

Media: Remove artist field

parent 1269fd82
......@@ -71,7 +71,6 @@ class IMedia
virtual bool addLabel( LabelPtr label ) = 0;
virtual bool removeLabel( LabelPtr label ) = 0;
virtual MoviePtr movie() = 0;
virtual const std::string& artist() const = 0;
virtual std::vector<LabelPtr> labels() = 0;
virtual std::vector<VideoTrackPtr> videoTracks() = 0;
virtual std::vector<AudioTrackPtr> audioTracks() = 0;
......
......@@ -56,7 +56,6 @@ Media::Media( DBConnection dbConnection, sqlite::Row& row )
>> m_rating
>> m_showEpisodeId
>> m_mrl
>> m_artist
>> m_movieId
>> m_folderId
>> m_lastModificationDate
......@@ -120,19 +119,6 @@ bool Media::setAlbumTrack( AlbumTrackPtr albumTrack )
return true;
}
const std::string& Media::artist() const
{
return m_artist;
}
void Media::setArtist(const std::string& artist)
{
if ( m_artist == artist )
return;
m_artist = artist;
m_changed = true;
}
int64_t Media::duration() const
{
return m_duration;
......@@ -290,13 +276,13 @@ bool Media::save()
{
static const std::string req = "UPDATE " + policy::MediaTable::Name + " SET "
"type = ?, duration = ?, play_count = ?, progress = ?, rating = ?, show_episode_id = ?,"
"artist = ?, movie_id = ?, last_modification_date = ?, thumbnail = ?, parsed = ?,"
"movie_id = ?, last_modification_date = ?, thumbnail = ?, parsed = ?,"
"title = ? WHERE id_media = ?";
if ( m_changed == false )
return true;
if ( sqlite::Tools::executeUpdate( m_dbConnection, req, m_type, m_duration, m_playCount,
m_progress, m_rating,
sqlite::ForeignKey{ m_showEpisodeId }, m_artist,
sqlite::ForeignKey{ m_showEpisodeId },
sqlite::ForeignKey{ m_movieId }, m_lastModificationDate,
m_thumbnail, m_isParsed, m_title, m_id ) == false )
{
......@@ -366,7 +352,6 @@ bool Media::createTable( DBConnection connection )
"rating INTEGER DEFAULT -1,"
"show_episode_id UNSIGNED INTEGER,"
"mrl TEXT,"
"artist TEXT,"
"movie_id UNSIGNED INTEGER,"
"folder_id UNSIGNED INTEGER,"
"last_modification_date UNSIGNED INTEGER,"
......
......@@ -66,8 +66,6 @@ class Media : public IMedia, public DatabaseHelpers<Media, policy::MediaTable>
void setTitle( const std::string& title );
virtual AlbumTrackPtr albumTrack() override;
bool setAlbumTrack( AlbumTrackPtr albumTrack );
virtual const std::string& artist() const override;
void setArtist( const std::string& artist );
virtual int64_t duration() const override;
void setDuration( int64_t duration);
virtual std::shared_ptr<IShowEpisode> showEpisode() override;
......@@ -115,7 +113,6 @@ class Media : public IMedia, public DatabaseHelpers<Media, policy::MediaTable>
int m_rating;
unsigned int m_showEpisodeId;
std::string m_mrl;
std::string m_artist;
unsigned int m_movieId;
unsigned int m_folderId;
unsigned int m_lastModificationDate;
......
......@@ -189,7 +189,7 @@ bool VLCMetadataService::parseAudioFile( std::shared_ptr<Media> media, VLC::Medi
if ( cover.empty() == false )
media->setThumbnail( cover );
auto artists = handleArtists( media, vlcMedia );
auto artists = handleArtists( vlcMedia );
auto album = handleAlbum( media, vlcMedia, artists.first, artists.second );
if ( album == nullptr )
{
......@@ -344,7 +344,7 @@ std::shared_ptr<Album> VLCMetadataService::handleAlbum( std::shared_ptr<Media> m
/// The album artist as a first element
/// The track artist as a second element, if it differs from the album artist.
///
std::pair<std::shared_ptr<Artist>, std::shared_ptr<Artist>> VLCMetadataService::handleArtists( std::shared_ptr<Media> media, VLC::Media& vlcMedia ) const
std::pair<std::shared_ptr<Artist>, std::shared_ptr<Artist>> VLCMetadataService::handleArtists( VLC::Media& vlcMedia ) const
{
std::shared_ptr<Artist> albumArtist;
std::shared_ptr<Artist> artist;
......@@ -383,14 +383,6 @@ std::pair<std::shared_ptr<Artist>, std::shared_ptr<Artist>> VLCMetadataService::
}
}
if ( artistName.length() > 0 )
media->setArtist( artistName );
else if ( albumArtistName.length() > 0 )
{
// Always provide an artist, to avoid the user from having to fallback
// to the album artist by himself
media->setArtist( albumArtistName );
}
return {albumArtist, artist};
}
......
......@@ -55,7 +55,7 @@ private:
std::shared_ptr<Album> findAlbum(Media* media, VLC::Media& vlcMedia, const std::string& title, Artist* albumArtist ) const;
bool parseAudioFile( std::shared_ptr<Media> media, VLC::Media &vlcMedia ) const;
bool parseVideoFile( std::shared_ptr<Media> file, VLC::Media &media ) const;
std::pair<std::shared_ptr<Artist>, std::shared_ptr<Artist>> handleArtists( std::shared_ptr<Media> media, VLC::Media& vlcMedia ) const;
std::pair<std::shared_ptr<Artist>, std::shared_ptr<Artist>> handleArtists(VLC::Media& vlcMedia ) const;
std::shared_ptr<AlbumTrack> handleTrack(std::shared_ptr<Album> album, std::shared_ptr<Media> media, VLC::Media& vlcMedia , std::shared_ptr<Artist> artist) const;
bool link(std::shared_ptr<Media> media, std::shared_ptr<Album> album, std::shared_ptr<Artist> albumArtist, std::shared_ptr<Artist> artist ) const;
std::shared_ptr<Album> handleAlbum(std::shared_ptr<Media> media, VLC::Media& vlcMedia, std::shared_ptr<Artist> albumArtist , std::shared_ptr<Artist> artist) const;
......
......@@ -109,24 +109,6 @@ TEST_F( Medias, Duration )
ASSERT_EQ( f2->duration(), d );
}
TEST_F( Medias, Artist )
{
auto f = std::static_pointer_cast<Media>( ml->addFile( "media.avi" ) );
ASSERT_EQ( f->artist(), "" );
std::string newArtist( "Rage Against The Otters" );
f->setArtist( newArtist );
f->save();
ASSERT_EQ( f->artist(), newArtist );
Reload();
auto f2 = ml->media( f->id() );
ASSERT_EQ( f2->artist(), newArtist );
}
TEST_F( Medias, Thumbnail )
{
auto f = ml->addFile( "media.avi" );
......
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