Kodi Documentation 22.0
Kodi is an open source media player and entertainment hub.
Loading...
Searching...
No Matches
CMusicDatabase Class Reference

Class to store and read tag information. More...

#include <MusicDatabase.h>

Inheritance diagram for CMusicDatabase:
CDatabase

Public Member Functions

 CMusicDatabase (void)
 
 ~CMusicDatabase (void) override
 
bool Open () override
 
bool CommitTransaction () override
 
void EmptyCache ()
 
void Clean ()
 
int Cleanup (CGUIDialogProgress *progressDialog=nullptr)
 
bool LookupCDDBInfo (bool bRequery=false)
 
void DeleteCDDBInfo ()
 
int AddSong (const int idSong, const CDateTime &dtDateNew, const int idAlbum, const std::string &strTitle, const std::string &strMusicBrainzTrackID, const std::string &strPathAndFileName, const std::string &strComment, const std::string &strMood, const std::string &strThumb, const std::string &artistDisp, const std::string &artistSort, const std::vector< std::string > &genres, int iTrack, int iDuration, const std::string &strReleaseDate, const std::string &strOrigReleaseDate, std::string &strDiscSubtitle, const int iTimesPlayed, int iStartOffset, int iEndOffset, const CDateTime &dtLastPlayed, float rating, int userrating, int votes, int iBPM, int iBitRate, int iSampleRate, int iChannels, const std::string &songVideoURL, const ReplayGain &replayGain)
 Add a song to the database.
 
bool GetSong (int idSong, CSong &song)
 
bool UpdateSong (CSong &song, bool bArtists=true, bool bArtistLinks=true)
 Update a song and all its nested entities (genres, artists, contributors)
 
int UpdateSong (int idSong, const std::string &strTitle, const std::string &strMusicBrainzTrackID, const std::string &strPathAndFileName, const std::string &strComment, const std::string &strMood, const std::string &strThumb, const std::string &artistDisp, const std::string &artistSort, const std::vector< std::string > &genres, int iTrack, int iDuration, const std::string &strReleaseDate, const std::string &strOrigReleaseDate, const std::string &strDiscSubtitle, int iTimesPlayed, int iStartOffset, int iEndOffset, const CDateTime &dtLastPlayed, float rating, int userrating, int votes, const ReplayGain &replayGain, int iBPM, int iBitRate, int iSampleRate, int iChannels, const std::string &songVideoURL)
 Update a song in the database.
 
bool GetSongByFileName (const std::string &strFileName, CSong &song, int64_t startOffset=0)
 
bool GetSongsByPath (const std::string &strPath, MAPSONGS &songmap, bool bAppendToMap=false)
 
bool Search (const std::string &search, CFileItemList &items)
 
bool RemoveSongsFromPath (const std::string &path, MAPSONGS &songmap, bool exact=true)
 
void CheckArtistLinksChanged ()
 
bool SetSongUserrating (const std::string &filePath, int userrating)
 
bool SetSongUserrating (int idSong, int userrating)
 
bool SetSongVotes (const std::string &filePath, int votes)
 
int GetSongByArtistAndAlbumAndTitle (const std::string &strArtist, const std::string &strAlbum, const std::string &strTitle)
 
bool AddAlbum (CAlbum &album, int idSource)
 Add an album and all its songs to the database.
 
bool UpdateAlbum (CAlbum &album)
 Update an album and all its nested entities (artists, songs etc)
 
int AddAlbum (const std::string &strAlbum, const std::string &strMusicBrainzAlbumID, const std::string &strReleaseGroupMBID, const std::string &strArtist, const std::string &strArtistSort, const std::string &strGenre, const std::string &strReleaseDate, const std::string &strOrigReleaseDate, bool bBoxedSet, const std::string &strRecordLabel, const std::string &strType, const std::string &strReleaseStatus, bool bCompilation, CAlbum::ReleaseType releaseType)
 Add an album to the database.
 
bool GetAlbum (int idAlbum, CAlbum &album, bool getSongs=true)
 retrieve an album, optionally with all songs.
 
int UpdateAlbum (int idAlbum, const std::string &strAlbum, const std::string &strMusicBrainzAlbumID, const std::string &strReleaseGroupMBID, const std::string &strArtist, const std::string &strArtistSort, const std::string &strGenre, const std::string &strMoods, const std::string &strStyles, const std::string &strThemes, const std::string &strReview, const std::string &strImage, const std::string &strLabel, const std::string &strType, const std::string &strReleaseStatus, float fRating, int iUserrating, int iVotes, const std::string &strReleaseDate, const std::string &strOrigReleaseDate, bool bBoxedSet, bool bCompilation, CAlbum::ReleaseType releaseType, bool bScrapedMBID)
 
bool ClearAlbumLastScrapedTime (int idAlbum)
 
bool HasAlbumBeenScraped (int idAlbum)
 
bool AddAudioBook (const CFileItem &item)
 
bool SetResumeBookmarkForAudioBook (const CFileItem &item, int bookmark)
 
bool GetResumeBookmarkForAudioBook (const CFileItem &item, int &bookmark)
 
bool InsideScannedPath (const std::string &path)
 Checks if the given path is inside a folder that has already been scanned into the library.
 
int GetAlbumIdByPath (const std::string &path)
 
bool GetAlbumFromSong (int idSong, CAlbum &album)
 
int GetAlbumByName (const std::string &strAlbum, const std::string &strArtist="")
 
int GetAlbumByName (const std::string &strAlbum, const std::vector< std::string > &artist)
 
bool GetMatchingMusicVideoAlbum (const std::string &strAlbum, const std::string &strArtist, int &idAlbum, std::string &strReview)
 
bool SearchAlbumsByArtistName (const std::string &strArtist, CFileItemList &items)
 
int GetAlbumByMatch (const CAlbum &album)
 
std::string GetAlbumById (int id)
 
std::string GetAlbumDiscTitle (int idAlbum, int idDisc)
 
bool SetAlbumUserrating (const int idAlbum, int userrating)
 
int GetAlbumDiscsCount (int idAlbum)
 
bool UpdateArtist (const CArtist &artist)
 
int AddArtist (const std::string &strArtist, const std::string &strMusicBrainzArtistID, const std::string &strSortName, bool bScrapedMBID=false)
 
int AddArtist (const std::string &strArtist, const std::string &strMusicBrainzArtistID, bool bScrapedMBID=false)
 
bool GetArtist (int idArtist, CArtist &artist, bool fetchAll=false)
 
bool GetArtistExists (int idArtist)
 
int GetLastArtist ()
 
int GetArtistFromMBID (const std::string &strMusicBrainzArtistID, std::string &artistname)
 
int UpdateArtist (int idArtist, const std::string &strArtist, const std::string &strSortName, const std::string &strMusicBrainzArtistID, bool bScrapedMBID, const std::string &strType, const std::string &strGender, const std::string &strDisambiguation, const std::string &strBorn, const std::string &strFormed, const std::string &strGenres, const std::string &strMoods, const std::string &strStyles, const std::string &strInstruments, const std::string &strBiography, const std::string &strDied, const std::string &strDisbanded, const std::string &strYearsActive, const std::string &strImage)
 
bool UpdateArtistScrapedMBID (int idArtist, const std::string &strMusicBrainzArtistID)
 
bool GetTranslateBlankArtist ()
 
void SetTranslateBlankArtist (bool translate)
 
bool HasArtistBeenScraped (int idArtist)
 
bool ClearArtistLastScrapedTime (int idArtist)
 
int AddArtistDiscography (int idArtist, const CDiscoAlbum &discoAlbum)
 
bool DeleteArtistDiscography (int idArtist)
 
bool GetArtistDiscography (int idArtist, CFileItemList &items)
 
bool AddArtistVideoLinks (const CArtist &artist)
 
bool DeleteArtistVideoLinks (const int idArtist)
 
std::string GetArtistById (int id)
 
int GetArtistByName (const std::string &strArtist)
 
int GetArtistByMatch (const CArtist &artist)
 
bool GetArtistFromSong (int idSong, CArtist &artist)
 
bool IsSongArtist (int idSong, int idArtist)
 
bool IsSongAlbumArtist (int idSong, int idArtist)
 
std::string GetRoleById (int id)
 
bool UpdateArtistSortNames (int idArtist=-1)
 Propagate artist sort name into the concatenated artist sort name strings held for songs and albums.
 
int AddPath (const std::string &strPath)
 
bool GetPaths (std::set< std::string > &paths)
 
bool SetPathHash (const std::string &path, const std::string &hash)
 
bool GetPathHash (const std::string &path, std::string &hash)
 
bool GetAlbumPaths (int idAlbum, std::vector< std::pair< std::string, int > > &paths)
 
bool GetAlbumPath (int idAlbum, std::string &basePath)
 
int GetDiscnumberForPathID (int idPath)
 
bool GetOldArtistPath (int idArtist, std::string &path)
 
bool GetArtistPath (const CArtist &artist, std::string &path)
 
bool GetAlbumFolder (const CAlbum &album, const std::string &strAlbumPath, std::string &strFolder)
 
bool GetArtistFolderName (const CArtist &artist, std::string &strFolder)
 
bool GetArtistFolderName (const std::string &strArtist, const std::string &strMusicBrainzArtistID, std::string &strFolder)
 
bool UpdateSources ()
 
int AddSource (const std::string &strName, const std::string &strMultipath, const std::vector< std::string > &vecPaths, int id=-1)
 
int UpdateSource (const std::string &strOldName, const std::string &strName, const std::string &strMultipath, const std::vector< std::string > &vecPaths)
 
bool RemoveSource (const std::string &strName)
 
int GetSourceFromPath (const std::string &strPath)
 
bool AddAlbumSource (int idAlbum, int idSource)
 
bool AddAlbumSources (int idAlbum, const std::string &strPath)
 
bool DeleteAlbumSources (int idAlbum)
 
bool GetSources (CFileItemList &items)
 
bool GetSourcesByArtist (int idArtist, CFileItem *item)
 
bool GetSourcesByAlbum (int idAlbum, CFileItem *item)
 
bool GetSourcesBySong (int idSong, const std::string &strPath, CFileItem *item)
 
int GetSourceByName (const std::string &strSource)
 
std::string GetSourceById (int id)
 
int AddGenre (std::string &strGenre)
 
std::string GetGenreById (int id)
 
int GetGenreByName (const std::string &strGenre)
 
bool AddAlbumArtist (int idArtist, int idAlbum, const std::string &strArtist, int iOrder)
 
bool GetAlbumsByArtist (int idArtist, std::vector< int > &albums)
 
bool GetArtistsByAlbum (int idAlbum, CFileItem *item)
 
bool GetArtistsByAlbum (int idAlbum, std::vector< std::string > &artistIDs)
 
bool DeleteAlbumArtistsByAlbum (int idAlbum)
 
int AddRole (const std::string &strRole)
 
bool AddSongArtist (int idArtist, int idSong, const std::string &strRole, const std::string &strArtist, int iOrder)
 
bool AddSongArtist (int idArtist, int idSong, int idRole, const std::string &strArtist, int iOrder)
 
int AddSongContributor (int idSong, const std::string &strRole, const std::string &strArtist, const std::string &strSort)
 
void AddSongContributors (int idSong, const VECMUSICROLES &contributors, const std::string &strSort)
 
int GetRoleByName (const std::string &strRole)
 
bool GetRolesByArtist (int idArtist, CFileItem *item)
 
bool GetSongsByArtist (int idArtist, std::vector< int > &songs)
 
bool GetArtistsBySong (int idSong, std::vector< int > &artists)
 
bool DeleteSongArtistsBySong (int idSong)
 
bool AddSongGenres (int idSong, const std::vector< std::string > &genres)
 
bool GetGenresBySong (int idSong, std::vector< int > &genres)
 
bool GetGenresByAlbum (int idAlbum, CFileItem *item)
 
bool GetGenresByArtist (int idArtist, CFileItem *item)
 
bool GetIsAlbumArtist (int idArtist, CFileItem *item)
 
bool GetTop100 (const std::string &strBaseDir, CFileItemList &items)
 
bool GetTop100Albums (VECALBUMS &albums)
 
bool GetTop100AlbumSongs (const std::string &strBaseDir, CFileItemList &item)
 
bool GetRecentlyAddedAlbums (VECALBUMS &albums, unsigned int limit=0)
 
bool GetRecentlyAddedAlbumSongs (const std::string &strBaseDir, CFileItemList &item, unsigned int limit=0)
 
bool GetRecentlyPlayedAlbums (VECALBUMS &albums)
 
bool GetRecentlyPlayedAlbumSongs (const std::string &strBaseDir, CFileItemList &item)
 
int GetCompilationAlbumsCount ()
 
bool IsAlbumBoxset (int idAlbum)
 
int GetBoxsetsCount ()
 
int GetSinglesCount ()
 
int GetArtistCountForRole (int role)
 
int GetArtistCountForRole (const std::string &strRole)
 
void IncrementPlayCount (const CFileItem &item)
 Increment the playcount of an item Increments the playcount and updates the last played date.
 
bool CleanupOrphanedItems ()
 
bool GetGenresNav (const std::string &strBaseDir, CFileItemList &items, const Filter &filter=Filter(), bool countOnly=false)
 
bool GetSourcesNav (const std::string &strBaseDir, CFileItemList &items, const Filter &filter=Filter(), bool countOnly=false)
 
bool GetYearsNav (const std::string &strBaseDir, CFileItemList &items, const Filter &filter=Filter())
 
bool GetRolesNav (const std::string &strBaseDir, CFileItemList &items, const Filter &filter=Filter())
 
bool GetArtistsNav (const std::string &strBaseDir, CFileItemList &items, bool albumArtistsOnly=false, int idGenre=-1, int idAlbum=-1, int idSong=-1, const Filter &filter=Filter(), const SortDescription &sortDescription=SortDescription(), bool countOnly=false)
 
bool GetCommonNav (const std::string &strBaseDir, const std::string &table, const std::string &labelField, CFileItemList &items, const Filter &filter, bool countOnly)
 
bool GetAlbumTypesNav (const std::string &strBaseDir, CFileItemList &items, const Filter &filter=Filter(), bool countOnly=false)
 
bool GetMusicLabelsNav (const std::string &strBaseDir, CFileItemList &items, const Filter &filter=Filter(), bool countOnly=false)
 
bool GetAlbumsNav (const std::string &strBaseDir, CFileItemList &items, int idGenre=-1, int idArtist=-1, const Filter &filter=Filter(), const SortDescription &sortDescription=SortDescription(), bool countOnly=false)
 
bool GetDiscsNav (const std::string &strBaseDir, CFileItemList &items, int idAlbum, const Filter &filter=Filter(), const SortDescription &sortDescription=SortDescription(), bool countOnly=false)
 
bool GetAlbumsByYear (const std::string &strBaseDir, CFileItemList &items, int year)
 
bool GetSongsNav (const std::string &strBaseDir, CFileItemList &items, int idGenre, int idArtist, int idAlbum, const SortDescription &sortDescription=SortDescription())
 
bool GetSongsByYear (const std::string &baseDir, CFileItemList &items, int year)
 
bool GetSongsByWhere (const std::string &baseDir, const Filter &filter, CFileItemList &items, const SortDescription &sortDescription=SortDescription())
 
bool GetSongsFullByWhere (const std::string &baseDir, const Filter &filter, CFileItemList &items, const SortDescription &sortDescription=SortDescription(), bool artistData=false)
 
bool GetAlbumsByWhere (const std::string &baseDir, const Filter &filter, CFileItemList &items, const SortDescription &sortDescription=SortDescription(), bool countOnly=false)
 
bool GetDiscsByWhere (const std::string &baseDir, const Filter &filter, CFileItemList &items, const SortDescription &sortDescription=SortDescription(), bool countOnly=false)
 
bool GetDiscsByWhere (CMusicDbUrl &musicUrl, const Filter &filter, CFileItemList &items, const SortDescription &sortDescription=SortDescription(), bool countOnly=false)
 
bool GetArtistsByWhere (const std::string &strBaseDir, const Filter &filter, CFileItemList &items, const SortDescription &sortDescription=SortDescription(), bool countOnly=false)
 
int GetDiscsCount (const std::string &baseDir, const Filter &filter=Filter())
 
int GetSongsCount (const Filter &filter=Filter())
 
bool GetFilter (CDbUrl &musicUrl, Filter &filter, SortDescription &sorting) override
 
int GetOrderFilter (const std::string &type, const SortDescription &sorting, Filter &filter)
 
unsigned int GetRandomSongIDs (const Filter &filter, std::vector< std::pair< int, int > > &songIDs)
 Gets song IDs in random order that match the filter criteria.
 
bool GetGenresJSON (CFileItemList &items, bool bSources=false)
 
bool GetArtistsByWhereJSON (const std::set< std::string > &fields, const std::string &baseDir, CVariant &result, int &total, const SortDescription &sortDescription=SortDescription())
 
bool GetAlbumsByWhereJSON (const std::set< std::string > &fields, const std::string &baseDir, CVariant &result, int &total, const SortDescription &sortDescription=SortDescription())
 
bool GetSongsByWhereJSON (const std::set< std::string > &fields, const std::string &baseDir, CVariant &result, int &total, const SortDescription &sortDescription=SortDescription())
 
bool SetScraper (int id, const CONTENT_TYPE &content, const ADDON::ScraperPtr &scraper)
 
bool SetScraperAll (const std::string &strBaseDir, const ADDON::ScraperPtr &scraper)
 
bool GetScraper (int id, const CONTENT_TYPE &content, ADDON::ScraperPtr &scraper)
 
bool ScraperInUse (const std::string &scraperID) const
 Check whether a given scraper is in use.
 
bool GetItems (const std::string &strBaseDir, CFileItemList &items, const Filter &filter=Filter(), const SortDescription &sortDescription=SortDescription())
 
bool GetItems (const std::string &strBaseDir, const std::string &itemType, CFileItemList &items, const Filter &filter=Filter(), const SortDescription &sortDescription=SortDescription())
 
std::string GetItemById (const std::string &itemType, int id)
 
void ExportToXML (const CLibExportSettings &settings, CGUIDialogProgress *progressDialog=nullptr)
 
bool ExportSongHistory (TiXmlNode *pNode, CGUIDialogProgress *progressDialog=nullptr)
 
void ImportFromXML (const std::string &xmlFile, CGUIDialogProgress *progressDialog=nullptr)
 
bool ImportSongHistory (const std::string &xmlFile, const int total, CGUIDialogProgress *progressDialog=nullptr)
 
void SetPropertiesForFileItem (CFileItem &item)
 
void SetItemUpdated (int mediaId, const std::string &mediaType)
 
void SetArtForItem (int mediaId, const std::string &mediaType, const std::string &artType, const std::string &url)
 Sets art for a database item. Sets a single piece of art for a database item.
 
void SetArtForItem (int mediaId, const std::string &mediaType, const std::map< std::string, std::string > &art)
 Sets art for a database item. Sets multiple pieces of art for a database item.
 
bool GetArtForItem (int songId, int albumId, int artistId, bool bPrimaryArtist, std::vector< ArtForThumbLoader > &art)
 Fetch all related art for a database item. Fetches multiple pieces of art for a database item including that for related media types Given song id art for the related album, artist(s) and albumartist(s) will also be fetched, looking up the album and artist when ids are not provided. Given album id (and not song id) art for the related artist(s) will also be fetched, looking up the artist(s) when id are not provided.
 
bool GetArtForItem (int mediaId, const std::string &mediaType, std::map< std::string, std::string > &art)
 Fetch art for a database item. Fetches multiple pieces of art for a database item.
 
std::string GetArtForItem (int mediaId, const std::string &mediaType, const std::string &artType)
 Fetch art for a database item. Fetches a single piece of art for a database item.
 
bool RemoveArtForItem (int mediaId, const MediaType &mediaType, const std::string &artType)
 Remove art for a database item. Removes a single piece of art for a database item.
 
bool RemoveArtForItem (int mediaId, const MediaType &mediaType, const std::set< std::string > &artTypes)
 Remove art for a database item. Removes multiple pieces of art for a database item.
 
bool GetArtTypes (const MediaType &mediaType, std::vector< std::string > &artTypes)
 Fetch the distinct types of art held in the database for a type of media.
 
std::vector< std::string > GetAvailableArtTypesForItem (int mediaId, const MediaType &mediaType)
 Fetch the distinct types of available-but-unassigned art held in the database for a specific media item.
 
std::vector< CScraperUrl::SUrlEntryGetAvailableArtForItem (int mediaId, const MediaType &mediaType, const std::string &artType)
 Fetch the list of available-but-unassigned art URLs held in the database for a specific media item and art type.
 
virtual int GetMusicNeedsTagScan ()
 Check if music files need all tags rescanning regardless of file being unchanged because the tag processing has changed (which may happen without db version changes) since they where last scanned.
 
void SetMusicNeedsTagScan (int version)
 Set minimum version number of db needed when tag data scanned from music files.
 
void SetMusicTagScanVersion (int version=0)
 Set the version number of tag data.
 
std::string GetLibraryLastUpdated ()
 
void SetLibraryLastUpdated ()
 
std::string GetLibraryLastCleaned ()
 
void SetLibraryLastCleaned ()
 
std::string GetArtistLinksUpdated ()
 
void SetArtistLinksUpdated ()
 
std::string GetGenresLastAdded ()
 
std::string GetSongsLastAdded ()
 
std::string GetAlbumsLastAdded ()
 
std::string GetArtistsLastAdded ()
 
std::string GetSongsLastModified ()
 
std::string GetAlbumsLastModified ()
 
std::string GetArtistsLastModified ()
 
std::vector< std::string > GetUsedImages (const std::vector< std::string > &imagesToCheck) const
 Check the passed in list of images if used in this database. Used to clean the image cache.
 
- Public Member Functions inherited from CDatabase
 CDatabase ()
 
virtual ~CDatabase (void)
 
bool IsOpen ()
 
virtual void Close ()
 
bool Compress (bool bForce=true)
 
void Interrupt ()
 
bool Open (const DatabaseSettings &db)
 
void BeginTransaction ()
 
void RollbackTransaction ()
 
void CopyDB (const std::string &latestDb)
 
void DropAnalytics ()
 
std::string PrepareSQL (std::string strStmt,...) const
 
std::string GetSingleValue (const std::string &strTable, const std::string &strColumn, const std::string &strWhereClause=std::string(), const std::string &strOrderBy=std::string()) const
 Get a single value from a table.
 
std::string GetSingleValue (const std::string &query) const
 
std::string GetSingleValue (const std::string &query, const std::unique_ptr< dbiplus::Dataset > &ds) const
 Get a single value from a query on a dataset.
 
int GetSingleValueInt (const std::string &strTable, const std::string &strColumn, const std::string &strWhereClause=std::string(), const std::string &strOrderBy=std::string()) const
 Get a single integer value from a table.
 
int GetSingleValueInt (const std::string &query) const
 
int GetSingleValueInt (const std::string &query, const std::unique_ptr< dbiplus::Dataset > &ds) const
 Get a single integer value from a query on a dataset.
 
bool DeleteValues (const std::string &strTable, const Filter &filter=Filter())
 Delete values from a table.
 
bool ExecuteQuery (const std::string &strQuery)
 Execute a query that does not return any result. Note that if BeginMultipleExecute() has been called, the query will be queued until CommitMultipleExecute() is called.
 
bool ResultQuery (const std::string &strQuery) const
 Execute a query that returns a result.
 
bool BeginMultipleExecute ()
 Start a multiple execution queue. Any ExecuteQuery() function following this call will be queued rather than executed until CommitMultipleExecute() is performed. NOTE: Queries that rely on any queued execute query will not function as expected during this period!
 
bool CommitMultipleExecute ()
 Commit the multiple execution queue to the database. Queries are performed within a transaction, and the transaction is rolled back should any one query fail.
 
bool QueueInsertQuery (const std::string &strQuery)
 Put an INSERT or REPLACE query in the queue.
 
bool CommitInsertQueries ()
 Commit all queries in the queue.
 
size_t GetInsertQueriesCount ()
 Get the number of INSERT queries in the queue.
 
bool QueueDeleteQuery (const std::string &strQuery)
 Put a DELETE query in the queue.
 
bool CommitDeleteQueries ()
 Commit all queued DELETE queries.
 
size_t GetDeleteQueriesCount ()
 Get the number of DELETE queries in the queue.
 
virtual bool BuildSQL (const std::string &strBaseDir, const std::string &strQuery, Filter &filter, std::string &strSQL, CDbUrl &dbUrl)
 
virtual bool BuildSQL (const std::string &strBaseDir, const std::string &strQuery, Filter &filter, std::string &strSQL, CDbUrl &dbUrl, SortDescription &sorting)
 
bool Connect (const std::string &dbName, const DatabaseSettings &db, bool create)
 

Static Public Member Functions

static void SetPropertiesFromArtist (CFileItem &item, const CArtist &artist)
 
static void SetPropertiesFromAlbum (CFileItem &item, const CAlbum &album)
 

Protected Member Functions

void CreateTables () override
 
void CreateAnalytics () override
 
int GetMinSchemaVersion () const override
 
int GetSchemaVersion () const override
 
const char * GetBaseDBName () const override
 
- Protected Member Functions inherited from CDatabase
void Split (const std::string &strFileNameAndPath, std::string &strPath, std::string &strFileName)
 
bool CreateDatabase ()
 Create database tables and analytics as needed. Calls CreateTables() and CreateAnalytics() on child classes.
 
int GetDBVersion ()
 
bool BuildSQL (const std::string &strQuery, const Filter &filter, std::string &strSQL) const
 

Protected Attributes

std::map< std::string, intm_genreCache
 
std::map< std::string, intm_pathCache
 
- Protected Attributes inherited from CDatabase
bool m_sqlite
 whether we use sqlite (defaults to true)
 
std::unique_ptr< dbiplus::Databasem_pDB
 
std::unique_ptr< dbiplus::Datasetm_pDS
 
std::unique_ptr< dbiplus::Datasetm_pDS2
 
const CProfileManagerm_profileManager
 

Friends

class DatabaseUtils
 
class TestDatabaseUtilsHelper
 

Detailed Description

Class to store and read tag information.

CMusicDatabase can be used to read and store tag information for faster access. It is based on sqlite (http://www.sqlite.org).

Here is the database layout:

See also
CAlbum, CSong, VECSONGS, CMapSong, VECARTISTS, VECALBUMS, VECGENRES

Constructor & Destructor Documentation

◆ CMusicDatabase()

CMusicDatabase::CMusicDatabase ( void )

◆ ~CMusicDatabase()

CMusicDatabase::~CMusicDatabase ( void )
override

Member Function Documentation

◆ AddAlbum() [1/2]

bool CMusicDatabase::AddAlbum ( CAlbum & album,
int idSource )

Add an album and all its songs to the database.

Parameters
albumthe album to add
idSourcethe music source id
Returns
the id of the album

◆ AddAlbum() [2/2]

int CMusicDatabase::AddAlbum ( const std::string & strAlbum,
const std::string & strMusicBrainzAlbumID,
const std::string & strReleaseGroupMBID,
const std::string & strArtist,
const std::string & strArtistSort,
const std::string & strGenre,
const std::string & strReleaseDate,
const std::string & strOrigReleaseDate,
bool bBoxedSet,
const std::string & strRecordLabel,
const std::string & strType,
const std::string & strReleaseStatus,
bool bCompilation,
CAlbum::ReleaseType releaseType )

Add an album to the database.

Parameters
strAlbumthe album title
strMusicBrainzAlbumIDthe Musicbrainz Id
strArtistthe album artist name(s) display string
strArtistSortthe album artist name(s) sort string
strGenrethe album genre(s)
strReleaseDate[in] the release date of the album ISO8601 format
strOrigReleaseDate[in] the original release date of the album ISO8601 format
bBoxedSetif the album is a boxset
strRecordLabelthe recording label
strTypealbum type (Musicbrainz release type e.g. "Broadcast, Soundtrack, live"),
strReleaseStatus(see https://musicbrainz.org/doc/Release#Status)
bCompilationif the album is a compilation
releaseType"album" or "single"
Returns
the id of the album

◆ AddAlbumArtist()

bool CMusicDatabase::AddAlbumArtist ( int idArtist,
int idAlbum,
const std::string & strArtist,
int iOrder )

◆ AddAlbumSource()

bool CMusicDatabase::AddAlbumSource ( int idAlbum,
int idSource )

◆ AddAlbumSources()

bool CMusicDatabase::AddAlbumSources ( int idAlbum,
const std::string & strPath )

◆ AddArtist() [1/2]

int CMusicDatabase::AddArtist ( const std::string & strArtist,
const std::string & strMusicBrainzArtistID,
bool bScrapedMBID = false )

◆ AddArtist() [2/2]

int CMusicDatabase::AddArtist ( const std::string & strArtist,
const std::string & strMusicBrainzArtistID,
const std::string & strSortName,
bool bScrapedMBID = false )

◆ AddArtistDiscography()

int CMusicDatabase::AddArtistDiscography ( int idArtist,
const CDiscoAlbum & discoAlbum )

◆ AddArtistVideoLinks()

bool CMusicDatabase::AddArtistVideoLinks ( const CArtist & artist)

◆ AddAudioBook()

bool CMusicDatabase::AddAudioBook ( const CFileItem & item)

◆ AddGenre()

int CMusicDatabase::AddGenre ( std::string & strGenre)

◆ AddPath()

int CMusicDatabase::AddPath ( const std::string & strPath)

◆ AddRole()

int CMusicDatabase::AddRole ( const std::string & strRole)

◆ AddSong()

int CMusicDatabase::AddSong ( const int idSong,
const CDateTime & dtDateNew,
const int idAlbum,
const std::string & strTitle,
const std::string & strMusicBrainzTrackID,
const std::string & strPathAndFileName,
const std::string & strComment,
const std::string & strMood,
const std::string & strThumb,
const std::string & artistDisp,
const std::string & artistSort,
const std::vector< std::string > & genres,
int iTrack,
int iDuration,
const std::string & strReleaseDate,
const std::string & strOrigReleaseDate,
std::string & strDiscSubtitle,
const int iTimesPlayed,
int iStartOffset,
int iEndOffset,
const CDateTime & dtLastPlayed,
float rating,
int userrating,
int votes,
int iBPM,
int iBitRate,
int iSampleRate,
int iChannels,
const std::string & songVideoURL,
const ReplayGain & replayGain )

Add a song to the database.

Parameters
idSong[in] the original database ID of the song to reuse (-1 when new)
dtDateNew[in] the datetime the original ID was new
idAlbum[in] the database ID of the album for the song
strTitle[in] the title of the song (required to be non-empty)
strMusicBrainzTrackID[in] the MusicBrainz track ID of the song
strPathAndFileName[in] the path and filename to the song
strComment[in] the ids of the added songs
strMood[in] the mood of the added song
strThumb[in] the ids of the added songs
artistDisp[in] the assembled artist name(s) display string
artistSort[in] the artist name(s) sort string
genres[in] a vector of genres to which this song belongs
iTrack[in] the track number and disc number of the song
iDuration[in] the duration of the song
strReleaseDate[in] the release date of the song ISO8601 format
strOrigReleaseDate[in] the original release date of the song ISO8601 format
strDiscSubtitle[in] subtitle of a disc
iTimesPlayed[in] the number of times the song has been played
iStartOffset[in] the start offset of the song (when using a single audio file with a .cue)
iEndOffset[in] the end offset of the song (when using a single audio file with .cue)
dtLastPlayed[in] the time the song was last played
rating[in] a rating for the song
userrating[in] a userrating (my rating) for the song
votes[in] a vote counter for the song rating
songVideoURL[in] url to video of the song
replayGain[in] album and track replaygain and peak values
Returns
the id of the song

◆ AddSongArtist() [1/2]

bool CMusicDatabase::AddSongArtist ( int idArtist,
int idSong,
const std::string & strRole,
const std::string & strArtist,
int iOrder )

◆ AddSongArtist() [2/2]

bool CMusicDatabase::AddSongArtist ( int idArtist,
int idSong,
int idRole,
const std::string & strArtist,
int iOrder )

◆ AddSongContributor()

int CMusicDatabase::AddSongContributor ( int idSong,
const std::string & strRole,
const std::string & strArtist,
const std::string & strSort )

◆ AddSongContributors()

void CMusicDatabase::AddSongContributors ( int idSong,
const VECMUSICROLES & contributors,
const std::string & strSort )

◆ AddSongGenres()

bool CMusicDatabase::AddSongGenres ( int idSong,
const std::vector< std::string > & genres )

◆ AddSource()

int CMusicDatabase::AddSource ( const std::string & strName,
const std::string & strMultipath,
const std::vector< std::string > & vecPaths,
int id = -1 )

◆ CheckArtistLinksChanged()

void CMusicDatabase::CheckArtistLinksChanged ( )

◆ Clean()

void CMusicDatabase::Clean ( )

◆ Cleanup()

int CMusicDatabase::Cleanup ( CGUIDialogProgress * progressDialog = nullptr)

◆ CleanupOrphanedItems()

bool CMusicDatabase::CleanupOrphanedItems ( )

◆ ClearAlbumLastScrapedTime()

bool CMusicDatabase::ClearAlbumLastScrapedTime ( int idAlbum)

◆ ClearArtistLastScrapedTime()

bool CMusicDatabase::ClearArtistLastScrapedTime ( int idArtist)

◆ CommitTransaction()

bool CMusicDatabase::CommitTransaction ( )
overridevirtual

Reimplemented from CDatabase.

◆ CreateAnalytics()

void CMusicDatabase::CreateAnalytics ( )
overrideprotectedvirtual

Implements CDatabase.

◆ CreateTables()

void CMusicDatabase::CreateTables ( )
overrideprotectedvirtual

Implements CDatabase.

◆ DeleteAlbumArtistsByAlbum()

bool CMusicDatabase::DeleteAlbumArtistsByAlbum ( int idAlbum)

◆ DeleteAlbumSources()

bool CMusicDatabase::DeleteAlbumSources ( int idAlbum)

◆ DeleteArtistDiscography()

bool CMusicDatabase::DeleteArtistDiscography ( int idArtist)

◆ DeleteArtistVideoLinks()

bool CMusicDatabase::DeleteArtistVideoLinks ( const int idArtist)

◆ DeleteCDDBInfo()

void CMusicDatabase::DeleteCDDBInfo ( )

◆ DeleteSongArtistsBySong()

bool CMusicDatabase::DeleteSongArtistsBySong ( int idSong)

◆ EmptyCache()

void CMusicDatabase::EmptyCache ( )

◆ ExportSongHistory()

bool CMusicDatabase::ExportSongHistory ( TiXmlNode * pNode,
CGUIDialogProgress * progressDialog = nullptr )

◆ ExportToXML()

void CMusicDatabase::ExportToXML ( const CLibExportSettings & settings,
CGUIDialogProgress * progressDialog = nullptr )

◆ GetAlbum()

bool CMusicDatabase::GetAlbum ( int idAlbum,
CAlbum & album,
bool getSongs = true )

retrieve an album, optionally with all songs.

Parameters
idAlbumthe database id of the album.
album[out] the album to fill.
getSongswhether or not to retrieve songs, defaults to true.
Returns
true if the album is retrieved, false otherwise.

◆ GetAlbumById()

std::string CMusicDatabase::GetAlbumById ( int id)

◆ GetAlbumByMatch()

int CMusicDatabase::GetAlbumByMatch ( const CAlbum & album)

◆ GetAlbumByName() [1/2]

int CMusicDatabase::GetAlbumByName ( const std::string & strAlbum,
const std::string & strArtist = "" )

◆ GetAlbumByName() [2/2]

int CMusicDatabase::GetAlbumByName ( const std::string & strAlbum,
const std::vector< std::string > & artist )

◆ GetAlbumDiscsCount()

int CMusicDatabase::GetAlbumDiscsCount ( int idAlbum)

◆ GetAlbumDiscTitle()

std::string CMusicDatabase::GetAlbumDiscTitle ( int idAlbum,
int idDisc )

◆ GetAlbumFolder()

bool CMusicDatabase::GetAlbumFolder ( const CAlbum & album,
const std::string & strAlbumPath,
std::string & strFolder )

◆ GetAlbumFromSong()

bool CMusicDatabase::GetAlbumFromSong ( int idSong,
CAlbum & album )

◆ GetAlbumIdByPath()

int CMusicDatabase::GetAlbumIdByPath ( const std::string & path)

◆ GetAlbumPath()

bool CMusicDatabase::GetAlbumPath ( int idAlbum,
std::string & basePath )

◆ GetAlbumPaths()

bool CMusicDatabase::GetAlbumPaths ( int idAlbum,
std::vector< std::pair< std::string, int > > & paths )

◆ GetAlbumsByArtist()

bool CMusicDatabase::GetAlbumsByArtist ( int idArtist,
std::vector< int > & albums )

◆ GetAlbumsByWhere()

bool CMusicDatabase::GetAlbumsByWhere ( const std::string & baseDir,
const Filter & filter,
CFileItemList & items,
const SortDescription & sortDescription = SortDescription(),
bool countOnly = false )

◆ GetAlbumsByWhereJSON()

bool CMusicDatabase::GetAlbumsByWhereJSON ( const std::set< std::string > & fields,
const std::string & baseDir,
CVariant & result,
int & total,
const SortDescription & sortDescription = SortDescription() )

◆ GetAlbumsByYear()

bool CMusicDatabase::GetAlbumsByYear ( const std::string & strBaseDir,
CFileItemList & items,
int year )

◆ GetAlbumsLastAdded()

std::string CMusicDatabase::GetAlbumsLastAdded ( )

◆ GetAlbumsLastModified()

std::string CMusicDatabase::GetAlbumsLastModified ( )

◆ GetAlbumsNav()

bool CMusicDatabase::GetAlbumsNav ( const std::string & strBaseDir,
CFileItemList & items,
int idGenre = -1,
int idArtist = -1,
const Filter & filter = Filter(),
const SortDescription & sortDescription = SortDescription(),
bool countOnly = false )

◆ GetAlbumTypesNav()

bool CMusicDatabase::GetAlbumTypesNav ( const std::string & strBaseDir,
CFileItemList & items,
const Filter & filter = Filter(),
bool countOnly = false )

◆ GetArtForItem() [1/3]

std::string CMusicDatabase::GetArtForItem ( int mediaId,
const std::string & mediaType,
const std::string & artType )

Fetch art for a database item. Fetches a single piece of art for a database item.

Parameters
mediaIdthe id in the media (song/artist/album) table.
mediaTypethe type of media, which corresponds to the table the item resides in (song/artist/album).
artTypethe type of art to retrieve, eg "thumb", "fanart".
Returns
the original URL to the piece of art, if available.
See also
SetArtForItem

◆ GetArtForItem() [2/3]

bool CMusicDatabase::GetArtForItem ( int mediaId,
const std::string & mediaType,
std::map< std::string, std::string > & art )

Fetch art for a database item. Fetches multiple pieces of art for a database item.

Parameters
mediaIdthe id in the media (song/artist/album) table.
mediaTypethe type of media, which corresponds to the table the item resides in (song/artist/album).
art[out] a map of <type, url> where type is "thumb", "fanart", etc. and url is the original url of the art.
Returns
true if art is retrieved, false if no art is found.
See also
SetArtForItem

◆ GetArtForItem() [3/3]

bool CMusicDatabase::GetArtForItem ( int songId,
int albumId,
int artistId,
bool bPrimaryArtist,
std::vector< ArtForThumbLoader > & art )

Fetch all related art for a database item. Fetches multiple pieces of art for a database item including that for related media types Given song id art for the related album, artist(s) and albumartist(s) will also be fetched, looking up the album and artist when ids are not provided. Given album id (and not song id) art for the related artist(s) will also be fetched, looking up the artist(s) when id are not provided.

Parameters
songIdthe id in the song table, -1 when song art not being fetched
albumIdthe id in the album table, -1 when album art not being fetched
artistIdthe id in the artist table, -1 when artist not known
bPrimaryArtisttrue if art from only the first song artist or album artist is to be fetched
art[out] a vector, each element having media type e.g. "artist", "album" or "song", artType e.g. "thumb", "fanart", etc., prefix of "", "artist" or "albumartist" etc. giving the kind of artist relationship, and the original url of the art.
Returns
true if art is retrieved, false if no art is found.
See also
SetArtForItem

◆ GetArtist()

bool CMusicDatabase::GetArtist ( int idArtist,
CArtist & artist,
bool fetchAll = false )

◆ GetArtistById()

std::string CMusicDatabase::GetArtistById ( int id)

◆ GetArtistByMatch()

int CMusicDatabase::GetArtistByMatch ( const CArtist & artist)

◆ GetArtistByName()

int CMusicDatabase::GetArtistByName ( const std::string & strArtist)

◆ GetArtistCountForRole() [1/2]

int CMusicDatabase::GetArtistCountForRole ( const std::string & strRole)

◆ GetArtistCountForRole() [2/2]

int CMusicDatabase::GetArtistCountForRole ( int role)

◆ GetArtistDiscography()

bool CMusicDatabase::GetArtistDiscography ( int idArtist,
CFileItemList & items )

◆ GetArtistExists()

bool CMusicDatabase::GetArtistExists ( int idArtist)

◆ GetArtistFolderName() [1/2]

bool CMusicDatabase::GetArtistFolderName ( const CArtist & artist,
std::string & strFolder )

◆ GetArtistFolderName() [2/2]

bool CMusicDatabase::GetArtistFolderName ( const std::string & strArtist,
const std::string & strMusicBrainzArtistID,
std::string & strFolder )

◆ GetArtistFromMBID()

int CMusicDatabase::GetArtistFromMBID ( const std::string & strMusicBrainzArtistID,
std::string & artistname )

◆ GetArtistFromSong()

bool CMusicDatabase::GetArtistFromSong ( int idSong,
CArtist & artist )

◆ GetArtistLinksUpdated()

std::string CMusicDatabase::GetArtistLinksUpdated ( )

◆ GetArtistPath()

bool CMusicDatabase::GetArtistPath ( const CArtist & artist,
std::string & path )

◆ GetArtistsByAlbum() [1/2]

bool CMusicDatabase::GetArtistsByAlbum ( int idAlbum,
CFileItem * item )

◆ GetArtistsByAlbum() [2/2]

bool CMusicDatabase::GetArtistsByAlbum ( int idAlbum,
std::vector< std::string > & artistIDs )

◆ GetArtistsBySong()

bool CMusicDatabase::GetArtistsBySong ( int idSong,
std::vector< int > & artists )

◆ GetArtistsByWhere()

bool CMusicDatabase::GetArtistsByWhere ( const std::string & strBaseDir,
const Filter & filter,
CFileItemList & items,
const SortDescription & sortDescription = SortDescription(),
bool countOnly = false )

◆ GetArtistsByWhereJSON()

bool CMusicDatabase::GetArtistsByWhereJSON ( const std::set< std::string > & fields,
const std::string & baseDir,
CVariant & result,
int & total,
const SortDescription & sortDescription = SortDescription() )
Todo
: replace GetFilter to avoid exists as well as JOIn to albm_artist and song_artist tables

◆ GetArtistsLastAdded()

std::string CMusicDatabase::GetArtistsLastAdded ( )

◆ GetArtistsLastModified()

std::string CMusicDatabase::GetArtistsLastModified ( )

◆ GetArtistsNav()

bool CMusicDatabase::GetArtistsNav ( const std::string & strBaseDir,
CFileItemList & items,
bool albumArtistsOnly = false,
int idGenre = -1,
int idAlbum = -1,
int idSong = -1,
const Filter & filter = Filter(),
const SortDescription & sortDescription = SortDescription(),
bool countOnly = false )

◆ GetArtTypes()

bool CMusicDatabase::GetArtTypes ( const MediaType & mediaType,
std::vector< std::string > & artTypes )

Fetch the distinct types of art held in the database for a type of media.

Parameters
mediaTypethe type of media, which corresponds to the table the item resides in (song/artist/album).
artTypes[out] the types of art e.g. "thumb", "fanart", etc.
Returns
true if art is found, false if no art is found.

◆ GetAvailableArtForItem()

std::vector< CScraperUrl::SUrlEntry > CMusicDatabase::GetAvailableArtForItem ( int mediaId,
const MediaType & mediaType,
const std::string & artType )

Fetch the list of available-but-unassigned art URLs held in the database for a specific media item and art type.

Parameters
mediaIdthe id in the media (artist/album) table.
mediaTypecorresponds to the table the item resides in (artist/album).
artTypee.g. "thumb", "fanart", etc.
Returns
list of URLs

◆ GetAvailableArtTypesForItem()

std::vector< std::string > CMusicDatabase::GetAvailableArtTypesForItem ( int mediaId,
const MediaType & mediaType )

Fetch the distinct types of available-but-unassigned art held in the database for a specific media item.

Parameters
mediaIdthe id in the media (artist/album) table.
mediaTypethe type of media, which corresponds to the table the item resides in (artist/album).
Returns
the types of art e.g. "thumb", "fanart", etc.

◆ GetBaseDBName()

const char * CMusicDatabase::GetBaseDBName ( ) const
inlineoverrideprotectedvirtual

Implements CDatabase.

◆ GetBoxsetsCount()

int CMusicDatabase::GetBoxsetsCount ( )

◆ GetCommonNav()

bool CMusicDatabase::GetCommonNav ( const std::string & strBaseDir,
const std::string & table,
const std::string & labelField,
CFileItemList & items,
const Filter & filter,
bool countOnly )

◆ GetCompilationAlbumsCount()

int CMusicDatabase::GetCompilationAlbumsCount ( )

◆ GetDiscnumberForPathID()

int CMusicDatabase::GetDiscnumberForPathID ( int idPath)

◆ GetDiscsByWhere() [1/2]

bool CMusicDatabase::GetDiscsByWhere ( CMusicDbUrl & musicUrl,
const Filter & filter,
CFileItemList & items,
const SortDescription & sortDescription = SortDescription(),
bool countOnly = false )

◆ GetDiscsByWhere() [2/2]

bool CMusicDatabase::GetDiscsByWhere ( const std::string & baseDir,
const Filter & filter,
CFileItemList & items,
const SortDescription & sortDescription = SortDescription(),
bool countOnly = false )

◆ GetDiscsCount()

int CMusicDatabase::GetDiscsCount ( const std::string & baseDir,
const Filter & filter = Filter() )

◆ GetDiscsNav()

bool CMusicDatabase::GetDiscsNav ( const std::string & strBaseDir,
CFileItemList & items,
int idAlbum,
const Filter & filter = Filter(),
const SortDescription & sortDescription = SortDescription(),
bool countOnly = false )

◆ GetFilter()

bool CMusicDatabase::GetFilter ( CDbUrl & musicUrl,
Filter & filter,
SortDescription & sorting )
overridevirtual

Reimplemented from CDatabase.

◆ GetGenreById()

std::string CMusicDatabase::GetGenreById ( int id)

◆ GetGenreByName()

int CMusicDatabase::GetGenreByName ( const std::string & strGenre)

◆ GetGenresByAlbum()

bool CMusicDatabase::GetGenresByAlbum ( int idAlbum,
CFileItem * item )

◆ GetGenresByArtist()

bool CMusicDatabase::GetGenresByArtist ( int idArtist,
CFileItem * item )

◆ GetGenresBySong()

bool CMusicDatabase::GetGenresBySong ( int idSong,
std::vector< int > & genres )

◆ GetGenresJSON()

bool CMusicDatabase::GetGenresJSON ( CFileItemList & items,
bool bSources = false )

◆ GetGenresLastAdded()

std::string CMusicDatabase::GetGenresLastAdded ( )

◆ GetGenresNav()

bool CMusicDatabase::GetGenresNav ( const std::string & strBaseDir,
CFileItemList & items,
const Filter & filter = Filter(),
bool countOnly = false )

◆ GetIsAlbumArtist()

bool CMusicDatabase::GetIsAlbumArtist ( int idArtist,
CFileItem * item )

◆ GetItemById()

std::string CMusicDatabase::GetItemById ( const std::string & itemType,
int id )

◆ GetItems() [1/2]

bool CMusicDatabase::GetItems ( const std::string & strBaseDir,
CFileItemList & items,
const Filter & filter = Filter(),
const SortDescription & sortDescription = SortDescription() )

◆ GetItems() [2/2]

bool CMusicDatabase::GetItems ( const std::string & strBaseDir,
const std::string & itemType,
CFileItemList & items,
const Filter & filter = Filter(),
const SortDescription & sortDescription = SortDescription() )

◆ GetLastArtist()

int CMusicDatabase::GetLastArtist ( )

◆ GetLibraryLastCleaned()

std::string CMusicDatabase::GetLibraryLastCleaned ( )

◆ GetLibraryLastUpdated()

std::string CMusicDatabase::GetLibraryLastUpdated ( )

◆ GetMatchingMusicVideoAlbum()

bool CMusicDatabase::GetMatchingMusicVideoAlbum ( const std::string & strAlbum,
const std::string & strArtist,
int & idAlbum,
std::string & strReview )

◆ GetMinSchemaVersion()

int CMusicDatabase::GetMinSchemaVersion ( ) const
inlineoverrideprotectedvirtual

Reimplemented from CDatabase.

◆ GetMusicLabelsNav()

bool CMusicDatabase::GetMusicLabelsNav ( const std::string & strBaseDir,
CFileItemList & items,
const Filter & filter = Filter(),
bool countOnly = false )

◆ GetMusicNeedsTagScan()

int CMusicDatabase::GetMusicNeedsTagScan ( )
virtual

Check if music files need all tags rescanning regardless of file being unchanged because the tag processing has changed (which may happen without db version changes) since they where last scanned.

Returns
-1 if an error occurred, 0 if no scan is needed, or the version number of tags if not the same as current.

◆ GetOldArtistPath()

bool CMusicDatabase::GetOldArtistPath ( int idArtist,
std::string & path )

◆ GetOrderFilter()

int CMusicDatabase::GetOrderFilter ( const std::string & type,
const SortDescription & sorting,
Filter & filter )

◆ GetPathHash()

bool CMusicDatabase::GetPathHash ( const std::string & path,
std::string & hash )

◆ GetPaths()

bool CMusicDatabase::GetPaths ( std::set< std::string > & paths)

◆ GetRandomSongIDs()

unsigned int CMusicDatabase::GetRandomSongIDs ( const Filter & filter,
std::vector< std::pair< int, int > > & songIDs )

Gets song IDs in random order that match the filter criteria.

Parameters
filterthe criteria to apply in the query
songIDsa vector of <1, id> pairs suited to party mode use
Returns
count of song ids found.

◆ GetRecentlyAddedAlbums()

bool CMusicDatabase::GetRecentlyAddedAlbums ( VECALBUMS & albums,
unsigned int limit = 0 )

◆ GetRecentlyAddedAlbumSongs()

bool CMusicDatabase::GetRecentlyAddedAlbumSongs ( const std::string & strBaseDir,
CFileItemList & item,
unsigned int limit = 0 )

◆ GetRecentlyPlayedAlbums()

bool CMusicDatabase::GetRecentlyPlayedAlbums ( VECALBUMS & albums)

◆ GetRecentlyPlayedAlbumSongs()

bool CMusicDatabase::GetRecentlyPlayedAlbumSongs ( const std::string & strBaseDir,
CFileItemList & item )

◆ GetResumeBookmarkForAudioBook()

bool CMusicDatabase::GetResumeBookmarkForAudioBook ( const CFileItem & item,
int & bookmark )

◆ GetRoleById()

std::string CMusicDatabase::GetRoleById ( int id)

◆ GetRoleByName()

int CMusicDatabase::GetRoleByName ( const std::string & strRole)

◆ GetRolesByArtist()

bool CMusicDatabase::GetRolesByArtist ( int idArtist,
CFileItem * item )

◆ GetRolesNav()

bool CMusicDatabase::GetRolesNav ( const std::string & strBaseDir,
CFileItemList & items,
const Filter & filter = Filter() )

◆ GetSchemaVersion()

int CMusicDatabase::GetSchemaVersion ( ) const
overrideprotectedvirtual

Implements CDatabase.

◆ GetScraper()

bool CMusicDatabase::GetScraper ( int id,
const CONTENT_TYPE & content,
ADDON::ScraperPtr & scraper )

◆ GetSinglesCount()

int CMusicDatabase::GetSinglesCount ( )

◆ GetSong()

bool CMusicDatabase::GetSong ( int idSong,
CSong & song )

◆ GetSongByArtistAndAlbumAndTitle()

int CMusicDatabase::GetSongByArtistAndAlbumAndTitle ( const std::string & strArtist,
const std::string & strAlbum,
const std::string & strTitle )

◆ GetSongByFileName()

bool CMusicDatabase::GetSongByFileName ( const std::string & strFileName,
CSong & song,
int64_t startOffset = 0 )

◆ GetSongsByArtist()

bool CMusicDatabase::GetSongsByArtist ( int idArtist,
std::vector< int > & songs )

◆ GetSongsByPath()

bool CMusicDatabase::GetSongsByPath ( const std::string & strPath,
MAPSONGS & songmap,
bool bAppendToMap = false )

◆ GetSongsByWhere()

bool CMusicDatabase::GetSongsByWhere ( const std::string & baseDir,
const Filter & filter,
CFileItemList & items,
const SortDescription & sortDescription = SortDescription() )

◆ GetSongsByWhereJSON()

bool CMusicDatabase::GetSongsByWhereJSON ( const std::set< std::string > & fields,
const std::string & baseDir,
CVariant & result,
int & total,
const SortDescription & sortDescription = SortDescription() )

◆ GetSongsByYear()

bool CMusicDatabase::GetSongsByYear ( const std::string & baseDir,
CFileItemList & items,
int year )

◆ GetSongsCount()

int CMusicDatabase::GetSongsCount ( const Filter & filter = Filter())

◆ GetSongsFullByWhere()

bool CMusicDatabase::GetSongsFullByWhere ( const std::string & baseDir,
const Filter & filter,
CFileItemList & items,
const SortDescription & sortDescription = SortDescription(),
bool artistData = false )

◆ GetSongsLastAdded()

std::string CMusicDatabase::GetSongsLastAdded ( )

◆ GetSongsLastModified()

std::string CMusicDatabase::GetSongsLastModified ( )

◆ GetSongsNav()

bool CMusicDatabase::GetSongsNav ( const std::string & strBaseDir,
CFileItemList & items,
int idGenre,
int idArtist,
int idAlbum,
const SortDescription & sortDescription = SortDescription() )

◆ GetSourceById()

std::string CMusicDatabase::GetSourceById ( int id)

◆ GetSourceByName()

int CMusicDatabase::GetSourceByName ( const std::string & strSource)

◆ GetSourceFromPath()

int CMusicDatabase::GetSourceFromPath ( const std::string & strPath)

◆ GetSources()

bool CMusicDatabase::GetSources ( CFileItemList & items)

◆ GetSourcesByAlbum()

bool CMusicDatabase::GetSourcesByAlbum ( int idAlbum,
CFileItem * item )
Todo
: handle singles, or don't waste time checking songs

◆ GetSourcesByArtist()

bool CMusicDatabase::GetSourcesByArtist ( int idArtist,
CFileItem * item )

◆ GetSourcesBySong()

bool CMusicDatabase::GetSourcesBySong ( int idSong,
const std::string & strPath,
CFileItem * item )

◆ GetSourcesNav()

bool CMusicDatabase::GetSourcesNav ( const std::string & strBaseDir,
CFileItemList & items,
const Filter & filter = Filter(),
bool countOnly = false )

◆ GetTop100()

bool CMusicDatabase::GetTop100 ( const std::string & strBaseDir,
CFileItemList & items )

◆ GetTop100Albums()

bool CMusicDatabase::GetTop100Albums ( VECALBUMS & albums)

◆ GetTop100AlbumSongs()

bool CMusicDatabase::GetTop100AlbumSongs ( const std::string & strBaseDir,
CFileItemList & item )

◆ GetTranslateBlankArtist()

bool CMusicDatabase::GetTranslateBlankArtist ( )
inline

◆ GetUsedImages()

std::vector< std::string > CMusicDatabase::GetUsedImages ( const std::vector< std::string > & imagesToCheck) const

Check the passed in list of images if used in this database. Used to clean the image cache.

Parameters
imagesToCheck
Returns
a list of the passed in images used by this database.

◆ GetYearsNav()

bool CMusicDatabase::GetYearsNav ( const std::string & strBaseDir,
CFileItemList & items,
const Filter & filter = Filter() )

◆ HasAlbumBeenScraped()

bool CMusicDatabase::HasAlbumBeenScraped ( int idAlbum)

◆ HasArtistBeenScraped()

bool CMusicDatabase::HasArtistBeenScraped ( int idArtist)

◆ ImportFromXML()

void CMusicDatabase::ImportFromXML ( const std::string & xmlFile,
CGUIDialogProgress * progressDialog = nullptr )

◆ ImportSongHistory()

bool CMusicDatabase::ImportSongHistory ( const std::string & xmlFile,
const int total,
CGUIDialogProgress * progressDialog = nullptr )

◆ IncrementPlayCount()

void CMusicDatabase::IncrementPlayCount ( const CFileItem & item)

Increment the playcount of an item Increments the playcount and updates the last played date.

Parameters
itemCFileItem to increment the playcount for

◆ InsideScannedPath()

bool CMusicDatabase::InsideScannedPath ( const std::string & path)

Checks if the given path is inside a folder that has already been scanned into the library.

Parameters
paththe path we want to check

◆ IsAlbumBoxset()

bool CMusicDatabase::IsAlbumBoxset ( int idAlbum)

◆ IsSongAlbumArtist()

bool CMusicDatabase::IsSongAlbumArtist ( int idSong,
int idArtist )

◆ IsSongArtist()

bool CMusicDatabase::IsSongArtist ( int idSong,
int idArtist )

◆ LookupCDDBInfo()

bool CMusicDatabase::LookupCDDBInfo ( bool bRequery = false)

◆ Open()

bool CMusicDatabase::Open ( )
overridevirtual

Reimplemented from CDatabase.

◆ RemoveArtForItem() [1/2]

bool CMusicDatabase::RemoveArtForItem ( int mediaId,
const MediaType & mediaType,
const std::set< std::string > & artTypes )

Remove art for a database item. Removes multiple pieces of art for a database item.

Parameters
mediaIdthe id in the media (song/artist/album) table.
mediaTypethe type of media, which corresponds to the table the item resides in (song/artist/album).
arttypesa set of types, e.g. "thumb", "fanart", etc. to be removed.
Returns
true if art is removed, false if no art is found.
See also
RemoveArtForItem

◆ RemoveArtForItem() [2/2]

bool CMusicDatabase::RemoveArtForItem ( int mediaId,
const MediaType & mediaType,
const std::string & artType )

Remove art for a database item. Removes a single piece of art for a database item.

Parameters
mediaIdthe id in the media (song/artist/album) table.
mediaTypethe type of media, which corresponds to the table the item resides in (song/artist/album).
artTypethe type of art to remove, eg "thumb", "fanart".
Returns
true if art is removed, false if no art is found.
See also
RemoveArtForItem

◆ RemoveSongsFromPath()

bool CMusicDatabase::RemoveSongsFromPath ( const std::string & path,
MAPSONGS & songmap,
bool exact = true )
Todo
SQLite probably doesn't allow this, but can we rely on that??
Todo
move this below the m_pDS->exec block, once UPnP doesn't rely on this anymore

◆ RemoveSource()

bool CMusicDatabase::RemoveSource ( const std::string & strName)

◆ ScraperInUse()

bool CMusicDatabase::ScraperInUse ( const std::string & scraperID) const

Check whether a given scraper is in use.

Parameters
scraperIDthe scraper to check for.
Returns
true if the scraper is in use, false otherwise.

◆ Search()

bool CMusicDatabase::Search ( const std::string & search,
CFileItemList & items )

◆ SearchAlbumsByArtistName()

bool CMusicDatabase::SearchAlbumsByArtistName ( const std::string & strArtist,
CFileItemList & items )

◆ SetAlbumUserrating()

bool CMusicDatabase::SetAlbumUserrating ( const int idAlbum,
int userrating )

◆ SetArtForItem() [1/2]

void CMusicDatabase::SetArtForItem ( int mediaId,
const std::string & mediaType,
const std::map< std::string, std::string > & art )

Sets art for a database item. Sets multiple pieces of art for a database item.

Parameters
mediaIdthe id in the media (song/artist/album) table.
mediaTypethe type of media, which corresponds to the table the item resides in (song/artist/album).
arta map of <type, url> where type is "thumb", "fanart", etc. and url is the original url of the art.
See also
GetArtForItem

◆ SetArtForItem() [2/2]

void CMusicDatabase::SetArtForItem ( int mediaId,
const std::string & mediaType,
const std::string & artType,
const std::string & url )

Sets art for a database item. Sets a single piece of art for a database item.

Parameters
mediaIdthe id in the media (song/artist/album) table.
mediaTypethe type of media, which corresponds to the table the item resides in (song/artist/album).
artTypethe type of art to set, e.g. "thumb", "fanart"
urlthe url to the art (this is the original url, not a cached url).
See also
GetArtForItem

◆ SetArtistLinksUpdated()

void CMusicDatabase::SetArtistLinksUpdated ( )

◆ SetItemUpdated()

void CMusicDatabase::SetItemUpdated ( int mediaId,
const std::string & mediaType )

◆ SetLibraryLastCleaned()

void CMusicDatabase::SetLibraryLastCleaned ( )

◆ SetLibraryLastUpdated()

void CMusicDatabase::SetLibraryLastUpdated ( )

◆ SetMusicNeedsTagScan()

void CMusicDatabase::SetMusicNeedsTagScan ( int version)

Set minimum version number of db needed when tag data scanned from music files.

Parameters
versionthe version number of db

◆ SetMusicTagScanVersion()

void CMusicDatabase::SetMusicTagScanVersion ( int version = 0)

Set the version number of tag data.

Parameters
versionthe version number of db when tags last scanned, 0 (default) means current db version

◆ SetPathHash()

bool CMusicDatabase::SetPathHash ( const std::string & path,
const std::string & hash )

◆ SetPropertiesForFileItem()

void CMusicDatabase::SetPropertiesForFileItem ( CFileItem & item)

◆ SetPropertiesFromAlbum()

void CMusicDatabase::SetPropertiesFromAlbum ( CFileItem & item,
const CAlbum & album )
static

◆ SetPropertiesFromArtist()

void CMusicDatabase::SetPropertiesFromArtist ( CFileItem & item,
const CArtist & artist )
static

◆ SetResumeBookmarkForAudioBook()

bool CMusicDatabase::SetResumeBookmarkForAudioBook ( const CFileItem & item,
int bookmark )

◆ SetScraper()

bool CMusicDatabase::SetScraper ( int id,
const CONTENT_TYPE & content,
const ADDON::ScraperPtr & scraper )

◆ SetScraperAll()

bool CMusicDatabase::SetScraperAll ( const std::string & strBaseDir,
const ADDON::ScraperPtr & scraper )

◆ SetSongUserrating() [1/2]

bool CMusicDatabase::SetSongUserrating ( const std::string & filePath,
int userrating )

◆ SetSongUserrating() [2/2]

bool CMusicDatabase::SetSongUserrating ( int idSong,
int userrating )

◆ SetSongVotes()

bool CMusicDatabase::SetSongVotes ( const std::string & filePath,
int votes )

◆ SetTranslateBlankArtist()

void CMusicDatabase::SetTranslateBlankArtist ( bool translate)
inline

◆ UpdateAlbum() [1/2]

bool CMusicDatabase::UpdateAlbum ( CAlbum & album)

Update an album and all its nested entities (artists, songs etc)

Parameters
albumthe album to update
Returns
true or false

◆ UpdateAlbum() [2/2]

int CMusicDatabase::UpdateAlbum ( int idAlbum,
const std::string & strAlbum,
const std::string & strMusicBrainzAlbumID,
const std::string & strReleaseGroupMBID,
const std::string & strArtist,
const std::string & strArtistSort,
const std::string & strGenre,
const std::string & strMoods,
const std::string & strStyles,
const std::string & strThemes,
const std::string & strReview,
const std::string & strImage,
const std::string & strLabel,
const std::string & strType,
const std::string & strReleaseStatus,
float fRating,
int iUserrating,
int iVotes,
const std::string & strReleaseDate,
const std::string & strOrigReleaseDate,
bool bBoxedSet,
bool bCompilation,
CAlbum::ReleaseType releaseType,
bool bScrapedMBID )

◆ UpdateArtist() [1/2]

bool CMusicDatabase::UpdateArtist ( const CArtist & artist)

◆ UpdateArtist() [2/2]

int CMusicDatabase::UpdateArtist ( int idArtist,
const std::string & strArtist,
const std::string & strSortName,
const std::string & strMusicBrainzArtistID,
bool bScrapedMBID,
const std::string & strType,
const std::string & strGender,
const std::string & strDisambiguation,
const std::string & strBorn,
const std::string & strFormed,
const std::string & strGenres,
const std::string & strMoods,
const std::string & strStyles,
const std::string & strInstruments,
const std::string & strBiography,
const std::string & strDied,
const std::string & strDisbanded,
const std::string & strYearsActive,
const std::string & strImage )

◆ UpdateArtistScrapedMBID()

bool CMusicDatabase::UpdateArtistScrapedMBID ( int idArtist,
const std::string & strMusicBrainzArtistID )

◆ UpdateArtistSortNames()

bool CMusicDatabase::UpdateArtistSortNames ( int idArtist = -1)

Propagate artist sort name into the concatenated artist sort name strings held for songs and albums.

Parameters
intidArtist to propagate sort name for, -1 means all artists

◆ UpdateSong() [1/2]

bool CMusicDatabase::UpdateSong ( CSong & song,
bool bArtists = true,
bool bArtistLinks = true )

Update a song and all its nested entities (genres, artists, contributors)

Parameters
song[in/out] the song to update, artist ids are returned in artist credits
bArtiststo update artist credits and contributors, default is true
bArtiststo check and log if artist links have changed, default is true
Returns
true if successful

◆ UpdateSong() [2/2]

int CMusicDatabase::UpdateSong ( int idSong,
const std::string & strTitle,
const std::string & strMusicBrainzTrackID,
const std::string & strPathAndFileName,
const std::string & strComment,
const std::string & strMood,
const std::string & strThumb,
const std::string & artistDisp,
const std::string & artistSort,
const std::vector< std::string > & genres,
int iTrack,
int iDuration,
const std::string & strReleaseDate,
const std::string & strOrigReleaseDate,
const std::string & strDiscSubtitle,
int iTimesPlayed,
int iStartOffset,
int iEndOffset,
const CDateTime & dtLastPlayed,
float rating,
int userrating,
int votes,
const ReplayGain & replayGain,
int iBPM,
int iBitRate,
int iSampleRate,
int iChannels,
const std::string & songVideoURL )

Update a song in the database.

Parameters
idSong[in] the database ID of the song to update
strTitle[in] the title of the song (required to be non-empty)
strMusicBrainzTrackID[in] the MusicBrainz track ID of the song
strPathAndFileName[in] the path and filename to the song
strComment[in] the ids of the added songs
strMood[in] the mood of the added song
strThumb[in] the ids of the added songs
artistDisp[in] the artist name(s) display string
artistSort[in] the artist name(s) sort string
genres[in] a vector of genres to which this song belongs
iTrack[in] the track number and disc number of the song
iDuration[in] the duration of the song
strReleaseDate[in] the release date of the song ISO8601 format
strOrigReleaseDate[in] the original release date of the song ISO8601 format
strDiscSubtitle[in] subtitle of a disc
iTimesPlayed[in] the number of times the song has been played
iStartOffset[in] the start offset of the song (when using a single audio file with a .cue)
iEndOffset[in] the end offset of the song (when using a single audio file with .cue)
dtLastPlayed[in] the time the song was last played
rating[in] a rating for the song
userrating[in] a userrating (my rating) for the song
votes[in] a vote counter for the song rating
replayGain[in] album and track replaygain and peak values
iBPM[in] the beats per minute of a song
iBitRate[in] the bitrate of the song file
iSampleRate[in] the sample rate of the song file
iChannels[in] the number of audio channels in the song file
songVideoURL[in] url link to a video of the song
Returns
the id of the song

◆ UpdateSource()

int CMusicDatabase::UpdateSource ( const std::string & strOldName,
const std::string & strName,
const std::string & strMultipath,
const std::vector< std::string > & vecPaths )

◆ UpdateSources()

bool CMusicDatabase::UpdateSources ( )

Friends And Related Symbol Documentation

◆ DatabaseUtils

friend class DatabaseUtils
friend

◆ TestDatabaseUtilsHelper

friend class TestDatabaseUtilsHelper
friend

Member Data Documentation

◆ m_genreCache

std::map<std::string, int> CMusicDatabase::m_genreCache
protected

◆ m_pathCache

std::map<std::string, int> CMusicDatabase::m_pathCache
protected

The documentation for this class was generated from the following files: