kodi
VideoInfoDownloader.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 "Episode.h"
12 #include "VideoInfoTag.h"
13 #include "addons/Scraper.h"
14 #include "threads/Thread.h"
15 
16 #include <string>
17 #include <vector>
18 
19 // forward declarations
20 class CXBMCTinyXML;
21 class CGUIDialogProgress;
22 
23 namespace ADDON
24 {
25 class CScraperError;
26 }
27 namespace XFILE
28 {
29 class CurlFile;
30 }
31 
32 typedef std::vector<CScraperUrl> MOVIELIST;
33 
35 {
36 public:
37  explicit CVideoInfoDownloader(const ADDON::ScraperPtr &scraper);
38  ~CVideoInfoDownloader() override;
39 
40  // threaded lookup functions
41 
49  int FindMovie(const std::string& movieTitle, int movieYear, MOVIELIST& movielist, CGUIDialogProgress *pProgress = NULL);
50 
55  bool GetArtwork(CVideoInfoTag &details);
56 
57  bool GetDetails(const std::unordered_map<std::string, std::string>& uniqueIDs,
58  const CScraperUrl& url,
59  CVideoInfoTag& movieDetails,
60  CGUIDialogProgress* pProgress = NULL);
61  bool GetEpisodeDetails(const CScraperUrl& url, CVideoInfoTag &movieDetails, CGUIDialogProgress *pProgress = NULL);
62  bool GetEpisodeList(const CScraperUrl& url, VIDEO::EPISODELIST& details, CGUIDialogProgress *pProgress = NULL);
63 
64  static void ShowErrorDialog(const ADDON::CScraperError &sce);
65 
66 protected:
67  enum LOOKUP_STATE { DO_NOTHING = 0,
68  FIND_MOVIE = 1,
69  GET_DETAILS = 2,
70  GET_EPISODE_LIST = 3,
71  GET_EPISODE_DETAILS = 4 };
72 
73  XFILE::CCurlFile* m_http;
74  std::string m_movieTitle;
75  int m_movieYear;
76  std::unordered_map<std::string, std::string> m_uniqueIDs;
77  MOVIELIST m_movieList;
78  CVideoInfoTag m_movieDetails;
79  CScraperUrl m_url;
80  VIDEO::EPISODELIST m_episode;
81  LOOKUP_STATE m_state = DO_NOTHING;
82  int m_found = 0;
83  ADDON::ScraperPtr m_info;
84 
85  // threaded stuff
86  void Process() override;
87  void CloseThread();
88 
89  int InternalFindMovie(const std::string& movieTitle, int movieYear, MOVIELIST& movielist, bool cleanChars = true);
90 };
91 
Definition: Scraper.h:41
Definition: Thread.h:44
Definition: XBMCTinyXML.h:33
Definition: VideoInfoDownloader.h:34
Definition: scraper.py:1
Definition: Scraper.h:58
Definition: GUIDialogProgress.h:16
Definition: CurlFile.h:24
Definition: Addon.cpp:39
Definition: VideoInfoTag.h:53
Definition: ScraperUrl.h:21