[PVR][Estuary] Timer settings dialog: Show client name in timer type selection dialog...
[xbmc.git] / xbmc / utils / ScraperUrl.h
blob9ff416a5dc4d8457e7d00bb811cf05d6eeec710f
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 <map>
12 #include <string>
13 #include <vector>
15 class TiXmlElement;
16 namespace XFILE
18 class CCurlFile;
21 class CScraperUrl
23 public:
24 enum class UrlType
26 General = 1,
27 Season = 2
30 struct SUrlEntry
32 explicit SUrlEntry(std::string url = "")
33 : m_url(std::move(url)), m_type(UrlType::General), m_post(false), m_isgz(false), m_season(-1)
37 std::string m_spoof;
38 std::string m_url;
39 std::string m_cache;
40 std::string m_aspect;
41 std::string m_preview;
42 UrlType m_type;
43 bool m_post;
44 bool m_isgz;
45 int m_season;
48 CScraperUrl();
49 explicit CScraperUrl(const std::string& strUrl);
50 explicit CScraperUrl(const TiXmlElement* element);
51 ~CScraperUrl();
53 void Clear();
55 bool HasData() const { return !m_data.empty(); }
56 const std::string& GetData() const { return m_data; }
57 void SetData(std::string data);
59 const std::string& GetTitle() const { return m_title; }
60 void SetTitle(std::string title) { m_title = std::move(title); }
62 const std::string& GetId() const { return m_id; }
63 void SetId(std::string id) { m_id = std::move(id); }
65 double GetRelevance() const { return m_relevance; }
66 void SetRelevance(double relevance) { m_relevance = relevance; }
68 bool HasUrls() const { return !m_urls.empty(); }
69 const std::vector<SUrlEntry>& GetUrls() const { return m_urls; }
70 void SetUrls(std::vector<SUrlEntry> urls) { m_urls = std::move(urls); }
71 void AppendUrl(SUrlEntry url) { m_urls.push_back(std::move(url)); }
73 const SUrlEntry GetFirstUrlByType(const std::string& type = "") const;
74 const SUrlEntry GetSeasonUrl(int season, const std::string& type = "") const;
75 unsigned int GetMaxSeasonUrl() const;
77 std::string GetFirstThumbUrl() const;
79 /*! \brief fetch the full URLs (including referrer) of thumbs
80 \param thumbs [out] vector of thumb URLs to fill
81 \param type the type of thumb URLs to fetch, if empty (the default) picks any
82 \param season number of season that we want thumbs for, -1 indicates no season (the default)
83 \param unique avoid adding duplicate URLs when adding to a thumbs vector with existing items
85 void GetThumbUrls(std::vector<std::string>& thumbs,
86 const std::string& type = "",
87 int season = -1,
88 bool unique = false) const;
90 bool Parse();
91 bool ParseFromData(const std::string& data); // copies by intention
92 bool ParseAndAppendUrl(const TiXmlElement* element);
93 bool ParseAndAppendUrlsFromEpisodeGuide(const std::string& episodeGuide); // copies by intention
94 void AddParsedUrl(const std::string& url,
95 const std::string& aspect = "",
96 const std::string& preview = "",
97 const std::string& referrer = "",
98 const std::string& cache = "",
99 bool post = false,
100 bool isgz = false,
101 int season = -1);
103 /*! \brief fetch the full URL (including referrer) of a thumb
104 \param URL entry to use to create the full URL
105 \return the full URL, including referrer
107 static std::string GetThumbUrl(const CScraperUrl::SUrlEntry& entry);
109 static bool Get(const SUrlEntry& scrURL,
110 std::string& strHTML,
111 XFILE::CCurlFile& http,
112 const std::string& cacheContext);
114 // ATTENTION: this member MUST NOT be used directly except from databases
115 std::string m_data;
117 private:
118 std::string m_title;
119 std::string m_id;
120 double m_relevance;
121 std::vector<SUrlEntry> m_urls;
122 bool m_parsed;