xbmc
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 
153  bool GetDetails(CFileItem *pItem, CScraperUrl &url,
154  const ADDON::ScraperPtr &scraper,
155  VIDEO::IVideoInfoTagLoader* nfoFile = nullptr,
156  CGUIDialogProgress* pDialog = nullptr);
157 
164  bool GetEpisodeAndSeasonFromRegExp(CRegExp &reg, EPISODE &episodeInfo, int defaultSeason);
165 
171  bool GetAirDateFromRegExp(CRegExp &reg, EPISODE &episodeInfo);
172 
178  bool GetEpisodeTitleFromRegExp(CRegExp& reg, EPISODE& episodeInfo);
179 
185  void FetchActorThumbs(std::vector<SActorInfo>& actors, const std::string& strPath);
186 
187  static int GetPathHash(const CFileItemList &items, std::string &hash);
188 
199  std::string GetFastHash(const std::string &directory, const std::vector<std::string> &excludes) const;
200 
211  std::string GetRecursiveFastHash(const std::string &directory, const std::vector<std::string> &excludes) const;
212 
221  bool CanFastHash(const CFileItemList &items, const std::vector<std::string> &excludes) const;
222 
234  INFO_RET OnProcessSeriesFolder(EPISODELIST& files, const ADDON::ScraperPtr &scraper, bool useLocal, const CVideoInfoTag& showInfo, CGUIDialogProgress* pDlgProgress = NULL);
235 
236  bool EnumerateSeriesFolder(CFileItem* item, EPISODELIST& episodeList);
237  bool ProcessItemByVideoInfoTag(const CFileItem *item, EPISODELIST &episodeList);
238 
239  bool m_bStop;
240  bool m_scanAll;
241  std::string m_strStartDir;
242  CVideoDatabase m_database;
243  std::set<std::string> m_pathsToCount;
244  std::set<int> m_pathsToClean;
245 
246  private:
247  static void AddLocalItemArtwork(CGUIListItem::ArtMap& itemArt,
248  const std::vector<std::string>& wantedArtTypes, const std::string& itemPath,
249  bool addAll, bool exactName);
250 
257  static std::string GetArtTypeFromSize(unsigned int width, unsigned int height);
258  };
259 }
260 
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:721
Definition: VideoInfoScanner.h:47
Definition: scraper.py:1
Definition: VideoDatabase.h:395
Definition: RegExp.h:27
Definition: Application.h:74
Definition: InfoScanner.h:17
Definition: ScraperUrl.h:30
Definition: GUIDialogProgress.h:16
Definition: VideoInfoTag.h:51
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