Merge pull request #4132 from wsnipex/pulse
[vuplus_xbmc] / xbmc / video / VideoInfoDownloader.h
1 #pragma once
2
3 /*
4  *      Copyright (C) 2005-2013 Team XBMC
5  *      http://xbmc.org
6  *
7  *  This Program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License as published by
9  *  the Free Software Foundation; either version 2, or (at your option)
10  *  any later version.
11  *
12  *  This Program is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  *  GNU General Public License for more details.
16  *
17  *  You should have received a copy of the GNU General Public License
18  *  along with XBMC; see the file COPYING.  If not, see
19  *  <http://www.gnu.org/licenses/>.
20  *
21  */
22
23 #include "threads/Thread.h"
24 #include "VideoInfoTag.h"
25 #include "addons/Scraper.h"
26 #include "Episode.h"
27 #include "XBDateTime.h"
28 #include "filesystem/CurlFile.h"
29
30 // forward declarations
31 class CXBMCTinyXML;
32 class CGUIDialogProgress;
33
34 namespace ADDON
35 {
36 class CScraperError;
37 }
38
39 typedef std::vector<CScraperUrl> MOVIELIST;
40
41 class CVideoInfoDownloader : public CThread
42 {
43 public:
44   CVideoInfoDownloader(const ADDON::ScraperPtr &scraper);
45   virtual ~CVideoInfoDownloader();
46
47   // threaded lookup functions
48
49   /*! \brief Do a search for matching media items (possibly asynchronously) with our scraper
50    \param strMovie name of the media item to look for
51    \param movielist [out] list of results to fill. May be empty on success.
52    \param pProgress progress bar to update as we go. If NULL we run on thread, if non-NULL we run off thread.
53    \return 1 on success, -1 on a scraper-specific error, 0 on some other error
54    */
55   int FindMovie(const CStdString& strMovie, MOVIELIST& movielist, CGUIDialogProgress *pProgress = NULL);
56   bool GetDetails(const CScraperUrl& url, CVideoInfoTag &movieDetails, CGUIDialogProgress *pProgress = NULL);
57   bool GetEpisodeDetails(const CScraperUrl& url, CVideoInfoTag &movieDetails, CGUIDialogProgress *pProgress = NULL);
58   bool GetEpisodeList(const CScraperUrl& url, VIDEO::EPISODELIST& details, CGUIDialogProgress *pProgress = NULL);
59
60   static void ShowErrorDialog(const ADDON::CScraperError &sce);
61
62 protected:
63   enum LOOKUP_STATE { DO_NOTHING = 0,
64                       FIND_MOVIE = 1,
65                       GET_DETAILS = 2,
66                       GET_EPISODE_LIST = 3,
67                       GET_EPISODE_DETAILS = 4 };
68
69   XFILE::CCurlFile*   m_http;
70   CStdString          m_strMovie;
71   MOVIELIST           m_movieList;
72   CVideoInfoTag       m_movieDetails;
73   CScraperUrl         m_url;
74   VIDEO::EPISODELIST  m_episode;
75   LOOKUP_STATE        m_state;
76   int                 m_found;
77   ADDON::ScraperPtr   m_info;
78
79   // threaded stuff
80   void Process();
81   void CloseThread();
82
83   int InternalFindMovie(const CStdString& strMovie, MOVIELIST& movielist, bool cleanChars = true);
84 };
85