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 QStringList tokens = newList.split(
",", Qt::SkipEmptyParts);
86 if (newList.isEmpty())
89 for (
const QString& token : std::as_const(tokens))
91 QStringList cutpair = token.split(
"-", Qt::SkipEmptyParts);
107 cout << QString(
"Cutlist set to: %1\n")
108 .arg(newList).toLocal8Bit().constData();
109 LOG(VB_GENERAL, LOG_NOTICE, QString(
"Cutlist set to: %1").arg(newList));
114 cout << QString(
"Commercial Skip List set to: %1\n")
115 .arg(newList).toLocal8Bit().constData();
116 LOG(VB_GENERAL, LOG_NOTICE, QString(
"Commercial Skip List set to: %1").arg(newList));
145 frm_dir_map_t::const_iterator it;
148 for (it = cutlist.cbegin(); it != cutlist.cend(); ++it)
157 cout <<
"Commercial Skip List copied to Cutlist\n";
158 LOG(VB_GENERAL, LOG_NOTICE,
"Commercial Skip List copied to Cutlist");
185 cout <<
"Clearing Seek Table\n";
186 LOG(VB_GENERAL, LOG_NOTICE, pginfo.
IsVideo() ?
187 QString(
"Clearing Seek Table for Video %1").arg(pginfo.
GetPathname()) :
188 QString(
"Clearing Seek Table for Channel ID %1 @ %2")
207 cout <<
"Clearing bookmarks\n";
208 LOG(VB_GENERAL, LOG_NOTICE, pginfo.
IsVideo() ?
209 QString(
"Clearing bookmarks for video %1").arg(pginfo.
GetPathname()) :
210 QString(
"Clearing bookmarks for channel id %1 @ %2")
229 LOG(VB_STDIO|VB_FLUSH, LOG_ERR,
"Missing --getmarkup filename\n");
232 QVector<ProgramInfo::MarkupEntry> mapMark;
233 QVector<ProgramInfo::MarkupEntry> mapSeek;
236 if (!outfile.open(QIODevice::WriteOnly))
238 LOG(VB_STDIO|VB_FLUSH, LOG_ERR,
239 QString(
"Couldn't open output file %1\n").arg(
filename));
242 QTextStream stream(&outfile);
244 QDomProcessingInstruction processing =
245 xml.createProcessingInstruction(
"xml",
246 "version='1.0' encoding='utf-8'");
247 xml.appendChild(processing);
248 QDomElement root = xml.createElement(
"metadata");
249 xml.appendChild(root);
250 QDomElement item = xml.createElement(
"item");
251 root.appendChild(item);
252 QDomElement markup = xml.createElement(
"markup");
253 item.appendChild(markup);
254 for (
const auto & entry : std::as_const(mapMark))
256 QDomElement child = xml.createElement(
"mark");
257 child.setAttribute(
"type", entry.type);
258 child.setAttribute(
"frame", (qulonglong)entry.frame);
259 if (!entry.isDataNull)
260 child.setAttribute(
"data", (qulonglong)entry.data);
261 markup.appendChild(child);
263 for (
const auto & entry : std::as_const(mapSeek))
265 QDomElement child = xml.createElement(
"seek");
266 child.setAttribute(
"type", entry.type);
267 child.setAttribute(
"frame", (qulonglong)entry.frame);
268 if (!entry.isDataNull)
269 child.setAttribute(
"data", (qulonglong)entry.data);
270 markup.appendChild(child);
273 stream << xml.toString(2);
287 LOG(VB_STDIO|VB_FLUSH, LOG_ERR,
"Missing --setmarkup filename\n");
290 QVector<ProgramInfo::MarkupEntry> mapMark;
291 QVector<ProgramInfo::MarkupEntry> mapSeek;
293 if (!infile.open(QIODevice::ReadOnly))
295 LOG(VB_STDIO|VB_FLUSH, LOG_ERR,
296 QString(
"Couldn't open input file %1\n").arg(
filename));
300 if (!xml.setContent(&infile))
302 LOG(VB_STDIO|VB_FLUSH, LOG_ERR,
303 QString(
"Failed to read valid XML from file %1\n").arg(
filename));
306 QDomElement metadata = xml.documentElement();
307 if (metadata.tagName() !=
"metadata")
309 LOG(VB_STDIO|VB_FLUSH, LOG_ERR,
310 QString(
"Expected top-level 'metadata' element "
314 QDomNode item = metadata.firstChild();
315 if (!item.isElement() || item.toElement().tagName() !=
"item")
317 LOG(VB_STDIO|VB_FLUSH, LOG_ERR,
318 QString(
"Expected 'item' element within 'metadata' element "
322 QDomNode markup = item.firstChild();
323 if (!markup.isElement() || markup.toElement().tagName() !=
"markup")
325 LOG(VB_STDIO|VB_FLUSH, LOG_ERR,
326 QString(
"Expected 'markup' element within 'item' element "
330 for (QDomNode n = markup.firstChild(); !n.isNull(); n = n.nextSibling())
334 QDomElement e = n.toElement();
335 QString tagName = e.tagName();
337 if (tagName ==
"mark")
339 else if (tagName ==
"seek")
343 LOG(VB_STDIO|VB_FLUSH, LOG_ERR,
344 QString(
"Weird tag '%1', expected 'mark' or 'seek'\n")
348 int type = e.attribute(
"type").toInt();
349 uint64_t frame = e.attribute(
"frame").toULongLong();
350 QString dataString = e.attribute(
"data");
351 uint64_t data = dataString.toULongLong();
352 bool isDataNull = dataString.isNull();
356 mapMark.append(entry);
358 mapSeek.append(entry);
QString toString(const QString &key) const
Returns stored QVariant as a QString, falling to default if not provided.
Holds information on recordings and videos.
uint GetChanID(void) const
This is the unique key used in the database to locate tuning information.
void QueryMarkup(QVector< MarkupEntry > &mapMark, QVector< MarkupEntry > &mapSeek) const
void ClearMarkupFlag(MarkTypes type) const
void ClearPositionMap(MarkTypes type) const
void SaveMarkup(const QVector< MarkupEntry > &mapMark, const QVector< MarkupEntry > &mapSeek) const
void QueryCommBreakList(frm_dir_map_t &frames) const
QDateTime GetScheduledStartTime(void) const
The scheduled start time of program.
uint64_t QueryLastFrameInPosMap(void) const
Returns last frame in position map or 0.
bool QueryCutList(frm_dir_map_t &delMap, bool loadAutosave=false) const
void SaveCommBreakList(frm_dir_map_t &frames) const
void SaveCutList(frm_dir_map_t &delMap, bool isAutoSave=false) const
QString GetPathname(void) const
@ GENERIC_EXIT_OK
Exited with no error.
@ GENERIC_EXIT_NO_RECORDING_DATA
No program/recording data.
@ GENERIC_EXIT_INVALID_CMDLINE
Command line parse error.
static int SetSkipList(const MythUtilCommandLineParser &cmdline)
static int SetMarkupList(const MythUtilCommandLineParser &cmdline, const QString &type, QString newList)
static int ClearBookmarks(const MythUtilCommandLineParser &cmdline)
static int CopySkipListToCutList(const MythUtilCommandLineParser &cmdline)
static int GetMarkup(const MythUtilCommandLineParser &cmdline)
static int GetMarkupList(const MythUtilCommandLineParser &cmdline, const QString &type)
static int GetCutList(const MythUtilCommandLineParser &cmdline)
static int GetSkipList(const MythUtilCommandLineParser &cmdline)
static int SetMarkup(const MythUtilCommandLineParser &cmdline)
static int ClearSeekTable(const MythUtilCommandLineParser &cmdline)
static int ClearCutList(const MythUtilCommandLineParser &cmdline)
static int ClearSkipList(const MythUtilCommandLineParser &cmdline)
static int SetCutList(const MythUtilCommandLineParser &cmdline)
void registerMarkupUtils(UtilMap &utilMap)
MythCommFlagCommandLineParser cmdline
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
bool GetProgramInfo(const MythUtilCommandLineParser &cmdline, ProgramInfo &pginfo)
QMap< QString, UtilFunc > UtilMap
QMap< uint64_t, MarkTypes > frm_dir_map_t
Frame # -> Mark map.