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 <QStringList>
26 #include <QPair>
27 
28 #include "Helper/Pimpl.h"
29 
30 typedef QStringList PlaylistFiles;
31 
32 class MetaDataList;
33 class MetaData;
34 class StreamParser : public QObject
35 {
36  Q_OBJECT
37 
38  signals:
39  void sig_finished(bool);
40  void sig_stopped();
41  void sig_too_many_urls_found(int n_urls, int n_max_urls);
42 
43  public:
44  explicit StreamParser(const QString& station_name=QString(), QObject* parent=nullptr);
45  ~StreamParser();
46 
47  void parse_stream(const QString& url);
48  void parse_streams(const QStringList& urls);
49  void set_cover_url(const QString& cover_url);
50  void stop();
51 
52  MetaDataList get_metadata() const;
53 
54  private slots:
55  void awa_finished();
56  void icy_finished();
57 
58  private:
59  PIMPL(StreamParser)
60 
61  private:
67  QString write_playlist_file(const QByteArray& data) const;
68 
79  QPair<MetaDataList, PlaylistFiles> parse_content(const QByteArray& data) const;
80 
86  QPair<MetaDataList, PlaylistFiles> parse_website(const QByteArray& arr) const;
87 
93  void tag_metadata(MetaData& md, const QString& stream_url, const QString& cover_url=QString()) const;
94 
100  bool parse_next_url();
101 
102 
103 };
104 
105 #endif
Definition: StreamParser.h:34
The MetaData class MetaDataHelper.
Definition: MetaData.h:55
Definition: MetaDataList.h:39