[video] Ask the user for confirmation when turning a version into an extra or vice...
[xbmc.git] / xbmc / video / VideoInfoDownloader.h
blob4479522a338cd05d4b3255956489cdf8e5471c24
1 /*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #pragma once
11 #include "Episode.h"
12 #include "VideoInfoTag.h"
13 #include "addons/Scraper.h"
14 #include "threads/Thread.h"
16 #include <string>
17 #include <vector>
19 // forward declarations
20 class CXBMCTinyXML;
21 class CGUIDialogProgress;
23 namespace ADDON
25 class CScraperError;
27 namespace XFILE
29 class CurlFile;
32 typedef std::vector<CScraperUrl> MOVIELIST;
34 class CVideoInfoDownloader : public CThread
36 public:
37 explicit CVideoInfoDownloader(const ADDON::ScraperPtr &scraper);
38 ~CVideoInfoDownloader() override;
40 // threaded lookup functions
42 /*! \brief Do a search for matching media items (possibly asynchronously) with our scraper
43 \param movieTitle title of the media item to look for
44 \param movieYear year of the media item to look for (-1 if not known)
45 \param movielist [out] list of results to fill. May be empty on success.
46 \param pProgress progress bar to update as we go. If NULL we run on thread, if non-NULL we run off thread.
47 \return 1 on success, -1 on a scraper-specific error, 0 on some other error
49 int FindMovie(const std::string& movieTitle, int movieYear, MOVIELIST& movielist, CGUIDialogProgress *pProgress = NULL);
51 /*! \brief Fetch art URLs for an item with our scraper
52 \param details the video info tag structure to fill with art.
53 \return true on success, false on failure.
55 bool GetArtwork(CVideoInfoTag &details);
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);
64 static void ShowErrorDialog(const ADDON::CScraperError &sce);
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 };
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;
85 // threaded stuff
86 void Process() override;
87 void CloseThread();
89 int InternalFindMovie(const std::string& movieTitle, int movieYear, MOVIELIST& movielist, bool cleanChars = true);