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

#include <MusicInfoScanner.h>

Inheritance diagram for MUSIC_INFO::CMusicInfoScanner:
IRunnable CInfoScanner

Public Types

enum  SCAN_FLAGS {
  SCAN_NORMAL = 0 , SCAN_ONLINE = 1 << 0 , SCAN_BACKGROUND = 1 << 1 , SCAN_RESCAN = 1 << 2 ,
  SCAN_ARTISTS = 1 << 3 , SCAN_ALBUMS = 1 << 4
}
 Flags for controlling the scanning process. More...
 
- Public Types inherited from CInfoScanner
enum  INFO_RET {
  INFO_CANCELLED , INFO_ERROR , INFO_NOT_NEEDED , INFO_HAVE_ALREADY ,
  INFO_NOT_FOUND , INFO_ADDED
}
 Return values from the information lookup functions. More...
 
enum  INFO_TYPE {
  NO_NFO = 0 , FULL_NFO = 1 , URL_NFO = 2 , OVERRIDE_NFO = 3 ,
  COMBINED_NFO = 4 , ERROR_NFO = 5 , TITLE_NFO = 6
}
 

Public Member Functions

 CMusicInfoScanner ()
 
 ~CMusicInfoScanner () override
 
void Start (const std::string &strDirectory, int flags)
 
void FetchAlbumInfo (const std::string &strDirectory, bool refresh=false)
 
void FetchArtistInfo (const std::string &strDirectory, bool refresh=false)
 
void Stop ()
 
INFO_RET UpdateAlbumInfo (CAlbum &album, const ADDON::ScraperPtr &scraper, bool bAllowSelection, CGUIDialogProgress *pDialog=NULL)
 Scrape additional album information and update the music database with it. Given an album, search for it using the given scraper. If info is found, update the database and artwork with the new information.
 
INFO_RET UpdateArtistInfo (CArtist &artist, const ADDON::ScraperPtr &scraper, bool bAllowSelection, CGUIDialogProgress *pDialog=NULL)
 Scrape additional artist information and update the music database with it. Given an artist, search for it using the given scraper. If info is found, update the database and artwork with the new information.
 
- Public Member Functions inherited from IRunnable
virtual void Cancel ()
 
virtual ~IRunnable ()=default
 
- Public Member Functions inherited from CInfoScanner
virtual ~CInfoScanner ()=default
 Empty destructor.
 
bool HasNoMedia (const std::string &strDirectory) const
 Check if the folder is excluded from scanning process.
 
void ShowDialog (bool show)
 Set whether or not to show a progress dialog.
 
bool IsScanning () const
 Returns whether or not a scan is in progress.
 

Static Public Member Functions

static void FileItemsToAlbums (CFileItemList &items, VECALBUMS &albums, MAPSONGS *songsMap=NULL)
 Categorize FileItems into Albums, Songs, and Artists This takes a list of FileItems and turns it into a tree of Albums, Artists, and Songs. Albums are defined uniquely by the album name and album artist.
 

Protected Member Functions

virtual void Process ()
 
bool DoScan (const std::string &strDirectory) override
 
INFO_RET UpdateDatabaseAlbumInfo (CAlbum &album, const ADDON::ScraperPtr &scraper, bool bAllowSelection, CGUIDialogProgress *pDialog=NULL)
 Scrape additional album information and update the database. Search for the given album using the given scraper. If info is found, update the database and artwork with the new information.
 
INFO_RET UpdateDatabaseArtistInfo (CArtist &artist, const ADDON::ScraperPtr &scraper, bool bAllowSelection, CGUIDialogProgress *pDialog=NULL)
 Scrape additional artist information and update the database. Search for the given artist using the given scraper. If info is found, update the database and artwork with the new information.
 
INFO_RET DownloadAlbumInfo (const CAlbum &album, const ADDON::ScraperPtr &scraper, MUSIC_GRABBER::CMusicAlbumInfo &albumInfo, bool bUseScrapedMBID, CGUIDialogProgress *pDialog=NULL)
 Using the scrapers download metadata for an album Given a CAlbum style struct containing some data about an album, query the scrapers to try and get more information about the album. The responsibility is with the caller to do something with that information. It will be passed back in a MusicInfo struct, which you can save, display to the user or throw away.
 
INFO_RET DownloadArtistInfo (const CArtist &artist, const ADDON::ScraperPtr &scraper, MUSIC_GRABBER::CMusicArtistInfo &artistInfo, bool bUseScrapedMBID, CGUIDialogProgress *pDialog=NULL)
 Using the scrapers download metadata for an artist Given a CAlbum style struct containing some data about an artist, query the scrapers to try and get more information about the artist. The responsibility is with the caller to do something with that information. It will be passed back in a MusicInfo struct, which you can save, display to the user or throw away.
 
std::vector< CVariantGetArtWhitelist (const MediaType &mediaType, int iArtLevel)
 Get the types of art for an artist or album that are to be automatically fetched from local files during scanning.
 
bool AddLocalArtwork (std::map< std::string, std::string > &art, const std::string &mediaType, const std::string &mediaName, const std::string &artfolder, int discnum=0)
 Add extra local artwork for albums and artists This common utility scans the given folder for local (non-thumb) art. The art types checked are determined by whitelist and usealllocalart settings.
 
bool AddRemoteArtwork (std::map< std::string, std::string > &art, const std::string &mediaType, const CScraperUrl &thumbURL)
 Add extra remote artwork for albums and artists This common utility fills the gaps in artwork using the first available art of each type from the possible art URL results of previous scraping. The art types applied are determined by whitelist and usealllocalart settings.
 
bool AddArtistArtwork (CArtist &artist, const std::string &artfolder)
 Add art for an artist This scans the given folder for local art and/or applies the first available art of each type from the possible art URLs previously scraped. Art is added to any already stored by previous scanning etc.The art types processed are determined by whitelist and other art settings. When usealllocalart is enabled then all local image files are applied as art (providing name is valid for an art type), and then the URL list of remote art is checked adding the first available image of each art type not yet in the art map. Art found is saved in the album structure and the music database. The images found are cached.
 
bool AddAlbumArtwork (CAlbum &album)
 Add art for an album This scans the album folder, and any disc set subfolders, for local art and/or applies the first available art of each type from the possible art URLs previously scraped. Only those subfolders beneath the album folder containing music files tagged with same unique disc number are scanned. Art is added to any already stored by previous scanning, only "thumb" is optionally replaced. The art types processed are determined by whitelist and other art settings. When usealllocalart is enabled then all local image files are applied as art (providing name is valid for an art type), and then the URL list of remote art is checked adding the first available image of each art type not yet in the art map. Art found is saved in the album structure and the music database. The images found are cached.
 
int RetrieveMusicInfo (const std::string &strDirectory, CFileItemList &items)
 Scan in the ID3/Ogg/FLAC tags for a bunch of FileItems Given a list of FileItems, scan in the tags for those FileItems and populate a new FileItemList with the files that were successfully scanned. Add album to library, populate a list of album ids added for possible scraping later. Any files which couldn't be scanned (no/bad tags) are discarded in the process.
 
void RetrieveLocalArt ()
 
void ScrapeInfoAddedAlbums ()
 
INFO_RET ScanTags (const CFileItemList &items, CFileItemList &scannedItems)
 Scan in the ID3/Ogg/FLAC tags for a bunch of FileItems Given a list of FileItems, scan in the tags for those FileItems and populate a new FileItemList with the files that were successfully scanned. Any files which couldn't be scanned (no/bad tags) are discarded in the process.
 
int GetPathHash (const CFileItemList &items, std::string &hash)
 
void Run () override
 
int CountFiles (const CFileItemList &items, bool recursive)
 
int CountFilesRecursively (const std::string &strPath)
 
bool ResolveMusicBrainz (const std::string &strMusicBrainzID, const ADDON::ScraperPtr &preferredScraper, CScraperUrl &musicBrainzURL)
 Resolve a MusicBrainzID to a URL If we have a MusicBrainz ID for an artist or album, resolve it to an MB URL and set up the scrapers accordingly.
 
void ScannerWait (unsigned int milliseconds)
 
- Protected Member Functions inherited from CInfoScanner
 CInfoScanner ()=default
 Protected constructor to only allow subclass instances.
 

Static Protected Member Functions

static void FindArtForAlbums (VECALBUMS &albums, const std::string &path)
 Find art for albums Based on the albums in the folder, finds whether we have unique album art and assigns to the album if we do.
 

Protected Attributes

int m_currentItem
 
int m_itemCount
 
bool m_bStop
 
bool m_needsCleanup = false
 
int m_scanType = 0
 
int m_idSourcePath
 
CMusicDatabase m_musicDatabase
 
std::set< intm_albumsAdded
 
std::set< std::string > m_seenPaths
 
int m_flags
 
CThread m_fileCountReader
 
- Protected Attributes inherited from CInfoScanner
std::set< std::string > m_pathsToScan
 Set of paths to scan.
 
bool m_showDialog = false
 Whether or not to show progress bar dialog.
 
CGUIDialogProgressBarHandlem_handle = nullptr
 Progress bar handle.
 
bool m_bRunning = false
 Whether or not scanner is running.
 
bool m_bCanInterrupt = false
 Whether or not scanner is currently interruptible.
 
bool m_bClean = false
 Whether or not to perform cleaning during scanning.
 

Member Enumeration Documentation

◆ SCAN_FLAGS

Flags for controlling the scanning process.

Enumerator
SCAN_NORMAL 
SCAN_ONLINE 
SCAN_BACKGROUND 
SCAN_RESCAN 
SCAN_ARTISTS 
SCAN_ALBUMS 

Constructor & Destructor Documentation

◆ CMusicInfoScanner()

CMusicInfoScanner::CMusicInfoScanner ( )

◆ ~CMusicInfoScanner()

CMusicInfoScanner::~CMusicInfoScanner ( )
overridedefault

Member Function Documentation

◆ AddAlbumArtwork()

bool CMusicInfoScanner::AddAlbumArtwork ( CAlbum & album)
protected

Add art for an album This scans the album folder, and any disc set subfolders, for local art and/or applies the first available art of each type from the possible art URLs previously scraped. Only those subfolders beneath the album folder containing music files tagged with same unique disc number are scanned. Art is added to any already stored by previous scanning, only "thumb" is optionally replaced. The art types processed are determined by whitelist and other art settings. When usealllocalart is enabled then all local image files are applied as art (providing name is valid for an art type), and then the URL list of remote art is checked adding the first available image of each art type not yet in the art map. Art found is saved in the album structure and the music database. The images found are cached.

Parameters
artist[in/out] an album, the art is set
Returns
true when art is added

◆ AddArtistArtwork()

bool CMusicInfoScanner::AddArtistArtwork ( CArtist & artist,
const std::string & artfolder )
protected

Add art for an artist This scans the given folder for local art and/or applies the first available art of each type from the possible art URLs previously scraped. Art is added to any already stored by previous scanning etc.The art types processed are determined by whitelist and other art settings. When usealllocalart is enabled then all local image files are applied as art (providing name is valid for an art type), and then the URL list of remote art is checked adding the first available image of each art type not yet in the art map. Art found is saved in the album structure and the music database. The images found are cached.

Parameters
artist[in/out] an artist, the art is set
artfolder[in] path of the location to search for local art files
Returns
true when art is added

◆ AddLocalArtwork()

bool CMusicInfoScanner::AddLocalArtwork ( std::map< std::string, std::string > & art,
const std::string & mediaType,
const std::string & mediaName,
const std::string & artfolder,
int discnum = 0 )
protected

Add extra local artwork for albums and artists This common utility scans the given folder for local (non-thumb) art. The art types checked are determined by whitelist and usealllocalart settings.

Parameters
art[in/out] map of art type and file location (URL or path) pairs
mediaType[in] artist or album
mediaName[in] artist or album name that may be stripped from image file names
artfolder[in] path of folder containing local image files
Returns
true when art is added

◆ AddRemoteArtwork()

bool CMusicInfoScanner::AddRemoteArtwork ( std::map< std::string, std::string > & art,
const std::string & mediaType,
const CScraperUrl & thumbURL )
protected

Add extra remote artwork for albums and artists This common utility fills the gaps in artwork using the first available art of each type from the possible art URL results of previous scraping. The art types applied are determined by whitelist and usealllocalart settings.

Parameters
art[in/out] map of art type and file location (URL or path) pairs
mediaType[in] artist or album
thumbURL[in] URLs for potential remote artwork (provided by scrapers)
Returns
true when art is added

◆ CountFiles()

int CMusicInfoScanner::CountFiles ( const CFileItemList & items,
bool recursive )
protected

◆ CountFilesRecursively()

int CMusicInfoScanner::CountFilesRecursively ( const std::string & strPath)
protected

◆ DoScan()

bool CMusicInfoScanner::DoScan ( const std::string & strDirectory)
overrideprotectedvirtual

Implements CInfoScanner.

◆ DownloadAlbumInfo()

CInfoScanner::INFO_RET CMusicInfoScanner::DownloadAlbumInfo ( const CAlbum & album,
const ADDON::ScraperPtr & scraper,
MUSIC_GRABBER::CMusicAlbumInfo & albumInfo,
bool bUseScrapedMBID,
CGUIDialogProgress * pDialog = NULL )
protected

Using the scrapers download metadata for an album Given a CAlbum style struct containing some data about an album, query the scrapers to try and get more information about the album. The responsibility is with the caller to do something with that information. It will be passed back in a MusicInfo struct, which you can save, display to the user or throw away.

Parameters
album[in] a partially or fully filled out album structure containing the search query
scraper[in] the scraper to query, usually the default or the relevant scraper for the musicdb path
albumInfo[in/out] a CMusicAlbumInfo struct which will be populated with the output of the scraper
bUseScrapedMBID[in] should scraper use any previously scraped mbid to identify the artist, or use artist name?
pDialog[in] a progress dialog which this and downstream functions can update with status, if required

◆ DownloadArtistInfo()

CInfoScanner::INFO_RET CMusicInfoScanner::DownloadArtistInfo ( const CArtist & artist,
const ADDON::ScraperPtr & scraper,
MUSIC_GRABBER::CMusicArtistInfo & artistInfo,
bool bUseScrapedMBID,
CGUIDialogProgress * pDialog = NULL )
protected

Using the scrapers download metadata for an artist Given a CAlbum style struct containing some data about an artist, query the scrapers to try and get more information about the artist. The responsibility is with the caller to do something with that information. It will be passed back in a MusicInfo struct, which you can save, display to the user or throw away.

Parameters
artist[in] a partially or fully filled out artist structure containing the search query
scraper[in] the scraper to query, usually the default or the relevant scraper for the musicdb path
artistInfo[in/out] a CMusicAlbumInfo struct which will be populated with the output of the scraper
bUseScrapedMBID[in] should scraper use any previously scraped mbid to identify the album, or use album and artist name?
pDialog[in] a progress dialog which this and downstream functions can update with status, if required

◆ FetchAlbumInfo()

void CMusicInfoScanner::FetchAlbumInfo ( const std::string & strDirectory,
bool refresh = false )

◆ FetchArtistInfo()

void CMusicInfoScanner::FetchArtistInfo ( const std::string & strDirectory,
bool refresh = false )

◆ FileItemsToAlbums()

void CMusicInfoScanner::FileItemsToAlbums ( CFileItemList & items,
VECALBUMS & albums,
MAPSONGS * songsMap = NULL )
static

Categorize FileItems into Albums, Songs, and Artists This takes a list of FileItems and turns it into a tree of Albums, Artists, and Songs. Albums are defined uniquely by the album name and album artist.

Parameters
songs[in/out] list of songs to categorise - albumartist field may be altered.
albums[out] albums found within these songs.
Todo
in future we may wish to union up the genres, for now we assume they're the same

◆ FindArtForAlbums()

void CMusicInfoScanner::FindArtForAlbums ( VECALBUMS & albums,
const std::string & path )
staticprotected

Find art for albums Based on the albums in the folder, finds whether we have unique album art and assigns to the album if we do.

In order of priority:

  1. If there is a single album in the folder, then the folder art is assigned to the album.
  2. We find the art for each song. A .tbn file takes priority over embedded art.
  3. If we have a unique piece of art for all songs in the album, we assign that to the album and remove that art from each song so that they inherit from the album.
  4. If there is not a unique piece of art for each song, then no art is assigned to the album.
Parameters
albums[in/out] list of albums to categorise - art field may be altered.
path[in] path containing albums.

◆ GetArtWhitelist()

std::vector< CVariant > CMusicInfoScanner::GetArtWhitelist ( const MediaType & mediaType,
int iArtLevel )
protected

Get the types of art for an artist or album that are to be automatically fetched from local files during scanning.

Parameters
mediaType[in] artist or album
iArtLevel[in] art level
Returns
vector of art types that are to be fetched during scanning

◆ GetPathHash()

int CMusicInfoScanner::GetPathHash ( const CFileItemList & items,
std::string & hash )
protected

◆ Process()

void CMusicInfoScanner::Process ( )
protectedvirtual

◆ ResolveMusicBrainz()

bool CMusicInfoScanner::ResolveMusicBrainz ( const std::string & strMusicBrainzID,
const ADDON::ScraperPtr & preferredScraper,
CScraperUrl & musicBrainzURL )
protected

Resolve a MusicBrainzID to a URL If we have a MusicBrainz ID for an artist or album, resolve it to an MB URL and set up the scrapers accordingly.

Parameters
preferredScraper[in] A ScraperPtr to the preferred album/artist scraper.
musicBrainzURL[out] will be populated with the MB URL for the artist/album.

◆ RetrieveLocalArt()

void MUSIC_INFO::CMusicInfoScanner::RetrieveLocalArt ( )
protected
Todo
: title = Checking for local art

◆ RetrieveMusicInfo()

int CMusicInfoScanner::RetrieveMusicInfo ( const std::string & strDirectory,
CFileItemList & items )
protected

Scan in the ID3/Ogg/FLAC tags for a bunch of FileItems Given a list of FileItems, scan in the tags for those FileItems and populate a new FileItemList with the files that were successfully scanned. Add album to library, populate a list of album ids added for possible scraping later. Any files which couldn't be scanned (no/bad tags) are discarded in the process.

Parameters
items[in] list of FileItems to scan
scannedItems[in] list to populate with the scannedItems

◆ Run()

void CMusicInfoScanner::Run ( )
overrideprotectedvirtual

Implements IRunnable.

◆ ScannerWait()

void CMusicInfoScanner::ScannerWait ( unsigned int milliseconds)
protected

◆ ScanTags()

CInfoScanner::INFO_RET CMusicInfoScanner::ScanTags ( const CFileItemList & items,
CFileItemList & scannedItems )
protected

Scan in the ID3/Ogg/FLAC tags for a bunch of FileItems Given a list of FileItems, scan in the tags for those FileItems and populate a new FileItemList with the files that were successfully scanned. Any files which couldn't be scanned (no/bad tags) are discarded in the process.

Parameters
items[in] list of FileItems to scan
scannedItems[in] list to populate with the scannedItems

◆ ScrapeInfoAddedAlbums()

void MUSIC_INFO::CMusicInfoScanner::ScrapeInfoAddedAlbums ( )
protected

◆ Start()

void CMusicInfoScanner::Start ( const std::string & strDirectory,
int flags )

◆ Stop()

void CMusicInfoScanner::Stop ( )

◆ UpdateAlbumInfo()

CInfoScanner::INFO_RET CMusicInfoScanner::UpdateAlbumInfo ( CAlbum & album,
const ADDON::ScraperPtr & scraper,
bool bAllowSelection,
CGUIDialogProgress * pDialog = NULL )

Scrape additional album information and update the music database with it. Given an album, search for it using the given scraper. If info is found, update the database and artwork with the new information.

Parameters
album[in/out] the album to update
scraper[in] the album scraper to use
bAllowSelection[in] should we allow the user to manually override the info with a GUI if the album is not found?
pDialog[in] a progress dialog which this and downstream functions can update with status, if required

◆ UpdateArtistInfo()

CInfoScanner::INFO_RET CMusicInfoScanner::UpdateArtistInfo ( CArtist & artist,
const ADDON::ScraperPtr & scraper,
bool bAllowSelection,
CGUIDialogProgress * pDialog = NULL )

Scrape additional artist information and update the music database with it. Given an artist, search for it using the given scraper. If info is found, update the database and artwork with the new information.

Parameters
artist[in/out] the artist to update
scraper[in] the artist scraper to use
bAllowSelection[in] should we allow the user to manually override the info with a GUI if the album is not found?
pDialog[in] a progress dialog which this and downstream functions can update with status, if required

◆ UpdateDatabaseAlbumInfo()

CInfoScanner::INFO_RET CMusicInfoScanner::UpdateDatabaseAlbumInfo ( CAlbum & album,
const ADDON::ScraperPtr & scraper,
bool bAllowSelection,
CGUIDialogProgress * pDialog = NULL )
protected

Scrape additional album information and update the database. Search for the given album using the given scraper. If info is found, update the database and artwork with the new information.

Parameters
album[in/out] the album to update
scraper[in] the album scraper to use
bAllowSelection[in] should we allow the user to manually override the info with a GUI if the album is not found?
pDialog[in] a progress dialog which this and downstream functions can update with status, if required

◆ UpdateDatabaseArtistInfo()

CInfoScanner::INFO_RET CMusicInfoScanner::UpdateDatabaseArtistInfo ( CArtist & artist,
const ADDON::ScraperPtr & scraper,
bool bAllowSelection,
CGUIDialogProgress * pDialog = NULL )
protected

Scrape additional artist information and update the database. Search for the given artist using the given scraper. If info is found, update the database and artwork with the new information.

Parameters
artist[in/out] the artist to update
scraper[in] the artist scraper to use
bAllowSelection[in] should we allow the user to manually override the info with a GUI if the album is not found?
pDialog[in] a progress dialog which this and downstream functions can update with status, if required

Member Data Documentation

◆ m_albumsAdded

std::set<int> MUSIC_INFO::CMusicInfoScanner::m_albumsAdded
protected

◆ m_bStop

bool MUSIC_INFO::CMusicInfoScanner::m_bStop
protected

◆ m_currentItem

int MUSIC_INFO::CMusicInfoScanner::m_currentItem
protected

◆ m_fileCountReader

CThread MUSIC_INFO::CMusicInfoScanner::m_fileCountReader
protected

◆ m_flags

int MUSIC_INFO::CMusicInfoScanner::m_flags
protected

◆ m_idSourcePath

int MUSIC_INFO::CMusicInfoScanner::m_idSourcePath
protected

◆ m_itemCount

int MUSIC_INFO::CMusicInfoScanner::m_itemCount
protected

◆ m_musicDatabase

CMusicDatabase MUSIC_INFO::CMusicInfoScanner::m_musicDatabase
protected

◆ m_needsCleanup

bool MUSIC_INFO::CMusicInfoScanner::m_needsCleanup = false
protected

◆ m_scanType

int MUSIC_INFO::CMusicInfoScanner::m_scanType = 0
protected

◆ m_seenPaths

std::set<std::string> MUSIC_INFO::CMusicInfoScanner::m_seenPaths
protected

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