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

#include <VideoInfoScanner.h>

Inheritance diagram for KODI::VIDEO::CVideoInfoScanner:
CInfoScanner

Public Member Functions

 CVideoInfoScanner ()
 
 ~CVideoInfoScanner () override
 
void Start (const std::string &strDirectory, bool scanAll=false)
 Scan a folder using the background scanner.
 
void Stop ()
 
long AddVideo (CFileItem *pItem, const CONTENT_TYPE &content, bool videoFolder=false, bool useLocal=true, const CVideoInfoTag *showInfo=NULL, bool libraryImport=false)
 Add an item to the database.
 
bool RetrieveVideoInfo (CFileItemList &items, bool bDirNames, CONTENT_TYPE content, bool useLocal=true, CScraperUrl *pURL=NULL, bool fetchEpisodes=true, CGUIDialogProgress *pDlgProgress=NULL)
 Retrieve information for a list of items and add them to the database.
 
void GetArtwork (CFileItem *pItem, const CONTENT_TYPE &content, bool bApplyToDir=false, bool useLocal=true, const std::string &actorArtPath="")
 Retrieve any artwork associated with an item.
 
bool EnumerateEpisodeItem (const CFileItem *item, EPISODELIST &episodeList)
 
- 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 ApplyThumbToFolder (const std::string &folder, const std::string &imdbThumb)
 
static bool DownloadFailed (CGUIDialogProgress *pDlgProgress)
 
static void GetSeasonThumbs (const CVideoInfoTag &show, std::map< int, std::map< std::string, std::string > > &art, const std::vector< std::string > &artTypes, bool useLocal=true)
 Get season thumbs for a tvshow. All seasons (regardless of whether the user has episodes) are added to the art map.
 
static std::string GetImage (const CScraperUrl::SUrlEntry &image, const std::string &itemPath)
 
static std::string GetMovieSetInfoFolder (const std::string &setTitle)
 

Protected Member Functions

virtual void Process ()
 
bool DoScan (const std::string &strDirectory) override
 
INFO_RET RetrieveInfoForTvShow (CFileItem *pItem, bool bDirNames, ADDON::ScraperPtr &scraper, bool useLocal, CScraperUrl *pURL, bool fetchEpisodes, CGUIDialogProgress *pDlgProgress)
 
INFO_RET RetrieveInfoForMovie (CFileItem *pItem, bool bDirNames, ADDON::ScraperPtr &scraper, bool useLocal, CScraperUrl *pURL, CGUIDialogProgress *pDlgProgress)
 
INFO_RET RetrieveInfoForMusicVideo (CFileItem *pItem, bool bDirNames, ADDON::ScraperPtr &scraper, bool useLocal, CScraperUrl *pURL, CGUIDialogProgress *pDlgProgress)
 
INFO_RET RetrieveInfoForEpisodes (CFileItem *item, long showID, const ADDON::ScraperPtr &scraper, bool useLocal, CGUIDialogProgress *progress=NULL)
 
bool ProgressCancelled (CGUIDialogProgress *progress, int heading, const std::string &line1)
 Update the progress bar with the heading and line and check for cancellation.
 
int FindVideo (const std::string &title, int year, const ADDON::ScraperPtr &scraper, CScraperUrl &url, CGUIDialogProgress *progress)
 Find a url for the given video using the given scraper.
 
int FindVideoUsingTag (CFileItem &item, const ADDON::ScraperPtr &scraper, CScraperUrl &url, CGUIDialogProgress *progress)
 Find a url for the given video using the given scraper.
 
bool GetDetails (CFileItem *pItem, const std::unordered_map< std::string, std::string > &uniqueIDs, CScraperUrl &url, const ADDON::ScraperPtr &scraper, VIDEO::IVideoInfoTagLoader *nfoFile=nullptr, CGUIDialogProgress *pDialog=nullptr)
 Retrieve detailed information for an item from an online source, optionally supplemented with local data.
 
bool GetEpisodeAndSeasonFromRegExp (CRegExp &reg, EPISODE &episodeInfo, int defaultSeason)
 Extract episode and season numbers from a processed regexp.
 
bool GetAirDateFromRegExp (CRegExp &reg, EPISODE &episodeInfo)
 Extract episode air-date from a processed regexp.
 
bool GetEpisodeTitleFromRegExp (CRegExp &reg, EPISODE &episodeInfo)
 Extract episode title from a processed regexp.
 
void FetchActorThumbs (std::vector< SActorInfo > &actors, const std::string &strPath)
 Fetch thumbs for actors Updates each actor with their thumb (local or online)
 
std::string GetFastHash (const std::string &directory, const std::vector< std::string > &excludes) const
 Retrieve a "fast" hash of the given directory (if available) Performs a stat() on the directory, and uses modified time to create a "fast" hash of the folder. If no modified time is available, the create time is used, and if neither are available, an empty hash is returned. In case exclude from scan expressions are present, the string array will be appended to the md5 hash to ensure we're doing a re-scan whenever the user modifies those.
 
std::string GetRecursiveFastHash (const std::string &directory, const std::vector< std::string > &excludes) const
 Retrieve a "fast" hash of the given directory recursively (if available) Performs a stat() on the directory, and uses modified time to create a "fast" hash of each folder. If no modified time is available, the create time is used, and if neither are available, an empty hash is returned. In case exclude from scan expressions are present, the string array will be appended to the md5 hash to ensure we're doing a re-scan whenever the user modifies those.
 
bool CanFastHash (const CFileItemList &items, const std::vector< std::string > &excludes) const
 Decide whether a folder listing could use the "fast" hash Fast hashing can be done whenever the folder contains no scannable subfolders, as the fast hash technique uses modified time to determine when folder content changes, which is generally not propagated up the directory tree.
 
INFO_RET OnProcessSeriesFolder (EPISODELIST &files, const ADDON::ScraperPtr &scraper, bool useLocal, const CVideoInfoTag &showInfo, CGUIDialogProgress *pDlgProgress=NULL)
 Process a series folder, filling in episode details and adding them to the database.
 
bool EnumerateSeriesFolder (CFileItem *item, EPISODELIST &episodeList)
 
bool ProcessItemByVideoInfoTag (const CFileItem *item, EPISODELIST &episodeList)
 
bool AddVideoExtras (CFileItemList &items, const CONTENT_TYPE &content, const std::string &path)
 
bool ProcessVideoVersion (VideoDbContentType itemType, int dbId)
 
- Protected Member Functions inherited from CInfoScanner
 CInfoScanner ()=default
 Protected constructor to only allow subclass instances.
 

Static Protected Member Functions

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

Protected Attributes

bool m_bStop
 
bool m_scanAll
 
bool m_ignoreVideoVersions {false}
 
bool m_ignoreVideoExtras {false}
 
std::string m_strStartDir
 
CVideoDatabase m_database
 
std::set< std::string > m_pathsToCount
 
std::set< intm_pathsToClean
 
- 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.
 

Additional Inherited Members

- 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
}
 

Constructor & Destructor Documentation

◆ CVideoInfoScanner()

KODI::VIDEO::CVideoInfoScanner::CVideoInfoScanner ( )

◆ ~CVideoInfoScanner()

KODI::VIDEO::CVideoInfoScanner::~CVideoInfoScanner ( )
overridedefault

Member Function Documentation

◆ AddVideo()

long KODI::VIDEO::CVideoInfoScanner::AddVideo ( CFileItem * pItem,
const CONTENT_TYPE & content,
bool videoFolder = false,
bool useLocal = true,
const CVideoInfoTag * showInfo = NULL,
bool libraryImport = false )

Add an item to the database.

Parameters
pItemitem to add to the database.
contentcontent type of the item.
videoFolderwhether the video is represented by a folder (single movie per folder). Defaults to false.
useLocalwhether to use local information for artwork etc.
showInfopointer to CVideoInfoTag details for the show if this is an episode. Defaults to NULL.
libraryImportWhether this call belongs to a full library import or not. Defaults to false.
Returns
database id of the added item, or -1 on failure.

◆ AddVideoExtras()

bool KODI::VIDEO::CVideoInfoScanner::AddVideoExtras ( CFileItemList & items,
const CONTENT_TYPE & content,
const std::string & path )
protected

◆ ApplyThumbToFolder()

void KODI::VIDEO::CVideoInfoScanner::ApplyThumbToFolder ( const std::string & folder,
const std::string & imdbThumb )
static

◆ CanFastHash()

bool KODI::VIDEO::CVideoInfoScanner::CanFastHash ( const CFileItemList & items,
const std::vector< std::string > & excludes ) const
protected

Decide whether a folder listing could use the "fast" hash Fast hashing can be done whenever the folder contains no scannable subfolders, as the fast hash technique uses modified time to determine when folder content changes, which is generally not propagated up the directory tree.

Parameters
itemsthe directory listing
excludesstring array of exclude expressions
Returns
true if this directory listing can be fast hashed, false otherwise

◆ DoScan()

bool KODI::VIDEO::CVideoInfoScanner::DoScan ( const std::string & strDirectory)
overrideprotectedvirtual

Implements CInfoScanner.

◆ DownloadFailed()

bool KODI::VIDEO::CVideoInfoScanner::DownloadFailed ( CGUIDialogProgress * pDlgProgress)
static

◆ EnumerateEpisodeItem()

bool KODI::VIDEO::CVideoInfoScanner::EnumerateEpisodeItem ( const CFileItem * item,
EPISODELIST & episodeList )

◆ EnumerateSeriesFolder()

bool KODI::VIDEO::CVideoInfoScanner::EnumerateSeriesFolder ( CFileItem * item,
EPISODELIST & episodeList )
protected

◆ FetchActorThumbs()

void KODI::VIDEO::CVideoInfoScanner::FetchActorThumbs ( std::vector< SActorInfo > & actors,
const std::string & strPath )
protected

Fetch thumbs for actors Updates each actor with their thumb (local or online)

Parameters
actors- vector of SActorInfo
strPath- path on filesystem to look for local thumbs

◆ FindVideo()

int KODI::VIDEO::CVideoInfoScanner::FindVideo ( const std::string & title,
int year,
const ADDON::ScraperPtr & scraper,
CScraperUrl & url,
CGUIDialogProgress * progress )
protected

Find a url for the given video using the given scraper.

Parameters
titletitle of the video to lookup
yearyear of the video to lookup
scraperscraper to use for the lookup
url[out] returned url from the scraper
progressCGUIDialogProgress bar
Returns
>0 on success, <0 on failure (cancellation), and 0 on no info found

◆ FindVideoUsingTag()

int KODI::VIDEO::CVideoInfoScanner::FindVideoUsingTag ( CFileItem & item,
const ADDON::ScraperPtr & scraper,
CScraperUrl & url,
CGUIDialogProgress * progress )
protected

Find a url for the given video using the given scraper.

Parameters
itemthe video to lookup
scraperscraper to use for the lookup
url[out] returned url from the scraper
progressCGUIDialogProgress bar
Returns
>0 on success, <0 on failure (cancellation), and 0 on no info found

◆ GetAirDateFromRegExp()

bool KODI::VIDEO::CVideoInfoScanner::GetAirDateFromRegExp ( CRegExp & reg,
EPISODE & episodeInfo )
protected

Extract episode air-date from a processed regexp.

Parameters
regRegular expression object with at least 3 matches
episodeInfoEpisode information to fill in.
Returns
true on success (3 matches), false on failure (fewer than 3 matches)

◆ GetArtwork()

void KODI::VIDEO::CVideoInfoScanner::GetArtwork ( CFileItem * pItem,
const CONTENT_TYPE & content,
bool bApplyToDir = false,
bool useLocal = true,
const std::string & actorArtPath = "" )

Retrieve any artwork associated with an item.

Parameters
pItemitem to find artwork for.
contentcontent type of the item.
bApplyToDirwhether we should apply any thumbs to a folder. Defaults to false.
useLocalwhether we should use local thumbs. Defaults to true.
actorArtPaththe path to search for actor thumbs. Defaults to empty.

◆ GetDetails()

bool KODI::VIDEO::CVideoInfoScanner::GetDetails ( CFileItem * pItem,
const std::unordered_map< std::string, std::string > & uniqueIDs,
CScraperUrl & url,
const ADDON::ScraperPtr & scraper,
VIDEO::IVideoInfoTagLoader * nfoFile = nullptr,
CGUIDialogProgress * pDialog = nullptr )
protected

Retrieve detailed information for an item from an online source, optionally supplemented with local data.

Todo
sort out some better return codes.
Parameters
pItemitem to retrieve online details for.
uniqueIDsUnique IDs for additional information for scrapers.
urlURL to use to retrieve online details.
scraperScraper that handles parsing the online data.
nfoFileif set, we override the online data with the locally supplied data. Defaults to NULL.
pDialogprogress dialog to update and check for cancellation during processing. Defaults to NULL.
Returns
true if information is found, false if an error occurred, the lookup was cancelled, or no information was found.

◆ GetEpisodeAndSeasonFromRegExp()

bool KODI::VIDEO::CVideoInfoScanner::GetEpisodeAndSeasonFromRegExp ( CRegExp & reg,
EPISODE & episodeInfo,
int defaultSeason )
protected

Extract episode and season numbers from a processed regexp.

Parameters
regRegular expression object with at least 2 matches
episodeInfoEpisode information to fill in.
defaultSeasonSeason to use if not found in reg.
Returns
true on success (2 matches), false on failure (fewer than 2 matches)

◆ GetEpisodeTitleFromRegExp()

bool KODI::VIDEO::CVideoInfoScanner::GetEpisodeTitleFromRegExp ( CRegExp & reg,
EPISODE & episodeInfo )
protected

Extract episode title from a processed regexp.

Parameters
regRegular expression object with at least 1 match
episodeInfoEpisode information to fill in.
Returns
true on success (1 match), false on failure (no matches)

◆ GetFastHash()

std::string KODI::VIDEO::CVideoInfoScanner::GetFastHash ( const std::string & directory,
const std::vector< std::string > & excludes ) const
protected

Retrieve a "fast" hash of the given directory (if available) Performs a stat() on the directory, and uses modified time to create a "fast" hash of the folder. If no modified time is available, the create time is used, and if neither are available, an empty hash is returned. In case exclude from scan expressions are present, the string array will be appended to the md5 hash to ensure we're doing a re-scan whenever the user modifies those.

Parameters
directoryfolder to hash
excludesstring array of exclude expressions
Returns
the md5 hash of the folder"

◆ GetImage()

std::string KODI::VIDEO::CVideoInfoScanner::GetImage ( const CScraperUrl::SUrlEntry & image,
const std::string & itemPath )
static

◆ GetMovieSetInfoFolder()

std::string KODI::VIDEO::CVideoInfoScanner::GetMovieSetInfoFolder ( const std::string & setTitle)
static

◆ GetPathHash()

int KODI::VIDEO::CVideoInfoScanner::GetPathHash ( const CFileItemList & items,
std::string & hash )
staticprotected

◆ GetRecursiveFastHash()

std::string KODI::VIDEO::CVideoInfoScanner::GetRecursiveFastHash ( const std::string & directory,
const std::vector< std::string > & excludes ) const
protected

Retrieve a "fast" hash of the given directory recursively (if available) Performs a stat() on the directory, and uses modified time to create a "fast" hash of each folder. If no modified time is available, the create time is used, and if neither are available, an empty hash is returned. In case exclude from scan expressions are present, the string array will be appended to the md5 hash to ensure we're doing a re-scan whenever the user modifies those.

Parameters
directoryfolder to hash (recursively)
excludesstring array of exclude expressions
Returns
the md5 hash of the folder
Todo
some filesystems may return the mtime/ctime inline, in which case this is unnecessarily expensive. Consider supporting Stat() in our directory cache?

◆ GetSeasonThumbs()

void KODI::VIDEO::CVideoInfoScanner::GetSeasonThumbs ( const CVideoInfoTag & show,
std::map< int, std::map< std::string, std::string > > & art,
const std::vector< std::string > & artTypes,
bool useLocal = true )
static

Get season thumbs for a tvshow. All seasons (regardless of whether the user has episodes) are added to the art map.

Parameters
showtvshow info tag
artartwork map to which season thumbs are added.
useLocalwhether to use local thumbs, defaults to true

◆ OnProcessSeriesFolder()

CInfoScanner::INFO_RET KODI::VIDEO::CVideoInfoScanner::OnProcessSeriesFolder ( EPISODELIST & files,
const ADDON::ScraperPtr & scraper,
bool useLocal,
const CVideoInfoTag & showInfo,
CGUIDialogProgress * pDlgProgress = NULL )
protected

Process a series folder, filling in episode details and adding them to the database.

Todo
Ideally we would return INFO_HAVE_ALREADY if we don't have to update any episodes and we should return INFO_NOT_FOUND only if no information is found for any of the episodes. INFO_ADDED then indicates we've added one or more episodes.
Parameters
filesthe episode files to process.
scraperscraper to use for finding online info
showInfoinformation for the show.
pDlgProcessprogress dialog to update during processing. Defaults to NULL.
Returns
INFO_ERROR on failure, INFO_CANCELLED on cancellation, INFO_NOT_FOUND if an episode isn't found, or INFO_ADDED if all episodes are added.
Todo
should we just skip to the next episode?

◆ Process()

void KODI::VIDEO::CVideoInfoScanner::Process ( )
protectedvirtual

◆ ProcessItemByVideoInfoTag()

bool KODI::VIDEO::CVideoInfoScanner::ProcessItemByVideoInfoTag ( const CFileItem * item,
EPISODELIST & episodeList )
protected

◆ ProcessVideoVersion()

bool KODI::VIDEO::CVideoInfoScanner::ProcessVideoVersion ( VideoDbContentType itemType,
int dbId )
protected

◆ ProgressCancelled()

bool KODI::VIDEO::CVideoInfoScanner::ProgressCancelled ( CGUIDialogProgress * progress,
int heading,
const std::string & line1 )
protected

Update the progress bar with the heading and line and check for cancellation.

Parameters
progressCGUIDialogProgress bar
headingstring id of heading
line1string to set for the first line
Returns
true if the user has cancelled the scanner, false otherwise

◆ RetrieveInfoForEpisodes()

CInfoScanner::INFO_RET KODI::VIDEO::CVideoInfoScanner::RetrieveInfoForEpisodes ( CFileItem * item,
long showID,
const ADDON::ScraperPtr & scraper,
bool useLocal,
CGUIDialogProgress * progress = NULL )
protected

◆ RetrieveInfoForMovie()

CInfoScanner::INFO_RET KODI::VIDEO::CVideoInfoScanner::RetrieveInfoForMovie ( CFileItem * pItem,
bool bDirNames,
ADDON::ScraperPtr & scraper,
bool useLocal,
CScraperUrl * pURL,
CGUIDialogProgress * pDlgProgress )
protected
Todo
This is not strictly correct as we could fail to download information here or error, or be cancelled

◆ RetrieveInfoForMusicVideo()

CInfoScanner::INFO_RET KODI::VIDEO::CVideoInfoScanner::RetrieveInfoForMusicVideo ( CFileItem * pItem,
bool bDirNames,
ADDON::ScraperPtr & scraper,
bool useLocal,
CScraperUrl * pURL,
CGUIDialogProgress * pDlgProgress )
protected
Todo
This is not strictly correct as we could fail to download information here or error, or be cancelled

◆ RetrieveInfoForTvShow()

CInfoScanner::INFO_RET KODI::VIDEO::CVideoInfoScanner::RetrieveInfoForTvShow ( CFileItem * pItem,
bool bDirNames,
ADDON::ScraperPtr & scraper,
bool useLocal,
CScraperUrl * pURL,
bool fetchEpisodes,
CGUIDialogProgress * pDlgProgress )
protected

◆ RetrieveVideoInfo()

bool KODI::VIDEO::CVideoInfoScanner::RetrieveVideoInfo ( CFileItemList & items,
bool bDirNames,
CONTENT_TYPE content,
bool useLocal = true,
CScraperUrl * pURL = NULL,
bool fetchEpisodes = true,
CGUIDialogProgress * pDlgProgress = NULL )

Retrieve information for a list of items and add them to the database.

Parameters
itemslist of items to retrieve info for.
bDirNameswhether we should use folder or file names for lookups.
contenttype of content to retrieve.
useLocalshould local data (.nfo and art) be used. Defaults to true.
pURLan optional URL to use to retrieve online info. Defaults to NULL.
fetchEpisodeswhether we are fetching episodes with shows. Defaults to true.
pDlgProgressprogress dialog to update and check for cancellation during processing. Defaults to NULL.
Returns
true if we successfully found information for some items, false otherwise

◆ Start()

void KODI::VIDEO::CVideoInfoScanner::Start ( const std::string & strDirectory,
bool scanAll = false )

Scan a folder using the background scanner.

Parameters
strDirectorypath to scan
scanAllwhether to scan everything not already scanned (regardless of whether the user normally doesn't want a folder scanned.) Defaults to false.

◆ Stop()

void KODI::VIDEO::CVideoInfoScanner::Stop ( )

Member Data Documentation

◆ m_bStop

bool KODI::VIDEO::CVideoInfoScanner::m_bStop
protected

◆ m_database

CVideoDatabase KODI::VIDEO::CVideoInfoScanner::m_database
protected

◆ m_ignoreVideoExtras

bool KODI::VIDEO::CVideoInfoScanner::m_ignoreVideoExtras {false}
protected

◆ m_ignoreVideoVersions

bool KODI::VIDEO::CVideoInfoScanner::m_ignoreVideoVersions {false}
protected

◆ m_pathsToClean

std::set<int> KODI::VIDEO::CVideoInfoScanner::m_pathsToClean
protected

◆ m_pathsToCount

std::set<std::string> KODI::VIDEO::CVideoInfoScanner::m_pathsToCount
protected

◆ m_scanAll

bool KODI::VIDEO::CVideoInfoScanner::m_scanAll
protected

◆ m_strStartDir

std::string KODI::VIDEO::CVideoInfoScanner::m_strStartDir
protected

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