Sayonara Player
StreamParser.h
1 /* StreamParser.h */
2 
3 /* Copyright (C) 2011-2020 Michael Lugmair (Lucio Carreras)
4  *
5  * This file is part of sayonara player
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 3 of the License, or
10  * (at your option) 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 this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef STREAMPARSER_H
22 #define STREAMPARSER_H
23 
24 #include "Utils/Pimpl.h"
25 #include <QObject>
26 
27 using PlaylistFiles=QStringList;
28 
29 class StreamParser : public QObject
30 {
31  Q_OBJECT
32  PIMPL(StreamParser)
33 
34  signals:
35  void sigFinished(bool success);
36  void sigStopped();
37  void sigUrlCountExceeded(int urlCount, int maxUrlCount);
38 
39  public:
40  StreamParser(QObject* parent=nullptr);
41  ~StreamParser();
42 
43  void parse(const QString& stationName, const QString& stationUrl, int timeout=5000);
44  void parse(const QStringList& urls, int timeout=5000);
45 
46  void setCoverUrl(const QString& coverUrl);
47 
48  void stop();
49  bool isStopped() const;
50 
51  MetaDataList tracks() const;
52 
53  private slots:
54  void awaFinished();
55  void icyFinished();
56 
57  private:
68  QPair<MetaDataList, PlaylistFiles> parseContent(const QByteArray& data) const;
69 
75  QPair<MetaDataList, PlaylistFiles> parseWebsite(const QByteArray& arr) const;
76 
82  void setMetadataTag(MetaData& md, const QString& streamUrl, const QString& coverUrl=QString()) const;
83 
89  bool parseNextUrl();
90 };
91 
92 #endif
QPair
Definition: typedefs.h:32
MetaDataList
The MetaDataList class.
Definition: MetaDataList.h:37
Gui::MimeData::coverUrl
QString coverUrl(const QMimeData *data)
cover_url
MetaData
The MetaData class.
Definition: MetaData.h:47
StreamParser
Definition: StreamParser.h:30