summaryrefslogtreecommitdiff
path: root/scrapmanager.c
diff options
context:
space:
mode:
Diffstat (limited to 'scrapmanager.c')
-rw-r--r--scrapmanager.c126
1 files changed, 102 insertions, 24 deletions
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 <vdr/recording.h>
#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<int, cTVDBSeries*>::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<sEventsKey, sEventsValue>::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<int, cMovieDbMovie*>::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<sEventsKey, sEventsValue>::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<sRecordingsKey, sEventsValue>::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<sEventsKey, sEventsValue>::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<sRecordingsKey, sEventsValue>::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;
}