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 
24  AUDIO_PODCAST = 3
25 };
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 {0};
75  QString Type;
76  QString Medium;
77  bool IsDefault {false};
78  QString Expression;
79  int Bitrate {0};
80  double Framerate {0.0};
81  double SamplingRate {0.0};
82  int Channels {0};
83  int Duration {0};
84  int Width {0};
85  int Height {0};
86  QString Lang;
87  int Group {0};
88  QString Rating;
89  QString RatingScheme;
90  QString Title;
91  QString Description;
92  QString Keywords;
93  QString CopyrightURL;
94  QString CopyrightText;
95  int RatingAverage {0};
96  int RatingCount {0};
97  int RatingMin {0};
98  int RatingMax {0};
99  int Views {0};
100  int Favs {0};
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  using resultList = QList<ResultItem *>;
115  using List = std::vector<ResultItem>;
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  ~Parse() override = default;
196 
197  ResultItem::resultList parseRSS(const QDomDocument& domDoc) const;
198  ResultItem* ParseItem(const QDomElement& item) const;
199 
200  static QString GetLink(const QDomElement& parent);
201  static QString GetAuthor(const QDomElement& parent);
202  static QString GetCommentsRSS(const QDomElement& parent);
203  static QString GetCommentsLink(const QDomElement& parent);
204  static QDateTime GetDCDateTime(const QDomElement& parent);
205  static QDateTime FromRFC3339(const QString& t);
206  QDateTime RFC822TimeToQDateTime (const QString& parent) const;
207  QStringList GetAllCategories (const QDomElement&) const;
208  static QList<MRSSEntry> GetMediaRSS (const QDomElement& item);
209  static QList<Enclosure> GetEnclosures(const QDomElement& entry);
210  static QString UnescapeHTML (const QString& escaped);
211 
212  private:
213  QMap<QString, int> m_timezoneOffsets;
214 
215  protected:
216  static const QString kDC;
217  static const QString kWFW;
218  static const QString kAtom;
219  static const QString kRDF;
220  static const QString kSlash;
221  static const QString kEnc;
222  static const QString kITunes;
223  static const QString kGeoRSSSimple;
224  static const QString kGeoRSSW3;
225  static const QString kMediaRSS;
226  static const QString kMythRSS;
227 };
228 
230 
231 #endif
MRSSEntry::Expression
QString Expression
Definition: rssparse.h:78
ResultItem::GetFilesize
const off_t & GetFilesize() const
Definition: rssparse.h:146
Q_DECLARE_METATYPE
Q_DECLARE_METATYPE(GrabberScript *)
MPUBLIC
#define MPUBLIC
Definition: mythexp.h:10
ResultItem::m_url
QString m_url
Definition: rssparse.h:166
AUDIO_FILE
@ AUDIO_FILE
Definition: rssparse.h:23
Parse::kRDF
static const QString kRDF
Definition: rssparse.h:219
Parse::kGeoRSSW3
static const QString kGeoRSSW3
Definition: rssparse.h:224
MRSSScene::StartTime
QString StartTime
Definition: rssparse.h:67
ResultItem::m_countries
QStringList m_countries
Definition: rssparse.h:182
ResultItem::m_sorttitle
QString m_sorttitle
Definition: rssparse.h:162
MRSSEntry::RatingCount
int RatingCount
Definition: rssparse.h:96
MRSSEntry::Comments
QList< MRSSComment > Comments
Definition: rssparse.h:104
AUDIO_PODCAST
@ AUDIO_PODCAST
Definition: rssparse.h:24
Parse::Parse
Parse()=default
Parse::~Parse
~Parse() override=default
MRSSEntry::Views
int Views
Definition: rssparse.h:99
ResultItem::GetPlayer
const QString & GetPlayer() const
Definition: rssparse.h:147
MRSSEntry::Scenes
QList< MRSSScene > Scenes
Definition: rssparse.h:106
title
QString title
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:633
MRSSEntry::RatingScheme
QString RatingScheme
Definition: rssparse.h:89
Parse::kAtom
static const QString kAtom
Definition: rssparse.h:218
mythexp.h
Parse::GetAllCategories
QStringList GetAllCategories(const QDomElement &) const
ResultItem::List
std::vector< ResultItem > List
Definition: rssparse.h:115
ResultItem::m_time
QString m_time
Definition: rssparse.h:171
ResultItem::m_download
QString m_download
Definition: rssparse.h:176
ResultItem::ResultItem
ResultItem()=default
ResultItem::m_thumbnail
QString m_thumbnail
Definition: rssparse.h:167
Parse::m_timezoneOffsets
QMap< QString, int > m_timezoneOffsets
Definition: rssparse.h:213
ResultItem::GetTitle
const QString & GetTitle() const
Definition: rssparse.h:134
ResultItem::GetCustomHTML
const bool & GetCustomHTML() const
Definition: rssparse.h:158
Parse::kMythRSS
static const QString kMythRSS
Definition: rssparse.h:226
MRSSThumbnail::Height
int Height
Definition: rssparse.h:41
ResultItem::GetCountries
const QStringList & GetCountries() const
Definition: rssparse.h:155
ResultItem::m_downloadargs
QStringList m_downloadargs
Definition: rssparse.h:177
MRSSScene
Definition: rssparse.h:64
MRSSEntry::Medium
QString Medium
Definition: rssparse.h:76
MRSSEntry::Favs
int Favs
Definition: rssparse.h:100
ResultItem::m_title
QString m_title
Definition: rssparse.h:161
MRSSEntry::Lang
QString Lang
Definition: rssparse.h:86
MRSSThumbnail::Time
QString Time
Definition: rssparse.h:42
MRSSEntry::URL
QString URL
Definition: rssparse.h:73
ResultItem::m_date
QDateTime m_date
Definition: rssparse.h:170
ResultItem::m_player
QString m_player
Definition: rssparse.h:174
InfoMap
QHash< QString, QString > InfoMap
Definition: mythtypes.h:15
RFC822TimeToQDateTime
QDateTime RFC822TimeToQDateTime(const QString &t)
Definition: metadatacommon.cpp:1416
Parse
Definition: rssparse.h:189
MRSSEntry::RatingMax
int RatingMax
Definition: rssparse.h:98
Parse::kSlash
static const QString kSlash
Definition: rssparse.h:220
ResultItem::GetAuthor
const QString & GetAuthor() const
Definition: rssparse.h:142
ResultItem::m_desc
QString m_desc
Definition: rssparse.h:165
Parse::kDC
static const QString kDC
Definition: rssparse.h:216
MRSSEntry::Tags
QString Tags
Definition: rssparse.h:101
ResultItem::GetRating
const QString & GetRating() const
Definition: rssparse.h:145
ResultItem::GetThumbnail
const QString & GetThumbnail() const
Definition: rssparse.h:140
ResultItem::GetDate
const QDateTime & GetDate() const
Definition: rssparse.h:143
ResultItem::GetSortSubtitle
const QString & GetSortSubtitle() const
Definition: rssparse.h:137
ResultItem::GetWidth
const uint & GetWidth() const
Definition: rssparse.h:151
MRSSEntry::Size
qint64 Size
Definition: rssparse.h:74
hardwareprofile.i18n.t
t
Definition: i18n.py:36
MRSSEntry::RatingMin
int RatingMin
Definition: rssparse.h:97
MRSSEntry::SamplingRate
double SamplingRate
Definition: rssparse.h:81
ResultItem::~ResultItem
~ResultItem()=default
Parse::kEnc
static const QString kEnc
Definition: rssparse.h:221
MRSSEntry::Rating
QString Rating
Definition: rssparse.h:88
hardwareprofile.scan.rating
def rating(profile, smoonURL, gate)
Definition: scan.py:39
MRSSEntry
Definition: rssparse.h:72
MRSSEntry::IsDefault
bool IsDefault
Definition: rssparse.h:77
MRSSEntry::CopyrightURL
QString CopyrightURL
Definition: rssparse.h:93
MRSSEntry::RatingAverage
int RatingAverage
Definition: rssparse.h:95
ResultItem::GetDownloader
const QString & GetDownloader() const
Definition: rssparse.h:149
ResultItem::m_author
QString m_author
Definition: rssparse.h:169
ResultItem::GetTime
const QString & GetTime() const
Definition: rssparse.h:144
mythtypes.h
ResultItem::GetLanguage
const QString & GetLanguage() const
Definition: rssparse.h:153
ResultItem::GetSeason
const uint & GetSeason() const
Definition: rssparse.h:156
MRSSThumbnail::URL
QString URL
Definition: rssparse.h:39
MRSSEntry::CopyrightText
QString CopyrightText
Definition: rssparse.h:94
MRSSCredit::Who
QString Who
Definition: rssparse.h:48
Parse::kITunes
static const QString kITunes
Definition: rssparse.h:222
ResultItem::m_subtitle
QString m_subtitle
Definition: rssparse.h:163
Parse::kMediaRSS
static const QString kMediaRSS
Definition: rssparse.h:225
MRSSEntry::Credits
QList< MRSSCredit > Credits
Definition: rssparse.h:103
MRSSCredit::Role
QString Role
Definition: rssparse.h:47
Enclosure
Describes an enclosure associated with an item.
Definition: rssparse.h:30
ResultItem::GetSubtitle
const QString & GetSubtitle() const
Definition: rssparse.h:136
uint
unsigned int uint
Definition: compat.h:140
MRSSEntry::Title
QString Title
Definition: rssparse.h:90
MRSSCredit
Definition: rssparse.h:46
MRSSEntry::Type
QString Type
Definition: rssparse.h:75
ArticleType
ArticleType
Definition: rssparse.h:20
off_t
#define off_t
Definition: mythiowrapper.cpp:238
MRSSScene::Description
QString Description
Definition: rssparse.h:66
ResultItem::GetDescription
const QString & GetDescription() const
Definition: rssparse.h:138
Parse::kWFW
static const QString kWFW
Definition: rssparse.h:217
MRSSEntry::PeerLinks
QList< MRSSPeerLink > PeerLinks
Definition: rssparse.h:105
MRSSEntry::Thumbnails
QList< MRSSThumbnail > Thumbnails
Definition: rssparse.h:102
ResultItem::GetPlayerArguments
const QStringList & GetPlayerArguments() const
Definition: rssparse.h:148
MRSSEntry::Height
int Height
Definition: rssparse.h:85
MRSSThumbnail::Width
int Width
Definition: rssparse.h:40
ResultItem::GetEpisode
const uint & GetEpisode() const
Definition: rssparse.h:157
MRSSEntry::Channels
int Channels
Definition: rssparse.h:82
MRSSEntry::Bitrate
int Bitrate
Definition: rssparse.h:79
MRSSScene::EndTime
QString EndTime
Definition: rssparse.h:68
MRSSThumbnail
Definition: rssparse.h:38
ResultItem::GetURL
const QString & GetURL() const
Definition: rssparse.h:139
countries
QDomElement countries
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:782
Enclosure::URL
QString URL
Definition: rssparse.h:31
VIDEO_FILE
@ VIDEO_FILE
Definition: rssparse.h:21
ResultItem
Definition: rssparse.h:110
Parse::kGeoRSSSimple
static const QString kGeoRSSSimple
Definition: rssparse.h:223
ResultItem::GetSortTitle
const QString & GetSortTitle() const
Definition: rssparse.h:135
ResultItem::m_sortsubtitle
QString m_sortsubtitle
Definition: rssparse.h:164
MRSSParser
Definition: rssparse.cpp:193
ResultItem::m_rating
QString m_rating
Definition: rssparse.h:172
MRSSComment::Type
QString Type
Definition: rssparse.h:53
VIDEO_PODCAST
@ VIDEO_PODCAST
Definition: rssparse.h:22
MRSSEntry::Width
int Width
Definition: rssparse.h:84
Enclosure::Lang
QString Lang
Definition: rssparse.h:34
ResultItem::resultList
QList< ResultItem * > resultList
Definition: rssparse.h:114
ResultItem::m_playerargs
QStringList m_playerargs
Definition: rssparse.h:175
Enclosure::Length
qint64 Length
Definition: rssparse.h:33
MRSSEntry::Group
int Group
Definition: rssparse.h:87
ResultItem::m_language
QString m_language
Definition: rssparse.h:180
MRSSEntry::Keywords
QString Keywords
Definition: rssparse.h:92
Enclosure::Type
QString Type
Definition: rssparse.h:32
MRSSComment
Definition: rssparse.h:52
URL
static const char URL[]
Definition: cddb.cpp:29
ResultItem::GetDownloaderArguments
const QStringList & GetDownloaderArguments() const
Definition: rssparse.h:150
MRSSEntry::Framerate
double Framerate
Definition: rssparse.h:80
ResultItem::GetDownloadable
const bool & GetDownloadable() const
Definition: rssparse.h:154
MRSSScene::Title
QString Title
Definition: rssparse.h:65
MRSSEntry::Description
QString Description
Definition: rssparse.h:91
MRSSEntry::Duration
int Duration
Definition: rssparse.h:83
ResultItem::GetHeight
const uint & GetHeight() const
Definition: rssparse.h:152
ResultItem::GetMediaURL
const QString & GetMediaURL() const
Definition: rssparse.h:141
ResultItem::m_mediaURL
QString m_mediaURL
Definition: rssparse.h:168
MRSSComment::Comment
QString Comment
Definition: rssparse.h:54