Sayonara Player
StreamParser.h
1 /* StreamParser.h */
2 
3 /* Copyright (C) 2011-2017 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 <QObject>
25 #include <QPair>
26 
27 #include "Utils/Pimpl.h"
28 
29 class QStringList;
30 
31 using PlaylistFiles=QStringList;
32 
33 class MetaDataList;
34 class MetaData;
35 class StreamParser : public QObject
36 {
37  Q_OBJECT
38  PIMPL(StreamParser)
39 
40  signals:
41  void sig_finished(bool);
42  void sig_stopped();
43  void sig_too_many_urls_found(int n_urls, int n_max_urls);
44 
45  public:
46  explicit StreamParser(const QString& station_name=QString(), QObject* parent=nullptr);
47  ~StreamParser();
48 
49  void parse_stream(const QString& url);
50  void parse_streams(const QStringList& urls);
51  void set_cover_url(const QString& cover_url);
52  void stop();
53 
54  MetaDataList metadata() const;
55 
56  private slots:
57  void awa_finished();
58  void icy_finished();
59 
60  private:
66  QString write_playlist_file(const QByteArray& data) const;
67 
78  QPair<MetaDataList, PlaylistFiles> parse_content(const QByteArray& data) const;
79 
85  QPair<MetaDataList, PlaylistFiles> parse_website(const QByteArray& arr) const;
86 
92  void tag_metadata(MetaData& md, const QString& stream_url, const QString& cover_url=QString()) const;
93 
99  bool parse_next_url();
100 };
101 
102 #endif
Definition: StreamParser.h:35
The MetaData class.
Definition: MetaData.h:48
The MetaDataList class.
Definition: MetaDataList.h:38
Definition: typedefs.h:28