Ticket #11713: 0001-Add-utility-function-to-clear-all-bookmarks.patch

File 0001-Add-utility-function-to-clear-all-bookmarks.patch, 3.1 KB (added by Karl Egly, 9 years ago)

proof of concept (compile tested) implementing the suggestion from the mailing list discussion

  • mythtv/programs/mythutil/commandlineparser.cpp

    From acc1b24d3bb0a1cc15a52bb068e41e06a04996f6 Mon Sep 17 00:00:00 2001
    From: Karl Dietz <dekarl@mythtv.org>
    Date: Tue, 4 Aug 2015 22:27:01 +0200
    Subject: [PATCH] Add utility function to clear all bookmarks.
    
    Clears the mythical bookmark around the start of the programme,
    the last playback position and manually set bookmarks.
    Its intended use case is cleanup when the recording file has changed in
    a way that makes the bookmarks useless.
    
    Refs #11713
    ---
     mythtv/programs/mythutil/commandlineparser.cpp |  5 +++++
     mythtv/programs/mythutil/markuputils.cpp       | 20 ++++++++++++++++++++
     2 files changed, 25 insertions(+)
    
    diff --git a/mythtv/programs/mythutil/commandlineparser.cpp b/mythtv/programs/mythutil/commandlineparser.cpp
    index 931372b..b5cd4c7 100644
    a b void MythUtilCommandLineParser::LoadArguments(void) 
    7373                "Clear the seek table.", "")
    7474                ->SetGroup("Recording Markup")
    7575                ->SetParentOf(ChanidStartimeVideo)
     76        << add("--clearbookmarks", "clearbookmarks", false,
     77                "Clear all bookmarks.", "This command will reset the playback "
     78                "start to the very beginning of the recording file.")
     79                ->SetGroup("Recording Markup")
     80                ->SetParentOf(ChanidStartimeVideo)
    7681        << add("--getmarkup", "getmarkup", "",
    7782               "Write markup data to the specified local file.", "")
    7883                ->SetGroup("Recording Markup")
  • mythtv/programs/mythutil/markuputils.cpp

    diff --git a/mythtv/programs/mythutil/markuputils.cpp b/mythtv/programs/mythutil/markuputils.cpp
    index 9295aeb..4a2ac89 100644
    a b static int ClearSeekTable(const MythUtilCommandLineParser &cmdline) 
    196196    return GENERIC_EXIT_OK;
    197197}
    198198
     199static int ClearBookmarks(const MythUtilCommandLineParser &cmdline)
     200{
     201    ProgramInfo pginfo;
     202    if (!GetProgramInfo(cmdline, pginfo))
     203        return GENERIC_EXIT_NO_RECORDING_DATA;
     204
     205    cout << "Clearing bookmarks\n";
     206    LOG(VB_GENERAL, LOG_NOTICE, pginfo.IsVideo() ?
     207        QString("Clearing bookmarks for video %1").arg(pginfo.GetPathname()) :
     208        QString("Clearing bookmarks for channel id %1 @ %2")
     209                .arg(pginfo.GetChanID())
     210                .arg(pginfo.GetScheduledStartTime().toString()));
     211    pginfo.ClearMarkupFlag(MARK_BOOKMARK);
     212    pginfo.ClearMarkupFlag(MARK_UTIL_PROGSTART);
     213    pginfo.ClearMarkupFlag(MARK_UTIL_LASTPLAYPOS);
     214
     215    return GENERIC_EXIT_OK;
     216}
     217
    199218static int GetMarkup(const MythUtilCommandLineParser &cmdline)
    200219{
    201220    ProgramInfo pginfo;
    void registerMarkupUtils(UtilMap &utilMap) 
    352371    utilMap["setskiplist"]            = &SetSkipList;
    353372    utilMap["clearskiplist"]          = &ClearSkipList;
    354373    utilMap["clearseektable"]         = &ClearSeekTable;
     374    utilMap["clearbookmarks"]         = &ClearBookmarks;
    355375    utilMap["getmarkup"]              = &GetMarkup;
    356376    utilMap["setmarkup"]              = &SetMarkup;
    357377}