Modified:
/trunk/libs/MediaInfoFetcher/MediaInfo.h
/trunk/libs/PlaylistParser/M3UParser.cpp
/trunk/libs/PlaylistParser/XSPFParser.cpp
/trunk/libs/PlaylistParser/XSPFParser.h
/trunk/quarkplayer-plugins/Playlist/PlaylistWidget.cpp
=======================================
--- /trunk/libs/MediaInfoFetcher/MediaInfo.h Wed Nov 10 03:33:10 2010
+++ /trunk/libs/MediaInfoFetcher/MediaInfo.h Wed Feb 16 06:13:11 2011
@@ -1,6 +1,6 @@
/*
* QuarkPlayer, a Phonon media player
- * Copyright (C) 2008-2010 Tanguy Krotoff <tkro...@gmail.com>
+ * Copyright (C) 2008-2011 Tanguy Krotoff <tkro...@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
published by
@@ -183,11 +183,14 @@
*
http://www.google.com/codesearch?as_q=Metadata&btnG=Search+Code&hl=en&as_lang=java&as_case=y
*/
enum MetaData {
+ /** In order to loop over this enum. */
+ MIN,
+
/**
* int
* Returns 0 if no track number.
*/
- TrackNumber,
+ TrackNumber = MIN,
/**
* int
@@ -276,7 +279,10 @@
* int
* @see http://en.wikipedia.org/wiki/Beats_per_minute
*/
- BPM
+ BPM,
+
+ /** In order to loop over this enum. */
+ MAX = BPM
};
QVariant metaDataValue(MetaData metaData) const;
=======================================
--- /trunk/libs/PlaylistParser/M3UParser.cpp Fri Aug 13 02:18:04 2010
+++ /trunk/libs/PlaylistParser/M3UParser.cpp Wed Feb 16 06:13:11 2011
@@ -1,6 +1,6 @@
/*
* QuarkPlayer, a Phonon media player
- * Copyright (C) 2008-2010 Tanguy Krotoff <tkro...@gmail.com>
+ * Copyright (C) 2008-2011 Tanguy Krotoff <tkro...@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
published by
@@ -63,9 +63,10 @@
//#EXTM3U
QRegExp rx_extm3u("^#EXTM3U$|^#M3U$");
//#EXTINF:123,Sample title
- QRegExp rx_extinf("^#EXTINF:([-+]?\\d+),(.*)$");
+ //"Sample title" can be "Artist - Title"
+ QRegExp rx_extinf("^#EXTINF:([-+]?\\d+),\s?(.*)$");
//#EXTINF:Sample title
- QRegExp rx_extinf_title("^#EXTINF:(.*)$");
+ QRegExp rx_extinf_title("^#EXTINF:\s?(.*)$");
//#Just a comment
QRegExp rx_comment("^#.*$");
=======================================
--- /trunk/libs/PlaylistParser/XSPFParser.cpp Wed Nov 10 03:33:10 2010
+++ /trunk/libs/PlaylistParser/XSPFParser.cpp Wed Feb 16 06:13:11 2011
@@ -1,6 +1,6 @@
/*
* QuarkPlayer, a Phonon media player
- * Copyright (C) 2008-2010 Tanguy Krotoff <tkro...@gmail.com>
+ * Copyright (C) 2008-2011 Tanguy Krotoff <tkro...@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
published by
@@ -32,6 +32,7 @@
#include <QtCore/QUrl>
#include <QtCore/QDateTime>
+static const char * XSPF_BASE = "xml:base";
static const char * XSPF_DATE = "date";
static const char * XSPF_PLAYLIST = "playlist";
static const char * XSPF_TRACK = "track";
@@ -83,7 +84,7 @@
_stop = true;
}
-void XSPFParser::readTrack(QXmlStreamReader & xml, MediaInfo & mediaInfo)
const {
+void XSPFParser::readTrack(QXmlStreamReader & xml, MediaInfo & mediaInfo,
const QString & base) const {
while (!xml.atEnd() && !_stop) {
xml.readNext();
@@ -93,8 +94,20 @@
//Filename
if (element == XSPF_LOCATION) {
- QUrl url = QUrl::fromEncoded(xml.readElementText().toUtf8());
+ QString originalLocation = base + xml.readElementText();
+
+ //Workaround for a bug with foorbar2000 XSPF plugin
+ //"C:/1.mp3" should be written "file:///C:/1.mp3" instead of
+ //"file://C:/1.mp3"
+ bool match =
QRegExp("^file://[A-Za-z_]:/.*$").exactMatch(originalLocation);
+ if (match) {
+ originalLocation = originalLocation.replace("file://", "file:///");
+ }
+ ///
+
+ QUrl url = QUrl::fromEncoded(originalLocation.toUtf8());
QString location(url.toString());
+
if (MediaInfo::isUrl(location)) {
mediaInfo.setFileName(location);
} else {
@@ -317,6 +330,7 @@
QList<MediaInfo> files;
MediaInfo mediaInfo;
+ QString base;
QXmlStreamReader xml(device);
while (!xml.atEnd() && !_stop) {
@@ -327,8 +341,17 @@
case QXmlStreamReader::StartElement: {
QString element(xml.name().toString());
- if (element == XSPF_TRACK) {
- readTrack(xml, mediaInfo);
+ if (element == XSPF_PLAYLIST) {
+ QXmlStreamAttributes attributes = xml.attributes();
+
+ //Base
+ if (attributes.hasAttribute(XSPF_BASE)) {
+ base = attributes.value(XSPF_BASE).toString();
+ }
+ }
+
+ else if (element == XSPF_TRACK) {
+ readTrack(xml, mediaInfo, base);
if (!mediaInfo.fileName().isEmpty()) {
//Add file to the list of files
=======================================
--- /trunk/libs/PlaylistParser/XSPFParser.h Fri Aug 13 02:18:04 2010
+++ /trunk/libs/PlaylistParser/XSPFParser.h Wed Feb 16 06:13:11 2011
@@ -1,6 +1,6 @@
/*
* QuarkPlayer, a Phonon media player
- * Copyright (C) 2008-2010 Tanguy Krotoff <tkro...@gmail.com>
+ * Copyright (C) 2008-2011 Tanguy Krotoff <tkro...@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
published by
@@ -36,7 +36,7 @@
*
* Future features:
* Add QuarkPlayer extension in order to save (and import) the SQL
database inside a XSPF file.
- * Amarok use a XML file format to load/save its SQL database,
+ * Amarok uses a XML file format to load/save its SQL database,
* see
http://websvn.kde.org/trunk/extragear/multimedia/amarok/utilities/collectionscanner/
*
* @see http://en.wikipedia.org/wiki/XML_Shareable_Playlist_Format
@@ -61,7 +61,7 @@
private:
- void readTrack(QXmlStreamReader & xml, MediaInfo & mediaInfo) const;
+ void readTrack(QXmlStreamReader & xml, MediaInfo & mediaInfo, const
QString & base) const;
static void writeTextElement(QXmlStreamWriter & xml, const QString &
qualifiedName, const QString & text);
=======================================
--- /trunk/quarkplayer-plugins/Playlist/PlaylistWidget.cpp Wed Aug 25
15:38:42 2010
+++ /trunk/quarkplayer-plugins/Playlist/PlaylistWidget.cpp Wed Feb 16
06:13:11 2011
@@ -1,6 +1,6 @@
/*
* QuarkPlayer, a Phonon media player
- * Copyright (C) 2008-2010 Tanguy Krotoff <tkro...@gmail.com>
+ * Copyright (C) 2008-2011 Tanguy Krotoff <tkro...@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
published by
@@ -359,7 +359,7 @@
}
void PlaylistWidget::savePlaylist() {
- static const char * PLAYLIST_DEFAULT_EXTENSION = "m3u8";
+ static const char * PLAYLIST_DEFAULT_EXTENSION = "m3u";
QString filename = TkFileDialog::getSaveFileName(
this, tr("Save Playlist"), Config::instance().lastDirOpened(),