Sayonara Player
StreamParser.h
1 /* StreamParser.h */
2 
3 /* Copyright (C) 2011-2019 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 sig_finished(bool);
36  void sig_stopped();
37  void sig_too_many_urls_found(int n_urls, int n_max_urls);
38 
39  public:
40  explicit StreamParser(const QString& station_name=QString(), QObject* parent=nullptr);
41  ~StreamParser();
42 
43  void parse_stream(const QString& url);
44  void parse_streams(const QStringList& urls);
45  void set_cover_url(const QString& cover_url);
46  void stop();
47 
48  MetaDataList metadata() const;
49 
50  private slots:
51  void awa_finished();
52  void icy_finished();
53 
54  private:
60  QString write_playlist_file(const QByteArray& data) const;
61 
72  QPair<MetaDataList, PlaylistFiles> parse_content(const QByteArray& data) const;
73 
79  QPair<MetaDataList, PlaylistFiles> parse_website(const QByteArray& arr) const;
80 
86  void tag_metadata(MetaData& md, const QString& stream_url, const QString& cover_url=QString()) const;
87 
93  bool parse_next_url();
94 };
95 
96 #endif
QPair
Definition: typedefs.h:32
MetaDataList
The MetaDataList class.
Definition: MetaDataList.h:37
Gui::MimeData::cover_url
QString cover_url(const QMimeData *data)
cover_url
MetaData
The MetaData class.
Definition: MetaData.h:44
StreamParser
Definition: StreamParser.h:29