Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add a PlaylistReader to parse .pls Soma.fm playlist

  • Loading branch information...
commit 94f434140812283833db502be0bb345ac6a009f1 1 parent 3e283a6
@andreagrandi authored
Showing with 54 additions and 3 deletions.
  1. +6 −3 CuteSoma.pro
  2. +31 −0 playlistreader.cpp
  3. +17 −0 playlistreader.h
View
9 CuteSoma.pro
@@ -4,7 +4,8 @@
QML_IMPORT_PATH =
QT+= declarative
-QT += phonon
+QT+= phonon
+QT+= network
symbian:TARGET.UID3 = 0xE6ACF247
# Smart Installer package's UID
@@ -24,7 +25,8 @@ symbian:TARGET.CAPABILITY += NetworkServices
# The .cpp file which was generated for your project. Feel free to hack it.
SOURCES += main.cpp \
- servercomm.cpp
+ servercomm.cpp \
+ playlistreader.cpp
OTHER_FILES += \
@@ -57,4 +59,5 @@ QMAKE_CXXFLAGS += -fPIC -fvisibility=hidden -fvisibility-inlines-hidden
QMAKE_LFLAGS += -pie -rdynamic
HEADERS += \
- servercomm.h
+ servercomm.h \
+ playlistreader.h
View
31 playlistreader.cpp
@@ -0,0 +1,31 @@
+#include "playlistreader.h"
+
+#include <QStringList>
+#include <QRegExp>
+
+PlaylistReader::PlaylistReader(const QString &playlistContents) :
+ contents(playlistContents)
+{
+}
+
+PlaylistReader::StreamUrls PlaylistReader::getStreamUrls()
+{
+ StreamUrls urls;
+ QRegExp streamRegExp("(File\\d)=(.*)");
+
+ QStringList lines = contents.split("\n");
+
+ for (QStringList::const_iterator line = lines.begin(); line != lines.end(); ++line)
+ {
+ if (line->startsWith("File")) {
+ if (streamRegExp.indexIn(*line) != -1)
+ {
+ QString url = streamRegExp.cap(2);
+ urls << url;
+ }
+ }
+ }
+
+ return urls;
+}
+
View
17 playlistreader.h
@@ -0,0 +1,17 @@
+#ifndef PLAYLISTREADER_H
+#define PLAYLISTREADER_H
+
+#include <QString>
+#include <QList>
+
+class PlaylistReader
+{
+ QString contents;
+
+public:
+ PlaylistReader(const QString &playlistContents);
+ typedef QList<QString> StreamUrls;
+ StreamUrls getStreamUrls();
+};
+
+#endif // PLAYLISTREADER_H
Please sign in to comment.
Something went wrong with that request. Please try again.