26 frm_dir_map_t::const_iterator it;
29 if (
type ==
"cutlist")
34 uint64_t lastStart = 0;
35 for (it = cutlist.cbegin(); it != cutlist.cend(); ++it)
40 if (!result.isEmpty())
43 result += QString(
"%1-").arg(lastStart);
49 result += QString(
"%1").arg(it.key());
53 if (result.endsWith(
'-'))
56 if (lastFrame > lastStart)
57 result += QString(
"%1").arg(lastFrame);
60 if (
type ==
"cutlist")
62 std::cout << QString(
"Cutlist: %1\n").arg(result).toLocal8Bit().constData();
66 std::cout << QString(
"Commercial Skip List: %1\n")
67 .arg(result).toLocal8Bit().constData();
74 const QString &
type, QString newList)
80 bool isCutlist = (
type ==
"cutlist");
85 QStringList tokens = newList.split(
",", Qt::SkipEmptyParts);
87 if (newList.isEmpty())
90 for (
const QString& token : std::as_const(tokens))
92 QStringList cutpair = token.split(
"-", Qt::SkipEmptyParts);
108 std::cout << QString(
"Cutlist set to: %1\n")
109 .arg(newList).toLocal8Bit().constData();
110 LOG(VB_GENERAL, LOG_NOTICE, QString(
"Cutlist set to: %1").arg(newList));
115 std::cout << QString(
"Commercial Skip List set to: %1\n")
116 .arg(newList).toLocal8Bit().constData();
117 LOG(VB_GENERAL, LOG_NOTICE, QString(
"Commercial Skip List set to: %1").arg(newList));
146 frm_dir_map_t::const_iterator it;
149 for (it = cutlist.cbegin(); it != cutlist.cend(); ++it)
158 std::cout <<
"Commercial Skip List copied to Cutlist\n";
159 LOG(VB_GENERAL, LOG_NOTICE,
"Commercial Skip List copied to Cutlist");
186 std::cout <<
"Clearing Seek Table\n";
187 LOG(VB_GENERAL, LOG_NOTICE, pginfo.
IsVideo() ?
188 QString(
"Clearing Seek Table for Video %1").arg(pginfo.
GetPathname()) :
189 QString(
"Clearing Seek Table for Channel ID %1 @ %2")
208 std::cout <<
"Clearing bookmarks\n";
209 LOG(VB_GENERAL, LOG_NOTICE, pginfo.
IsVideo() ?
210 QString(
"Clearing bookmarks for video %1").arg(pginfo.
GetPathname()) :
211 QString(
"Clearing bookmarks for channel id %1 @ %2")
230 LOG(VB_STDIO|VB_FLUSH, LOG_ERR,
"Missing --getmarkup filename\n");
233 QVector<ProgramInfo::MarkupEntry> mapMark;
234 QVector<ProgramInfo::MarkupEntry> mapSeek;
237 if (!outfile.open(QIODevice::WriteOnly))
239 LOG(VB_STDIO|VB_FLUSH, LOG_ERR,
240 QString(
"Couldn't open output file %1\n").arg(
filename));
243 QTextStream stream(&outfile);
245 QDomProcessingInstruction processing =
246 xml.createProcessingInstruction(
"xml",
247 "version='1.0' encoding='utf-8'");
248 xml.appendChild(processing);
249 QDomElement root = xml.createElement(
"metadata");
250 xml.appendChild(root);
251 QDomElement item = xml.createElement(
"item");
252 root.appendChild(item);
253 QDomElement markup = xml.createElement(
"markup");
254 item.appendChild(markup);
255 for (
const auto & entry : std::as_const(mapMark))
257 QDomElement child = xml.createElement(
"mark");
258 child.setAttribute(
"type", entry.type);
259 child.setAttribute(
"frame", (qulonglong)entry.frame);
260 if (!entry.isDataNull)
261 child.setAttribute(
"data", (qulonglong)entry.data);
262 markup.appendChild(child);
264 for (
const auto & entry : std::as_const(mapSeek))
266 QDomElement child = xml.createElement(
"seek");
267 child.setAttribute(
"type", entry.type);
268 child.setAttribute(
"frame", (qulonglong)entry.frame);
269 if (!entry.isDataNull)
270 child.setAttribute(
"data", (qulonglong)entry.data);
271 markup.appendChild(child);
274 stream << xml.toString(2);
288 LOG(VB_STDIO|VB_FLUSH, LOG_ERR,
"Missing --setmarkup filename\n");
291 QVector<ProgramInfo::MarkupEntry> mapMark;
292 QVector<ProgramInfo::MarkupEntry> mapSeek;
294 if (!infile.open(QIODevice::ReadOnly))
296 LOG(VB_STDIO|VB_FLUSH, LOG_ERR,
297 QString(
"Couldn't open input file %1\n").arg(
filename));
301 if (!xml.setContent(&infile))
303 LOG(VB_STDIO|VB_FLUSH, LOG_ERR,
304 QString(
"Failed to read valid XML from file %1\n").arg(
filename));
307 QDomElement metadata = xml.documentElement();
308 if (metadata.tagName() !=
"metadata")
310 LOG(VB_STDIO|VB_FLUSH, LOG_ERR,
311 QString(
"Expected top-level 'metadata' element "
315 QDomNode item = metadata.firstChild();
316 if (!item.isElement() || item.toElement().tagName() !=
"item")
318 LOG(VB_STDIO|VB_FLUSH, LOG_ERR,
319 QString(
"Expected 'item' element within 'metadata' element "
323 QDomNode markup = item.firstChild();
324 if (!markup.isElement() || markup.toElement().tagName() !=
"markup")
326 LOG(VB_STDIO|VB_FLUSH, LOG_ERR,
327 QString(
"Expected 'markup' element within 'item' element "
331 for (QDomNode n = markup.firstChild(); !n.isNull(); n = n.nextSibling())
335 QDomElement e = n.toElement();
336 QString tagName = e.tagName();
338 if (tagName ==
"mark")
342 else if (tagName ==
"seek")
348 LOG(VB_STDIO|VB_FLUSH, LOG_ERR,
349 QString(
"Weird tag '%1', expected 'mark' or 'seek'\n")
353 int type = e.attribute(
"type").toInt();
354 uint64_t frame = e.attribute(
"frame").toULongLong();
355 QString dataString = e.attribute(
"data");
356 uint64_t data = dataString.toULongLong();
357 bool isDataNull = dataString.isNull();
361 mapMark.append(entry);
363 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)
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
bool GetProgramInfo(const MythUtilCommandLineParser &cmdline, ProgramInfo &pginfo)
QMap< QString, UtilFunc > UtilMap
MythCommFlagCommandLineParser cmdline
QMap< uint64_t, MarkTypes > frm_dir_map_t
Frame # -> Mark map.