kodi
VideoInfoScanner.h
1 /*
2  * Copyright (C) 2005-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "InfoScanner.h"
12 #include "VideoDatabase.h"
13 #include "addons/Scraper.h"
14 #include "guilib/GUIListItem.h"
15 
16 #include <set>
17 #include <string>
18 #include <vector>
19 
20 class CRegExp;
21 class CFileItem;
22 class CFileItemList;
23 
24 namespace VIDEO
25 {
26  class IVideoInfoTagLoader;
27 
28  typedef struct SScanSettings
29  {
31  {
32  parent_name = false;
33  parent_name_root = false;
34  noupdate = false;
35  exclude = false;
36  m_allExtAudio = false;
37  recurse = 1;
38  }
39  bool parent_name; /* use the parent dirname as name of lookup */
40  bool parent_name_root; /* use the name of directory where scan started as name for files in that dir */
41  int recurse; /* recurse into sub folders (indicate levels) */
42  bool noupdate; /* exclude from update library function */
43  bool exclude; /* exclude this path from scraping */
44  bool m_allExtAudio; /* treat all audio files in video directory as external tracks */
45  } SScanSettings;
46 
48  {
49  public:
51  ~CVideoInfoScanner() override;
52 
57  void Start(const std::string& strDirectory, bool scanAll = false);
58  void Stop();
59 
69  long AddVideo(CFileItem *pItem, const CONTENT_TYPE &content, bool videoFolder = false, bool useLocal = true, const CVideoInfoTag *showInfo = NULL, bool libraryImport = false);
70 
81  bool RetrieveVideoInfo(CFileItemList& items, bool bDirNames, CONTENT_TYPE content, bool useLocal = true, CScraperUrl *pURL = NULL, bool fetchEpisodes = true, CGUIDialogProgress* pDlgProgress = NULL);
82 
83  static void ApplyThumbToFolder(const std::string &folder, const std::string &imdbThumb);
84  static bool DownloadFailed(CGUIDialogProgress* pDlgProgress);
85 
93  void GetArtwork(CFileItem *pItem, const CONTENT_TYPE &content, bool bApplyToDir=false, bool useLocal=true, const std::string &actorArtPath = "");
94 
101  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);
102  static std::string GetImage(const CScraperUrl::SUrlEntry &image, const std::string& itemPath);
103 
104  bool EnumerateEpisodeItem(const CFileItem *item, EPISODELIST& episodeList);
105 
106  static std::string GetMovieSetInfoFolder(const std::string& setTitle);
107 
108  protected:
109  virtual void Process();
110  bool DoScan(const std::string& strDirectory) override;
111 
112  INFO_RET RetrieveInfoForTvShow(CFileItem *pItem, bool bDirNames, ADDON::ScraperPtr &scraper, bool useLocal, CScraperUrl* pURL, bool fetchEpisodes, CGUIDialogProgress* pDlgProgress);
113  INFO_RET RetrieveInfoForMovie(CFileItem *pItem, bool bDirNames, ADDON::ScraperPtr &scraper, bool useLocal, CScraperUrl* pURL, CGUIDialogProgress* pDlgProgress);
114  INFO_RET RetrieveInfoForMusicVideo(CFileItem *pItem, bool bDirNames, ADDON::ScraperPtr &scraper, bool useLocal, CScraperUrl* pURL, CGUIDialogProgress* pDlgProgress);
115  INFO_RET RetrieveInfoForEpisodes(CFileItem *item, long showID, const ADDON::ScraperPtr &scraper, bool useLocal, CGUIDialogProgress *progress = NULL);
116 
123  bool ProgressCancelled(CGUIDialogProgress* progress, int heading, const std::string &line1);
124 
133  int FindVideo(const std::string &title, int year, const ADDON::ScraperPtr &scraper, CScraperUrl &url, CGUIDialogProgress *progress);
134 
142  int FindVideoUsingTag(CFileItem& item, const ADDON::ScraperPtr &scraper, CScraperUrl &url, CGUIDialogProgress *progress);
143 
154  bool GetDetails(CFileItem* pItem,
155  const std::unordered_map<std::string, std::string>& uniqueIDs,
156  CScraperUrl& url,
157  const ADDON::ScraperPtr& scraper,
158  VIDEO::IVideoInfoTagLoader* nfoFile = nullptr,
159  CGUIDialogProgress* pDialog = nullptr);
160 
167  bool GetEpisodeAndSeasonFromRegExp(CRegExp &reg, EPISODE &episodeInfo, int defaultSeason);
168 
174  bool GetAirDateFromRegExp(CRegExp &reg, EPISODE &episodeInfo);
175 
181  bool GetEpisodeTitleFromRegExp(CRegExp& reg, EPISODE& episodeInfo);
182 
188  void FetchActorThumbs(std::vector<SActorInfo>& actors, const std::string& strPath);
189 
190  static int GetPathHash(const CFileItemList &items, std::string &hash);
191 
202  std::string GetFastHash(const std::string &directory, const std::vector<std::string> &excludes) const;
203 
214  std::string GetRecursiveFastHash(const std::string &directory, const std::vector<std::string> &excludes) const;
215 
224  bool CanFastHash(const CFileItemList &items, const std::vector<std::string> &excludes) const;
225 
237  INFO_RET OnProcessSeriesFolder(EPISODELIST& files, const ADDON::ScraperPtr &scraper, bool useLocal, const CVideoInfoTag& showInfo, CGUIDialogProgress* pDlgProgress = NULL);
238 
239  bool EnumerateSeriesFolder(CFileItem* item, EPISODELIST& episodeList);
240  bool ProcessItemByVideoInfoTag(const CFileItem *item, EPISODELIST &episodeList);
241 
242  bool AddVideoExtras(CFileItemList& items, const CONTENT_TYPE& content, const std::string& path);
243  bool ProcessVideoVersion(VideoDbContentType itemType, int dbId);
244 
245  bool m_bStop;
246  bool m_scanAll;
247  bool m_ignoreVideoVersions{false};
248  bool m_ignoreVideoExtras{false};
249  std::string m_strStartDir;
250  CVideoDatabase m_database;
251  std::set<std::string> m_pathsToCount;
252  std::set<int> m_pathsToClean;
253 
254  private:
255  static void AddLocalItemArtwork(CGUIListItem::ArtMap& itemArt,
256  const std::vector<std::string>& wantedArtTypes, const std::string& itemPath,
257  bool addAll, bool exactName);
258 
265  static std::string GetArtTypeFromSize(unsigned int width, unsigned int height);
266  };
267 }
268 
Definition: Episode.h:23
Definition: VideoInfoScanner.h:28
Base class for video tag loaders.
Definition: IVideoInfoTagLoader.h:25
Represents a list of files.
Definition: FileItem.h:702
Definition: VideoInfoScanner.h:47
Definition: scraper.py:1
Definition: VideoDatabase.h:419
Definition: RegExp.h:27
Definition: Application.h:72
Definition: InfoScanner.h:17
Definition: ScraperUrl.h:30
Definition: GUIDialogProgress.h:16
Definition: VideoInfoTag.h:53
INFO_RET
Return values from the information lookup functions.
Definition: InfoScanner.h:23
Represents a file on a share.
Definition: FileItem.h:102
Definition: ScraperUrl.h:21