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.
12 #include "VideoInfoTag.h"
13 #include "addons/Scraper.h"
14 #include "threads/Thread.h"
19 // forward declarations
21 class CGUIDialogProgress
;
32 typedef std::vector
<CScraperUrl
> MOVIELIST
;
34 class CVideoInfoDownloader
: public CThread
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
);
67 enum LOOKUP_STATE
{ DO_NOTHING
= 0,
71 GET_EPISODE_DETAILS
= 4 };
73 XFILE::CCurlFile
* m_http
;
74 std::string m_movieTitle
;
76 std::unordered_map
<std::string
, std::string
> m_uniqueIDs
;
77 MOVIELIST m_movieList
;
78 CVideoInfoTag m_movieDetails
;
80 VIDEO::EPISODELIST m_episode
;
81 LOOKUP_STATE m_state
= DO_NOTHING
;
83 ADDON::ScraperPtr m_info
;
86 void Process() override
;
89 int InternalFindMovie(const std::string
& movieTitle
, int movieYear
, MOVIELIST
& movielist
, bool cleanChars
= true);