From c538d359ec7c63e0717fb7cd842ee96a6a11de98 Mon Sep 17 00:00:00 2001 From: louis Date: Sun, 27 Apr 2014 12:39:56 +0200 Subject: [PATCH] added more debugging possibilities --- config.c | 2 + config.h | 1 + po/de_DE.po | 6 ++- scraper2vdr.c | 15 ++++++ scrapmanager.c | 126 +++++++++++++++++++++++++++++++++++++++---------- scrapmanager.h | 6 +-- setup.c | 2 + update.c | 1 + 8 files changed, 130 insertions(+), 29 deletions(-) diff --git a/config.c b/config.c index b3812be..1fe1016 100644 --- a/config.c +++ b/config.c @@ -12,6 +12,7 @@ cScraper2VdrConfig::cScraper2VdrConfig() { mysqlDBUser = "epg2vdr"; mysqlDBPass = "epg"; recScrapInfoName = "scrapinfo"; + debug = 0; } cScraper2VdrConfig::~cScraper2VdrConfig() { @@ -50,6 +51,7 @@ bool cScraper2VdrConfig::SetupParse(const char *Name, const char *Value) { else if (strcmp(Name, "mysqlDBName") == 0) mysqlDBName = Value; else if (strcmp(Name, "mysqlDBUser") == 0) mysqlDBUser = Value; else if (strcmp(Name, "mysqlDBPass") == 0) mysqlDBPass = Value; + else if (strcmp(Name, "debug") == 0) debug = atoi(Value); else return false; return true; diff --git a/config.h b/config.h index c81a8ef..fb08748 100644 --- a/config.h +++ b/config.h @@ -27,5 +27,6 @@ class cScraper2VdrConfig { string mysqlDBUser; string mysqlDBPass; string recScrapInfoName; + int debug; }; #endif //__SCRAPER2VDR_CONFIG_H diff --git a/po/de_DE.po b/po/de_DE.po index be690eb..4d4094a 100644 --- a/po/de_DE.po +++ b/po/de_DE.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: vdr-scraper2vdr 0.0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-03-30 14:37+0200\n" +"POT-Creation-Date: 2014-04-27 12:22+0200\n" "PO-Revision-Date: 2014-03-30 18:30+0100\n" "Last-Translator: 3PO\n" "Language-Team: German \n" @@ -48,6 +48,9 @@ msgstr "Bereinige Aufnahmen in Datenbank" msgid "Show Main Menu Entry" msgstr "Hauptmenüeintrag anzeigen" +msgid "Debug Mode" +msgstr "Debug Modus" + msgid "MySQL Host" msgstr "MySQL Host" @@ -62,4 +65,3 @@ msgstr "MySQL Benutzer" msgid "MySQL Password" msgstr "MySQL Passwort" - diff --git a/scraper2vdr.c b/scraper2vdr.c index 57e2332..788c42b 100644 --- a/scraper2vdr.c +++ b/scraper2vdr.c @@ -219,6 +219,12 @@ const char **cPluginScraper2vdr::SVDRPHelpPages(void) { " Trigger scan for scrapinfo files in video directory.", "CRDB\n" " Trigger cleanup of recordings database.", + "DSER\n" + " Dump series kept in memory.", + "DMOV\n" + " Dump movies kept in memory.", + "DREC\n" + " Dump recordings kept in memory.", 0 }; return HelpPages; @@ -240,6 +246,15 @@ cString cPluginScraper2vdr::SVDRPCommand(const char *Command, const char *Option } else if (strcasecmp(Command, "CRDB") == 0) { update->TriggerCleanRecordingsDB(); return "SCRAPER2VDR cleanup of recording DB triggered."; + } else if (strcasecmp(Command, "DSER") == 0) { + scrapManager->DumpSeries(); + return "SCRAPER2VDR dumping available series"; + } else if (strcasecmp(Command, "DMOV") == 0) { + scrapManager->DumpMovies(); + return "SCRAPER2VDR dumping available movies"; + } else if (strcasecmp(Command, "DREC") == 0) { + scrapManager->DumpRecordings(); + return "SCRAPER2VDR dumping available recordings"; } return NULL; } diff --git a/scrapmanager.c b/scrapmanager.c index eda47e4..8a0925c 100644 --- a/scrapmanager.c +++ b/scrapmanager.c @@ -1,10 +1,13 @@ -#define __STL_CONFIG_H +#define __STL_v_H #include #include "tools.h" +#include "config.h" #include "scrapmanager.h" using namespace std; +extern cScraper2VdrConfig config; + bool operator<(const sEventsKey& l, const sEventsKey& r) { if (l.eventId != r.eventId) return (l.eventId < r.eventId); @@ -279,63 +282,138 @@ bool cScrapManager::MovieInUse(int movieId) { return false; } -void cScrapManager::DumpSeries(int num) { - int i=0; - tell(0, "Dumping first %d series", num); - for (map::iterator it = series.begin(); it != series.end(); it++) { - cTVDBSeries *s = it->second; - s->Dump(); - if (i == num) - break; - i++; +void cScrapManager::DumpSeries(void) { + int numSeries = 0; + map::iterator it; + for (it = events.begin(); it != events.end(); it++) { + sEventsKey key = it->first; + sEventsValue ev = it->second; + if (ev.seriesId > 0) { + const cEvent *event = NULL; + const cChannel *c = NULL; + cSchedulesLock lock; + cSchedules *s = (cSchedules *)cSchedules::Schedules(lock); + if (s) { + tChannelID cID = tChannelID::FromString(key.channelId.c_str()); + c = Channels.GetByChannelID(cID); + const cSchedule *schedule = s->GetSchedule(cID); + if (schedule) { + event = schedule->GetEvent(key.eventId); + } + } + if (event) { + tell(0, "series (tvdbID %d, episodeId %d), Event (EventID %d): %s, %s: %s (%s)", ev.seriesId, + ev.episodeId, + key.eventId, + *event->GetDateString(), + *event->GetTimeString(), + event->Title(), + c?(c->Name()):"unknown channel"); + } else { + tell(0, "series (tvdbID %d, episodeId %d), Event (EventID %d): No VDR Event found", ev.seriesId, ev.episodeId, key.eventId); + } + numSeries++; + } } + tell(0, "Keeping %d series in memory", numSeries); } -void cScrapManager::DumpMovies(int num) { - int i=0; - tell(0, "Dumping first %d movies", num); - for (map::iterator it = movies.begin(); it != movies.end(); it++) { - cMovieDbMovie *m = it->second; - m->Dump(); - if (i == num) - break; - i++; +void cScrapManager::DumpMovies(void) { + int numMovies = 0; + map::iterator it; + for (it = events.begin(); it != events.end(); it++) { + sEventsKey key = it->first; + sEventsValue ev = it->second; + if (ev.movieId > 0) { + const cEvent *event = NULL; + const cChannel *c = NULL; + cSchedulesLock lock; + cSchedules *s = (cSchedules *)cSchedules::Schedules(lock); + if (s) { + tChannelID cID = tChannelID::FromString(key.channelId.c_str()); + c = Channels.GetByChannelID(cID); + const cSchedule *schedule = s->GetSchedule(cID); + if (schedule) { + event = schedule->GetEvent(key.eventId); + } + } + if (event) { + tell(0, "movie (moviedbId %d), Event (EventID %d): %s, %s: %s (%s)", ev.movieId, + key.eventId, + *event->GetDateString(), + *event->GetTimeString(), + event->Title(), + c?(c->Name()):"unknown channel"); + } else { + tell(0, "movie (moviedbId %d), Event (EventID %d): No VDR Event found", ev.movieId, key.eventId); + } + numMovies++; + } } + tell(0, "Keeping %d movies in memory", numMovies); } -void cScrapManager::DumpRecordings(int num) { - tell(0, "Dumping first %d recordings", num); +void cScrapManager::DumpRecordings(void) { + tell(0, "%d recordings in memory:", recordings.size()); for (map::iterator it = recordings.begin(); it != recordings.end(); it++) { sRecordingsKey key = it->first; sEventsValue val = it->second; - tell(0, "recStart %d, recPath %s, seriesId %d, episodeId %d, movieId %d", key.recStart, key.recPath.c_str(), val.seriesId, val.episodeId, val.movieId); + if (val.seriesId > 0) { + tell(0, "series (tvdbID %d, episodeId %d): %s", val.seriesId, val.episodeId, key.recPath.c_str()); + } else if (val.movieId) { + tell(0, "movie (moviedbID %d): %s", val.movieId, key.recPath.c_str()); + } else { + tell(0, "unknown recording: %s", key.recPath.c_str()); + } } } bool cScrapManager::GetEventType(ScraperGetEventType *call) { + if (config.debug) { + tell(0, "scraper2vdr plugin service call GetEventType called"); + } sEventsValue v; if (call->event) { sEventsKey k; k.eventId = call->event->EventID(); k.channelId = *(call->event->ChannelID().ToString()); map::iterator hit = events.find(k); - if (hit == events.end()) + if (hit == events.end()) { + if (config.debug) { + tell(0, "no event found for eventID %d, channelID %s", k.eventId, k.channelId.c_str()); + } return false; + } + if (config.debug) + tell(0, "event found for eventID %d, channelID %s", k.eventId, k.channelId.c_str()); v = hit->second; } else if (call->recording) { sRecordingsKey k; k.recStart = call->recording->Start(); k.recPath = getRecPath(call->recording); map::iterator hit = recordings.find(k); - if (hit == recordings.end()) + if (hit == recordings.end()) { + if (config.debug) { + tell(0, "no recording found for recStart %d, recPath %s", k.recStart, k.recPath.c_str()); + } return false; + } v = hit->second; + if (config.debug) { + tell(0, "recording found for recStart %d, recPath %s", k.recStart, k.recPath.c_str()); + } } if (v.seriesId > 0) { call->type = tSeries; + if (config.debug) + tell(0, "series detected, seriesId %d, episodeId %d", v.seriesId, v.episodeId); } else if (v.movieId > 0) { call->type = tMovie; + if (config.debug) + tell(0, "movie detected, movieId %d", v.movieId); } else { + if (config.debug) + tell(0, "unvalid entry"); call->type = tNone; return false; } diff --git a/scrapmanager.h b/scrapmanager.h index 682bd65..c5b5782 100644 --- a/scrapmanager.h +++ b/scrapmanager.h @@ -67,9 +67,9 @@ class cScrapManager { bool SeriesInUse(int seriesId); bool MovieInUse(int movieId); //Debug - void DumpSeries(int num); - void DumpMovies(int num); - void DumpRecordings(int num); + void DumpSeries(void); + void DumpMovies(void); + void DumpRecordings(void); //Service Calls bool GetEventType(ScraperGetEventType *call); bool GetSeries(cSeries *series); diff --git a/setup.c b/setup.c index 3e9a1e2..e9bd7b4 100644 --- a/setup.c +++ b/setup.c @@ -21,6 +21,7 @@ void cScraper2VdrSetup::Setup(void) { Clear(); Add(new cMenuEditBoolItem(tr("Show Main Menu Entry"), &tmpConfig.mainMenuEntry)); + Add(new cMenuEditBoolItem(tr("Debug Mode"), &tmpConfig.debug)); Add(new cMenuEditStrItem(tr("MySQL Host"), host, sizeof(host), tr(FileNameChars))); Add(new cMenuEditIntItem(tr("MySQL Port"), &tmpConfig.mysqlPort, 1, 99999)); Add(new cMenuEditStrItem(tr("MySQL Database Name"), dbname, sizeof(dbname), tr(FileNameChars))); @@ -75,4 +76,5 @@ void cScraper2VdrSetup::Store(void) { SetupStore("mysqlDBName", tmpConfig.mysqlDBName.c_str()); SetupStore("mysqlDBUser", tmpConfig.mysqlDBUser.c_str()); SetupStore("mysqlDBPass", tmpConfig.mysqlDBPass.c_str()); + SetupStore("debug", tmpConfig.debug); } diff --git a/update.c b/update.c index 713aba2..93d7816 100644 --- a/update.c +++ b/update.c @@ -1314,3 +1314,4 @@ void cUpdate::TriggerCleanRecordingsDB(void) { tell(0, "cleanup of recording DB triggered"); forceCleanupRecordingDb = true; } +