Kodi Documentation  18.0
Kodi is an open source media player and entertainment hub.
VIDEO::CVideoInfoScanner Class Reference

#include <VideoInfoScanner.h>

Inheritance diagram for 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. More...
 
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. More...
 
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. More...
 
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. More...
 
bool EnumerateEpisodeItem (const CFileItem *item, EPISODELIST &episodeList)
 
- Public Member Functions inherited from CInfoScanner
virtual ~CInfoScanner ()=default
 Empty destructor. More...
 
bool HasNoMedia (const std::string &strDirectory) const
 Check if the folder is excluded from scanning process. More...
 
void ShowDialog (bool show)
 Set whether or not to show a progress dialog. More...
 
bool IsScanning () const
 Returns whether or not a scan is in progress. More...
 

Static Public Member Functions

static void ApplyThumbToFolder (const std::string &folder, const std::string &imdbThumb)
 
static bool DownloadFailed (CGUIDialogProgress *pDlgProgress)
 
static std::string GetArtTypeFromSize (unsigned int width, unsigned int height)
 Retrieve the art type for an image from the given size. More...
 
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. More...
 
static std::string GetImage (const CScraperUrl::SUrlEntry &image, const std::string &itemPath)
 
static std::string GetFanart (CFileItem *pItem, bool useLocal)
 

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. More...
 
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. More...
 
int FindVideoUsingTag (CFileItem &item, const ADDON::ScraperPtr &scraper, CScraperUrl &url, CGUIDialogProgress *progress)
 Find a url for the given video using the given scraper. More...
 
bool GetDetails (CFileItem *pItem, 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. More...
 
bool GetEpisodeAndSeasonFromRegExp (CRegExp &reg, EPISODE &episodeInfo, int defaultSeason)
 Extract episode and season numbers from a processed regexp. More...
 
bool GetAirDateFromRegExp (CRegExp &reg, EPISODE &episodeInfo)
 Extract episode air-date from a processed regexp. More...
 
void FetchActorThumbs (std::vector< SActorInfo > &actors, const std::string &strPath)
 Fetch thumbs for actors Updates each actor with their thumb (local or online) More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
bool EnumerateSeriesFolder (CFileItem *item, EPISODELIST &episodeList)
 
bool ProcessItemByVideoInfoTag (const CFileItem *item, EPISODELIST &episodeList)
 
- Protected Member Functions inherited from CInfoScanner
 CInfoScanner ()=default
 Protected constructor to only allow subclass instances. More...
 

Static Protected Member Functions

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

Protected Attributes

bool m_bStop
 
bool m_scanAll
 
std::string m_strStartDir
 
CVideoDatabase m_database
 
std::set< std::string > m_pathsToCount
 
std::set< int > m_pathsToClean
 
- Protected Attributes inherited from CInfoScanner
std::set< std::string > m_pathsToScan
 Set of paths to scan. More...
 
bool m_showDialog = false
 Whether or not to show progress bar dialog. More...
 
CGUIDialogProgressBarHandlem_handle = nullptr
 Progress bar handle. More...
 
bool m_bRunning = false
 Whether or not scanner is running. More...
 
bool m_bCanInterrupt = false
 Whether or not scanner is currently interruptable. More...
 
bool m_bClean = false
 Whether or not to perform cleaning during scanning. More...
 

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()

VIDEO::CVideoInfoScanner::CVideoInfoScanner ( )

§ ~CVideoInfoScanner()

VIDEO::CVideoInfoScanner::~CVideoInfoScanner ( )
overridedefault

Member Function Documentation

§ AddVideo()

long 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.

§ ApplyThumbToFolder()

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

§ CanFastHash()

bool 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 VIDEO::CVideoInfoScanner::DoScan ( const std::string &  strDirectory)
overrideprotectedvirtual

Implements CInfoScanner.

§ DownloadFailed()

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

§ EnumerateEpisodeItem()

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

§ EnumerateSeriesFolder()

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

§ FetchActorThumbs()

void 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 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 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 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)

§ GetArtTypeFromSize()

std::string VIDEO::CVideoInfoScanner::GetArtTypeFromSize ( unsigned int  width,
unsigned int  height 
)
static

Retrieve the art type for an image from the given size.

Parameters
widththe width of the image.
heightthe height of the image.
Returns
"poster" if the aspect ratio is at most 4:5, "banner" if the aspect ratio is at least 1:4, "thumb" otherwise.

§ GetArtwork()

void 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 VIDEO::CVideoInfoScanner::GetDetails ( CFileItem pItem,
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.
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 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)

§ GetFanart()

std::string VIDEO::CVideoInfoScanner::GetFanart ( CFileItem pItem,
bool  useLocal 
)
static

§ GetFastHash()

std::string 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 VIDEO::CVideoInfoScanner::GetImage ( const CScraperUrl::SUrlEntry image,
const std::string &  itemPath 
)
static

§ GetPathHash()

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

§ GetRecursiveFastHash()

std::string 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 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 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 VIDEO::CVideoInfoScanner::Process ( void  )
protectedvirtual

§ ProcessItemByVideoInfoTag()

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

§ ProgressCancelled()

bool 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 VIDEO::CVideoInfoScanner::RetrieveInfoForEpisodes ( CFileItem item,
long  showID,
const ADDON::ScraperPtr scraper,
bool  useLocal,
CGUIDialogProgress progress = NULL 
)
protected

§ RetrieveInfoForMovie()

CInfoScanner::INFO_RET 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 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 VIDEO::CVideoInfoScanner::RetrieveInfoForTvShow ( CFileItem pItem,
bool  bDirNames,
ADDON::ScraperPtr scraper,
bool  useLocal,
CScraperUrl pURL,
bool  fetchEpisodes,
CGUIDialogProgress pDlgProgress 
)
protected

§ RetrieveVideoInfo()

bool 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 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 VIDEO::CVideoInfoScanner::Stop ( void  )

Member Data Documentation

§ m_bStop

bool VIDEO::CVideoInfoScanner::m_bStop
protected

§ m_database

CVideoDatabase VIDEO::CVideoInfoScanner::m_database
protected

§ m_pathsToClean

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

§ m_pathsToCount

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

§ m_scanAll

bool VIDEO::CVideoInfoScanner::m_scanAll
protected

§ m_strStartDir

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

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