14 #include <QDomDocument>
19 #include <QRegularExpression>
21 #include <QStringList>
37 QString extension = QFileInfo(
filename).suffix().toLower();
39 if (extension ==
"pls")
41 else if (extension ==
"m3u")
43 else if (extension ==
"asx")
51 LOG(VB_FILE, LOG_DEBUG, QString(
"DecoderHandler: parsePLS - '%1'").arg(
filename));
53 QSettings settings(
filename, QSettings::IniFormat);
56 QStringList groups = settings.childGroups();
58 if (groups.contains(
"playlist"))
59 settings.beginGroup(
"playlist");
60 else if (groups.contains(
"Playlist"))
61 settings.beginGroup(
"Playlist");
64 LOG(VB_GENERAL, LOG_ERR, QString(
"DecoderHandler: parsePLS - playlist group not found"));
71 QStringList keys = settings.childKeys();
73 if (keys.contains(
"numberofentries"))
74 num_entries = settings.value(
"numberofentries", -1).toInt();
75 else if (keys.contains(
"NumberOfEntries"))
76 num_entries = settings.value(
"NumberOfEntries", -1).toInt();
79 LOG(VB_GENERAL, LOG_ERR, QString(
"DecoderHandler: parsePLS - NumberOfEntries key not found"));
83 for (
int n = 1; n <= num_entries; n++)
86 QString t_key = QString(
"Title%1").arg(n);
87 QString f_key = QString(
"File%1").arg(n);
88 QString l_key = QString(
"Length%1").arg(n);
90 e->setFile(settings.value(f_key).toString());
91 e->setTitle(settings.value(t_key).toString());
92 e->setLength(settings.value(l_key).toInt());
101 static constexpr
const char*
M3U_INFO {
"#EXTINF" };
106 if (!f.open(QIODevice::ReadOnly))
109 QTextStream stream(&f);
110 QString data = stream.readAll();
111 static const QRegularExpression kNewlineRE {
"\\R" };
112 QStringList lines = data.split(kNewlineRE);
114 QStringList::iterator it;
115 for (it = lines.begin(); it != lines.end(); ++it)
143 QDomDocument doc(
"mydocument");
145 if (!
file.open(QIODevice::ReadOnly))
148 if (!doc.setContent(&
file))
156 QDomNodeList entryList = doc.elementsByTagName(
"Entry");
159 for (
int x = 0; x < entryList.count(); x++)
161 QDomNode n = entryList.item(x);
162 QDomElement elem = n.toElement();
163 QDomNodeList refList = elem.elementsByTagName(
"ref");
164 for (
int y = 0; y < refList.count(); y++)
166 QDomNode n2 = refList.item(y);
167 QDomElement elem2 = n2.toElement();
170 url = elem2.attribute(
"href");
174 e->setFile(url.replace(
"mms://",
"mmsh://"));
175 e->setTitle(url.replace(
"mms://",
"mmsh://"));