File indexing completed on 2024-04-28 04:48:38

0001 /*
0002     SPDX-FileCopyrightText: 2005 Max Howell <max.howell@methylblue.com>
0003     SPDX-FileCopyrightText: 2007 Ian Monroe <ian@monroe.nu>
0004 
0005     SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0006 */
0007 
0008 #ifndef DRAGONPLAYER_PLAYLIST_FILE_H
0009 #define DRAGONPLAYER_PLAYLIST_FILE_H
0010 
0011 #include <QList>
0012 #include <QTextStream>
0013 #include <QUrl>
0014 
0015 class PlaylistFile
0016 {
0017 public:
0018     explicit PlaylistFile(const QUrl &url);
0019     ~PlaylistFile();
0020 
0021     enum FileFormat { M3U, PLS, Unknown, NotPlaylistFile = Unknown };
0022 
0023     bool isPlaylist() const
0024     {
0025         return m_type != Unknown;
0026     }
0027     bool isValid() const
0028     {
0029         return m_isValid;
0030     }
0031     QUrl firstUrl() const
0032     {
0033         return m_contents.isEmpty() ? QUrl() : m_contents.first();
0034     }
0035     QList<QUrl> contents() const
0036     {
0037         return m_contents;
0038     }
0039     QString error() const
0040     {
0041         return m_error;
0042     }
0043 
0044 private:
0045     void parsePlsFile(QTextStream &);
0046     void parseM3uFile(QTextStream &);
0047 
0048     void addToPlaylist(const QString &line);
0049 
0050     QUrl m_url;
0051     bool m_isValid;
0052     QString m_error;
0053     FileFormat m_type;
0054     QList<QUrl> m_contents;
0055 };
0056 
0057 #endif