MythTV  master
rssparse.h
Go to the documentation of this file.
1 #ifndef RSSPARSE_H
2 #define RSSPARSE_H
3 
4 #include <vector>
5 
6 #include <QString>
7 #include <QStringList>
8 #include <QList>
9 #include <QObject>
10 #include <QDomDocument>
11 #include <QDateTime>
12 #include <QPair>
13 #include <QMap>
14 #include <QVariant>
15 #include <sys/types.h>
16 
17 #include "mythexp.h"
18 #include "mythtypes.h"
19 
20 typedef enum ArticleTypes {
25 } ArticleType;
26 
29 struct Enclosure
30 {
31  QString URL;
32  QString Type;
33  qint64 Length;
34  QString Lang;
35 };
36 
38 {
39  QString URL;
40  int Width;
41  int Height;
42  QString Time;
43 };
44 
45 struct MRSSCredit
46 {
47  QString Role;
48  QString Who;
49 };
50 
52 {
53  QString Type;
54  QString Comment;
55 };
56 
58 {
59  QString Type;
60  QString Link;
61 };
62 
63 struct MRSSScene
64 {
65  QString Title;
66  QString Description;
67  QString StartTime;
68  QString EndTime;
69 };
70 
71 struct MRSSEntry
72 {
73  QString URL;
74  qint64 Size;
75  QString Type;
76  QString Medium;
77  bool IsDefault;
78  QString Expression;
79  int Bitrate;
80  double Framerate;
81  double SamplingRate;
82  int Channels;
83  int Duration;
84  int Width;
85  int Height;
86  QString Lang;
87  int Group;
88  QString Rating;
89  QString RatingScheme;
90  QString Title;
91  QString Description;
92  QString Keywords;
93  QString CopyrightURL;
94  QString CopyrightText;
97  int RatingMin;
98  int RatingMax;
99  int Views;
100  int Favs;
101  QString Tags;
102  QList<MRSSThumbnail> Thumbnails;
103  QList<MRSSCredit> Credits;
104  QList<MRSSComment> Comments;
105  QList<MRSSPeerLink> PeerLinks;
106  QList<MRSSScene> Scenes;
107 };
108 
110 {
111 
112  public:
113 
114  typedef QList<ResultItem *> resultList;
115  typedef std::vector<ResultItem> List;
116 
117  ResultItem(const QString& title, const QString& sortTitle,
118  const QString& subtitle, const QString& sortSubtitle,
119  const QString& desc, const QString& URL,
120  const QString& thumbnail, const QString& mediaURL,
121  const QString& author, const QDateTime& date, const QString& time,
122  const QString& rating, const off_t& filesize,
123  const QString& player, const QStringList& playerargs,
124  const QString& download, const QStringList& downloadargs,
125  const uint& width, const uint& height, const QString& language,
126  const bool& downloadable, const QStringList& countries,
127  const uint& season, const uint& episode, const bool& customhtml);
128  ResultItem() = default;
129  ~ResultItem() = default;
130 
131  void ensureSortFields(void);
132  void toMap(InfoMap &metadataMap);
133 
134  const QString& GetTitle() const { return m_title; }
135  const QString& GetSortTitle() const { return m_sorttitle; }
136  const QString& GetSubtitle() const { return m_subtitle; }
137  const QString& GetSortSubtitle() const { return m_sortsubtitle; }
138  const QString& GetDescription() const { return m_desc; }
139  const QString& GetURL() const { return m_URL; }
140  const QString& GetThumbnail() const { return m_thumbnail; }
141  const QString& GetMediaURL() const { return m_mediaURL; }
142  const QString& GetAuthor() const { return m_author; }
143  const QDateTime& GetDate() const { return m_date; }
144  const QString& GetTime() const { return m_time; }
145  const QString& GetRating() const { return m_rating; }
146  const off_t& GetFilesize() const { return m_filesize; }
147  const QString& GetPlayer() const { return m_player; }
148  const QStringList& GetPlayerArguments() const { return m_playerargs; }
149  const QString& GetDownloader() const { return m_download; }
150  const QStringList& GetDownloaderArguments() const { return m_downloadargs; }
151  const uint& GetWidth() const { return m_width; }
152  const uint& GetHeight() const { return m_height; }
153  const QString& GetLanguage() const { return m_language; }
154  const bool& GetDownloadable() const { return m_downloadable; }
155  const QStringList& GetCountries() const { return m_countries; }
156  const uint& GetSeason() const { return m_season; }
157  const uint& GetEpisode() const { return m_episode; }
158  const bool& GetCustomHTML() const { return m_customhtml; }
159 
160  private:
161  QString m_title;
162  QString m_sorttitle;
163  QString m_subtitle;
164  QString m_sortsubtitle;
165  QString m_desc;
166  QString m_URL;
167  QString m_thumbnail;
168  QString m_mediaURL;
169  QString m_author;
170  QDateTime m_date;
171  QString m_time;
172  QString m_rating;
173  off_t m_filesize {0};
174  QString m_player;
175  QStringList m_playerargs;
176  QString m_download;
177  QStringList m_downloadargs;
178  uint m_width {0};
179  uint m_height {0};
180  QString m_language;
181  bool m_downloadable {false};
182  QStringList m_countries;
183  uint m_season {0};
184  uint m_episode {0};
185  bool m_customhtml {false};
186 };
187 
188 class MPUBLIC Parse : public QObject
189 {
190  Q_OBJECT
191  friend class MRSSParser;
192 
193  public:
194  Parse() = default;
195  virtual ~Parse() = default;
196 
197  ResultItem::resultList parseRSS(const QDomDocument& domDoc);
198  ResultItem* ParseItem(const QDomElement& item) const;
199 
200  QString GetLink(const QDomElement&) const;
201  QString GetAuthor(const QDomElement&) const;
202  QString GetCommentsRSS(const QDomElement&) const;
203  QString GetCommentsLink(const QDomElement&) const;
204  QDateTime GetDCDateTime(const QDomElement&) const;
205  QDateTime FromRFC3339(const QString&) const;
206  QDateTime RFC822TimeToQDateTime (const QString&) const;
207  int GetNumComments (const QDomElement&) const;
208  QStringList GetAllCategories (const QDomElement&) const;
209  QPair<double, double> GetGeoPoint (const QDomElement&) const;
210  QList<MRSSEntry> GetMediaRSS (const QDomElement&) const;
211  QList<Enclosure> GetEnclosures(const QDomElement& entry) const;
212  static QString UnescapeHTML (const QString&);
213 
214  private:
215  QMap<QString, int> TimezoneOffsets;
216 
217  protected:
218  static const QString s_DC;
219  static const QString s_WFW;
220  static const QString s_Atom;
221  static const QString s_RDF;
222  static const QString s_Slash;
223  static const QString s_Enc;
224  static const QString s_ITunes;
225  static const QString s_GeoRSSSimple;
226  static const QString s_GeoRSSW3;
227  static const QString s_MediaRSS;
228  static const QString s_MythRSS;
229 };
230 
232 
233 #endif
double Framerate
Definition: rssparse.h:80
const QString & GetSubtitle() const
Definition: rssparse.h:136
QString Comment
Definition: rssparse.h:54
const QString & GetLanguage() const
Definition: rssparse.h:153
const uint & GetSeason() const
Definition: rssparse.h:156
QMap< QString, int > TimezoneOffsets
Definition: rssparse.h:215
#define MPUBLIC
Definition: mythexp.h:10
QList< MRSSScene > Scenes
Definition: rssparse.h:106
QString Medium
Definition: rssparse.h:76
static const QString s_ITunes
Definition: rssparse.h:224
static const QString s_RDF
Definition: rssparse.h:221
QString Description
Definition: rssparse.h:91
Describes an enclosure associated with an item.
Definition: rssparse.h:29
const QString & GetURL() const
Definition: rssparse.h:139
QString URL
Definition: rssparse.h:31
static const QString s_DC
Definition: rssparse.h:218
const QString & GetSortTitle() const
Definition: rssparse.h:135
QString m_sortsubtitle
Definition: rssparse.h:164
const QString & GetDescription() const
Definition: rssparse.h:138
QString Type
Definition: rssparse.h:53
QString Lang
Definition: rssparse.h:86
QString m_rating
Definition: rssparse.h:172
const QStringList & GetPlayerArguments() const
Definition: rssparse.h:148
static const char URL[]
Definition: cddb.cpp:29
const uint & GetEpisode() const
Definition: rssparse.h:157
qint64 Size
Definition: rssparse.h:74
unsigned int uint
Definition: compat.h:140
QString EndTime
Definition: rssparse.h:68
int RatingAverage
Definition: rssparse.h:95
int Views
Definition: rssparse.h:99
static const QString s_MythRSS
Definition: rssparse.h:228
QString m_URL
Definition: rssparse.h:166
QStringList m_playerargs
Definition: rssparse.h:175
Q_DECLARE_METATYPE(GrabberScript *)
int RatingMax
Definition: rssparse.h:98
QString m_language
Definition: rssparse.h:180
QString Type
Definition: rssparse.h:32
QString URL
Definition: rssparse.h:73
#define off_t
std::vector< ResultItem > List
Definition: rssparse.h:115
const QStringList & GetDownloaderArguments() const
Definition: rssparse.h:150
QString Lang
Definition: rssparse.h:34
QString Tags
Definition: rssparse.h:101
int Favs
Definition: rssparse.h:100
QString Description
Definition: rssparse.h:66
QString CopyrightText
Definition: rssparse.h:94
qint64 Length
Definition: rssparse.h:33
QList< MRSSThumbnail > Thumbnails
Definition: rssparse.h:102
const QString & GetMediaURL() const
Definition: rssparse.h:141
QString CopyrightURL
Definition: rssparse.h:93
int Height
Definition: rssparse.h:85
QList< MRSSCredit > Credits
Definition: rssparse.h:103
def rating(profile, smoonURL, gate)
Definition: scan.py:25
static const QString s_GeoRSSW3
Definition: rssparse.h:226
int Channels
Definition: rssparse.h:82
int RatingCount
Definition: rssparse.h:96
int Width
Definition: rssparse.h:84
QString Who
Definition: rssparse.h:48
QHash< QString, QString > InfoMap
Definition: mythtypes.h:15
const off_t & GetFilesize() const
Definition: rssparse.h:146
const bool & GetDownloadable() const
Definition: rssparse.h:154
QString Title
Definition: rssparse.h:65
const uint & GetHeight() const
Definition: rssparse.h:152
QString m_mediaURL
Definition: rssparse.h:168
ArticleTypes
Definition: rssparse.h:20
const QString & GetPlayer() const
Definition: rssparse.h:147
static const QString s_Enc
Definition: rssparse.h:223
QString Role
Definition: rssparse.h:47
QString m_time
Definition: rssparse.h:171
QString m_sorttitle
Definition: rssparse.h:162
static const QString s_WFW
Definition: rssparse.h:219
const bool & GetCustomHTML() const
Definition: rssparse.h:158
QStringList m_countries
Definition: rssparse.h:182
bool IsDefault
Definition: rssparse.h:77
QString Title
Definition: rssparse.h:90
QString RatingScheme
Definition: rssparse.h:89
int Bitrate
Definition: rssparse.h:79
int Duration
Definition: rssparse.h:83
QString m_download
Definition: rssparse.h:176
QString Keywords
Definition: rssparse.h:92
const QStringList & GetCountries() const
Definition: rssparse.h:155
QString Rating
Definition: rssparse.h:88
QString m_thumbnail
Definition: rssparse.h:167
static const QString s_GeoRSSSimple
Definition: rssparse.h:225
const QString & GetTitle() const
Definition: rssparse.h:134
static const QString s_Slash
Definition: rssparse.h:222
QDateTime m_date
Definition: rssparse.h:170
QList< MRSSPeerLink > PeerLinks
Definition: rssparse.h:105
QString m_player
Definition: rssparse.h:174
QStringList m_downloadargs
Definition: rssparse.h:177
QString StartTime
Definition: rssparse.h:67
double SamplingRate
Definition: rssparse.h:81
QString m_desc
Definition: rssparse.h:165
const QString & GetAuthor() const
Definition: rssparse.h:142
const QString & GetRating() const
Definition: rssparse.h:145
QString m_title
Definition: rssparse.h:161
const uint & GetWidth() const
Definition: rssparse.h:151
int Group
Definition: rssparse.h:87
QString Type
Definition: rssparse.h:75
QList< MRSSComment > Comments
Definition: rssparse.h:104
QList< ResultItem * > resultList
Definition: rssparse.h:114
static const QString s_Atom
Definition: rssparse.h:220
int RatingMin
Definition: rssparse.h:97
static const QString s_MediaRSS
Definition: rssparse.h:227
QDateTime RFC822TimeToQDateTime(const QString &t)
enum ArticleTypes ArticleType
const QString & GetThumbnail() const
Definition: rssparse.h:140
const QString & GetDownloader() const
Definition: rssparse.h:149
QString URL
Definition: rssparse.h:39
const QString & GetTime() const
Definition: rssparse.h:144
const QDateTime & GetDate() const
Definition: rssparse.h:143
QString m_author
Definition: rssparse.h:169
const QString & GetSortSubtitle() const
Definition: rssparse.h:137
QString Time
Definition: rssparse.h:42
QString Expression
Definition: rssparse.h:78
QString m_subtitle
Definition: rssparse.h:163