aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/plugins/PlayListFormats/m3u/m3uplaylistformat.cpp20
-rw-r--r--src/plugins/PlayListFormats/m3u/m3uplaylistformat.h4
-rw-r--r--src/plugins/PlayListFormats/pls/plsplaylistformat.cpp5
-rw-r--r--src/plugins/PlayListFormats/pls/plsplaylistformat.h4
-rw-r--r--src/plugins/PlayListFormats/xspf/xspfplaylistformat.cpp5
-rw-r--r--src/plugins/PlayListFormats/xspf/xspfplaylistformat.h4
-rw-r--r--src/qmmpui/playlistformat.h7
-rw-r--r--src/qmmpui/playlistparser.cpp2
8 files changed, 33 insertions, 18 deletions
diff --git a/src/plugins/PlayListFormats/m3u/m3uplaylistformat.cpp b/src/plugins/PlayListFormats/m3u/m3uplaylistformat.cpp
index e436eaec3..eb3fc19d1 100644
--- a/src/plugins/PlayListFormats/m3u/m3uplaylistformat.cpp
+++ b/src/plugins/PlayListFormats/m3u/m3uplaylistformat.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2008-2012 by Ilya Kotov *
+ * Copyright (C) 2008-2017 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -20,6 +20,7 @@
#include <QFileInfo>
#include <QtPlugin>
+#include <qmmpui/metadataformatter.h>
#include "m3uplaylistformat.h"
const PlayListFormatProperties M3UPlaylistFormat::properties() const
@@ -51,15 +52,26 @@ QStringList M3UPlaylistFormat::decode(const QString & contents)
return out;
}
-QString M3UPlaylistFormat::encode(const QList<PlayListTrack*> & contents)
+QString M3UPlaylistFormat::encode(const QList<PlayListTrack*> & contents, const QString &path)
{
QStringList out;
out << QString("#EXTM3U");
+ MetaDataFormatter formatter("%if(%p,%p - %t,%t)%if(%p|%t,,%f)");
+ QString m3uDir = QFileInfo(path).canonicalPath();
+
foreach(PlayListTrack* f,contents)
{
- QString info = "#EXTINF:" + QString::number(f->length()) + "," + f->value(Qmmp::TITLE);
+ QString info = "#EXTINF:" + QString::number(f->length()) + "," + formatter.format(f);
out.append(info);
- out.append(f->url());
+
+ if(!f->url().contains("://") && f->url().startsWith(m3uDir))
+ {
+ QString p = f->url();
+ p.remove(0, m3uDir.size() + 1);
+ out.append(p);
+ }
+ else
+ out.append(f->url());
}
return out.join("\n");
}
diff --git a/src/plugins/PlayListFormats/m3u/m3uplaylistformat.h b/src/plugins/PlayListFormats/m3u/m3uplaylistformat.h
index ff9f19c63..379ae063e 100644
--- a/src/plugins/PlayListFormats/m3u/m3uplaylistformat.h
+++ b/src/plugins/PlayListFormats/m3u/m3uplaylistformat.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2008-2012 by Ilya Kotov *
+ * Copyright (C) 2008-2017 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -37,7 +37,7 @@ class M3UPlaylistFormat : public QObject, public PlayListFormat
public:
const PlayListFormatProperties properties() const;
QStringList decode(const QString& contents);
- QString encode(const QList<PlayListTrack*>& contents);
+ QString encode(const QList<PlayListTrack*>& contents, const QString &path);
};
diff --git a/src/plugins/PlayListFormats/pls/plsplaylistformat.cpp b/src/plugins/PlayListFormats/pls/plsplaylistformat.cpp
index 76073a7c6..ac4954567 100644
--- a/src/plugins/PlayListFormats/pls/plsplaylistformat.cpp
+++ b/src/plugins/PlayListFormats/pls/plsplaylistformat.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2008-2012 by Ilya Kotov *
+ * Copyright (C) 2008-2017 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -64,8 +64,9 @@ QStringList PLSPlaylistFormat::decode(const QString & contents)
return QStringList();
}
-QString PLSPlaylistFormat::encode(const QList<PlayListTrack *> & contents)
+QString PLSPlaylistFormat::encode(const QList<PlayListTrack *> & contents, const QString &path)
{
+ Q_UNUSED(path);
QStringList out;
out << QString("[playlist]");
int counter = 1;
diff --git a/src/plugins/PlayListFormats/pls/plsplaylistformat.h b/src/plugins/PlayListFormats/pls/plsplaylistformat.h
index 86fc18d00..7fed6d810 100644
--- a/src/plugins/PlayListFormats/pls/plsplaylistformat.h
+++ b/src/plugins/PlayListFormats/pls/plsplaylistformat.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2008 by Ilya Kotov *
+ * Copyright (C) 2008-2017 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -37,7 +37,7 @@ class PLSPlaylistFormat : public QObject, public PlayListFormat
public:
const PlayListFormatProperties properties() const;
QStringList decode(const QString& contents);
- QString encode(const QList<PlayListTrack*>& contents);
+ QString encode(const QList<PlayListTrack*>& contents, const QString &path);
};
diff --git a/src/plugins/PlayListFormats/xspf/xspfplaylistformat.cpp b/src/plugins/PlayListFormats/xspf/xspfplaylistformat.cpp
index adea65e0e..d5ab21fb5 100644
--- a/src/plugins/PlayListFormats/xspf/xspfplaylistformat.cpp
+++ b/src/plugins/PlayListFormats/xspf/xspfplaylistformat.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2008-2014 by Ilya Kotov *
+ * Copyright (C) 2008-2017 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -88,8 +88,9 @@ QStringList XSPFPlaylistFormat::decode(const QString & contents)
// Needs more work - it's better use libSpiff there and put it as plugin.
-QString XSPFPlaylistFormat::encode(const QList<PlayListTrack*> & files)
+QString XSPFPlaylistFormat::encode(const QList<PlayListTrack*> & files, const QString &path)
{
+ Q_UNUSED(path);
QString out;
QXmlStreamWriter xml(&out);
xml.setCodec("UTF-8");
diff --git a/src/plugins/PlayListFormats/xspf/xspfplaylistformat.h b/src/plugins/PlayListFormats/xspf/xspfplaylistformat.h
index d1e5c0cb9..d3b03d3ca 100644
--- a/src/plugins/PlayListFormats/xspf/xspfplaylistformat.h
+++ b/src/plugins/PlayListFormats/xspf/xspfplaylistformat.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2008-2014 by Ilya Kotov *
+ * Copyright (C) 2008-2017 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -37,7 +37,7 @@ class XSPFPlaylistFormat : public QObject, public PlayListFormat
public:
const PlayListFormatProperties properties() const;
QStringList decode(const QString& contents);
- QString encode(const QList<PlayListTrack*>& contents);
+ QString encode(const QList<PlayListTrack*>& contents, const QString &path);
};
#endif
diff --git a/src/qmmpui/playlistformat.h b/src/qmmpui/playlistformat.h
index ba7ca26f2..06927cfbf 100644
--- a/src/qmmpui/playlistformat.h
+++ b/src/qmmpui/playlistformat.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2006-2013 by Ilya Kotov *
+ * Copyright (C) 2006-2017 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -56,9 +56,10 @@ public:
virtual QStringList decode(const QString& contents) = 0;
/*!
* Takes the list of AbstractPlaylistItem objects, should return string of
- * encoded playlist file
+ * encoded playlist file.
+ * @param dir Playlist file path (May be used to adjust playlist content).
*/
- virtual QString encode(const QList<PlayListTrack*>& contents) = 0;
+ virtual QString encode(const QList<PlayListTrack*>& contents, const QString &path) = 0;
};
Q_DECLARE_INTERFACE(PlayListFormat,"PlayListFormat/1.0")
diff --git a/src/qmmpui/playlistparser.cpp b/src/qmmpui/playlistparser.cpp
index 083cb35d4..70c3c3fe9 100644
--- a/src/qmmpui/playlistparser.cpp
+++ b/src/qmmpui/playlistparser.cpp
@@ -90,7 +90,7 @@ void PlayListParser::savePlayList(QList<PlayListTrack *> tracks, const QString &
if (file.open(QIODevice::WriteOnly))
{
QTextStream ts(&file);
- ts << prs->encode(tracks);
+ ts << prs->encode(tracks, QFileInfo(f_name).canonicalFilePath());
file.close();
}
else