10 #include <QDomDocument>
27 frm_dir_map_t::const_iterator it;
30 if (
type ==
"cutlist")
35 uint64_t lastStart = 0;
36 for (it = cutlist.cbegin(); it != cutlist.cend(); ++it)
41 if (!result.isEmpty())
44 result += QString(
"%1-").arg(lastStart);
50 result += QString(
"%1").arg(it.key());
54 if (result.endsWith(
'-'))
57 if (lastFrame > lastStart)
58 result += QString(
"%1").arg(lastFrame);
61 if (
type ==
"cutlist")
62 cout << QString(
"Cutlist: %1\n").arg(result).toLocal8Bit().constData();
65 cout << QString(
"Commercial Skip List: %1\n")
66 .arg(result).toLocal8Bit().constData();
73 const QString &
type, QString newList)
79 bool isCutlist = (
type ==
"cutlist");
84 #if QT_VERSION < QT_VERSION_CHECK(5,14,0)
85 QStringList tokens = newList.split(
",", QString::SkipEmptyParts);
87 QStringList tokens = newList.split(
",", Qt::SkipEmptyParts);
90 if (newList.isEmpty())
93 for (
const QString& token : qAsConst(tokens))
95 #if QT_VERSION < QT_VERSION_CHECK(5,14,0)
96 QStringList cutpair = token.split(
"-", QString::SkipEmptyParts);
98 QStringList cutpair = token.split(
"-", Qt::SkipEmptyParts);
115 cout << QString(
"Cutlist set to: %1\n")
116 .arg(newList).toLocal8Bit().constData();
117 LOG(VB_GENERAL, LOG_NOTICE, QString(
"Cutlist set to: %1").arg(newList));
122 cout << QString(
"Commercial Skip List set to: %1\n")
123 .arg(newList).toLocal8Bit().constData();
124 LOG(VB_GENERAL, LOG_NOTICE, QString(
"Commercial Skip List set to: %1").arg(newList));
153 frm_dir_map_t::const_iterator it;
156 for (it = cutlist.cbegin(); it != cutlist.cend(); ++it)
165 cout <<
"Commercial Skip List copied to Cutlist\n";
166 LOG(VB_GENERAL, LOG_NOTICE,
"Commercial Skip List copied to Cutlist");
193 cout <<
"Clearing Seek Table\n";
194 LOG(VB_GENERAL, LOG_NOTICE, pginfo.
IsVideo() ?
195 QString(
"Clearing Seek Table for Video %1").arg(pginfo.
GetPathname()) :
196 QString(
"Clearing Seek Table for Channel ID %1 @ %2")
215 cout <<
"Clearing bookmarks\n";
216 LOG(VB_GENERAL, LOG_NOTICE, pginfo.
IsVideo() ?
217 QString(
"Clearing bookmarks for video %1").arg(pginfo.
GetPathname()) :
218 QString(
"Clearing bookmarks for channel id %1 @ %2")
237 LOG(VB_STDIO|VB_FLUSH, LOG_ERR,
"Missing --getmarkup filename\n");
240 QVector<ProgramInfo::MarkupEntry> mapMark;
241 QVector<ProgramInfo::MarkupEntry> mapSeek;
244 if (!outfile.open(QIODevice::WriteOnly))
246 LOG(VB_STDIO|VB_FLUSH, LOG_ERR,
247 QString(
"Couldn't open output file %1\n").arg(
filename));
250 QTextStream stream(&outfile);
252 QDomProcessingInstruction processing =
253 xml.createProcessingInstruction(
"xml",
254 "version='1.0' encoding='utf-8'");
255 xml.appendChild(processing);
256 QDomElement root = xml.createElement(
"metadata");
257 xml.appendChild(root);
258 QDomElement item = xml.createElement(
"item");
259 root.appendChild(item);
260 QDomElement markup = xml.createElement(
"markup");
261 item.appendChild(markup);
262 for (
const auto & entry : qAsConst(mapMark))
264 QDomElement child = xml.createElement(
"mark");
265 child.setAttribute(
"type", entry.type);
266 child.setAttribute(
"frame", (qulonglong)entry.frame);
267 if (!entry.isDataNull)
268 child.setAttribute(
"data", (qulonglong)entry.data);
269 markup.appendChild(child);
271 for (
const auto & entry : qAsConst(mapSeek))
273 QDomElement child = xml.createElement(
"seek");
274 child.setAttribute(
"type", entry.type);
275 child.setAttribute(
"frame", (qulonglong)entry.frame);
276 if (!entry.isDataNull)
277 child.setAttribute(
"data", (qulonglong)entry.data);
278 markup.appendChild(child);
281 stream << xml.toString(2);
295 LOG(VB_STDIO|VB_FLUSH, LOG_ERR,
"Missing --setmarkup filename\n");
298 QVector<ProgramInfo::MarkupEntry> mapMark;
299 QVector<ProgramInfo::MarkupEntry> mapSeek;
301 if (!infile.open(QIODevice::ReadOnly))
303 LOG(VB_STDIO|VB_FLUSH, LOG_ERR,
304 QString(
"Couldn't open input file %1\n").arg(
filename));
308 if (!xml.setContent(&infile))
310 LOG(VB_STDIO|VB_FLUSH, LOG_ERR,
311 QString(
"Failed to read valid XML from file %1\n").arg(
filename));
314 QDomElement metadata = xml.documentElement();
315 if (metadata.tagName() !=
"metadata")
317 LOG(VB_STDIO|VB_FLUSH, LOG_ERR,
318 QString(
"Expected top-level 'metadata' element "
322 QDomNode item = metadata.firstChild();
323 if (!item.isElement() || item.toElement().tagName() !=
"item")
325 LOG(VB_STDIO|VB_FLUSH, LOG_ERR,
326 QString(
"Expected 'item' element within 'metadata' element "
330 QDomNode markup = item.firstChild();
331 if (!markup.isElement() || markup.toElement().tagName() !=
"markup")
333 LOG(VB_STDIO|VB_FLUSH, LOG_ERR,
334 QString(
"Expected 'markup' element within 'item' element "
338 for (QDomNode n = markup.firstChild(); !n.isNull(); n = n.nextSibling())
342 QDomElement e = n.toElement();
343 QString tagName = e.tagName();
345 if (tagName ==
"mark")
347 else if (tagName ==
"seek")
351 LOG(VB_STDIO|VB_FLUSH, LOG_ERR,
352 QString(
"Weird tag '%1', expected 'mark' or 'seek'\n")
356 int type = e.attribute(
"type").toInt();
357 uint64_t frame = e.attribute(
"frame").toULongLong();
358 QString dataString = e.attribute(
"data");
359 uint64_t data = dataString.toULongLong();
360 bool isDataNull = dataString.isNull();
364 mapMark.append(entry);
366 mapSeek.append(entry);