xbmc
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 CScraperUrl& url, CVideoInfoTag &movieDetails, CGUIDialogProgress *pProgress = NULL);
58  bool GetEpisodeDetails(const CScraperUrl& url, CVideoInfoTag &movieDetails, CGUIDialogProgress *pProgress = NULL);
59  bool GetEpisodeList(const CScraperUrl& url, VIDEO::EPISODELIST& details, CGUIDialogProgress *pProgress = NULL);
60 
61  static void ShowErrorDialog(const ADDON::CScraperError &sce);
62 
63 protected:
64  enum LOOKUP_STATE { DO_NOTHING = 0,
65  FIND_MOVIE = 1,
66  GET_DETAILS = 2,
67  GET_EPISODE_LIST = 3,
68  GET_EPISODE_DETAILS = 4 };
69 
70  XFILE::CCurlFile* m_http;
71  std::string m_movieTitle;
72  int m_movieYear;
73  MOVIELIST m_movieList;
74  CVideoInfoTag m_movieDetails;
75  CScraperUrl m_url;
76  VIDEO::EPISODELIST m_episode;
77  LOOKUP_STATE m_state;
78  int m_found;
79  ADDON::ScraperPtr m_info;
80 
81  // threaded stuff
82  void Process() override;
83  void CloseThread();
84 
85  int InternalFindMovie(const std::string& movieTitle, int movieYear, MOVIELIST& movielist, bool cleanChars = true);
86 };
87 
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:51
Definition: ScraperUrl.h:21