Skip to content
This repository was archived by the owner on May 18, 2022. It is now read-only.

Commit

Permalink
Add compatibility for VDR API >= 2.3.1.
Browse files Browse the repository at this point in the history
  • Loading branch information
unf committed May 10, 2017
1 parent 9a000ca commit 7183c4b
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
5 changes: 5 additions & 0 deletions config.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ void cTVScraperConfig::AddChannel(string channelID) {
}

bool cTVScraperConfig::ChannelActive(int channelNum) {
#if APIVERSNUM < 20301
cChannel *channel = Channels.GetByNumber(channelNum);
#else
LOCK_CHANNELS_READ;
const cChannel *channel = Channels->GetByNumber(channelNum);
#endif
if (channel) {
string channelID = "";
channelID = *(channel->GetChannelID().ToString());
Expand Down
17 changes: 16 additions & 1 deletion setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ using namespace std;

cTVScraperSetup::cTVScraperSetup(cTVScraperWorker *workerThread) {
worker = workerThread;
#if APIVERSNUM < 20301
int numChannels = Channels.Count();
#else
LOCK_CHANNELS_READ;
int numChannels = Channels->Count();
#endif
for (int i=0; i<numChannels; i++) {
int akt = 0;
if (config.ChannelActive(i+1))
Expand Down Expand Up @@ -60,7 +65,12 @@ void cTVScraperSetup::Store(void) {
int numChannels = channelsScrap.size();
for (int i=0; i<numChannels; i++) {
if (channelsScrap[i] == 1) {
#if APIVERSNUM < 20301
cChannel *channel = Channels.GetByNumber(i+1);
#else
LOCK_CHANNELS_READ;
const cChannel *channel = Channels->GetByNumber(i+1);
#endif
if (channel) {
string channelID = *(channel->GetChannelID().ToString());
channelsToScrap << channelID << ";";
Expand Down Expand Up @@ -89,7 +99,12 @@ void cTVScraperChannelSetup ::Setup(void) {
int currentItem = Current();
Clear();
int i=0;
#if APIVERSNUM < 20301
for (cChannel *channel = Channels.First(); channel; channel = Channels.Next(channel)) {
#else
LOCK_CHANNELS_READ;
for (const cChannel *channel = Channels->First(); channel; channel = Channels->Next(channel)) {
#endif
if (!channel->GroupSep()) {
Add(new cMenuEditBoolItem(channel->Name(), &channelsScrap->at(i), tr("don't scrap"), tr("scrap")));
i++;
Expand All @@ -108,4 +123,4 @@ eOSState cTVScraperChannelSetup ::ProcessKey(eKeys Key) {
break;
}
return state;
}
}
20 changes: 20 additions & 0 deletions worker.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,23 @@ void cTVScraperWorker::ScrapEPG(void) {
int numChannels = channels.size();
for (int i=0; i<numChannels; i++) {
string channelID = channels[i];
#if APIVERSNUM < 20301
const cChannel *channel = Channels.GetByChannelID(tChannelID::FromString(channelID.c_str()));
#else
LOCK_CHANNELS_READ;
const cChannel *channel = Channels->GetByChannelID(tChannelID::FromString(channelID.c_str()));
#endif
if (!channel)
continue;
dsyslog("tvscraper: scraping Channel %s %s", channel->Name(), channelID.c_str());
#if APIVERSNUM < 20301
cSchedulesLock schedulesLock;
const cSchedules *schedules = cSchedules::Schedules(schedulesLock);
const cSchedule *Schedule = schedules->GetSchedule(channel);
#else
LOCK_SCHEDULES_READ;
const cSchedule *Schedule = Schedules->GetSchedule(channel);
#endif
if (Schedule) {
const cEvent *event = NULL;
for (event = Schedule->Events()->First(); event; event = Schedule->Events()->Next(event)) {
Expand All @@ -160,7 +170,12 @@ void cTVScraperWorker::ScrapEPG(void) {

void cTVScraperWorker::ScrapRecordings(void) {
db->ClearRecordings();
#if APIVERSNUM < 20301
for (cRecording *rec = Recordings.First(); rec; rec = Recordings.Next(rec)) {
#else
LOCK_RECORDINGS_READ;
for (const cRecording *rec = Recordings->First(); rec; rec = Recordings->Next(rec)) {
#endif
if (overrides->IgnorePath(rec->FileName()))
continue;
const cRecordingInfo *recInfo = rec->Info();
Expand Down Expand Up @@ -188,7 +203,12 @@ void cTVScraperWorker::ScrapRecordings(void) {
}

void cTVScraperWorker::CheckRunningTimers(void) {
#if APIVERSNUM < 20301
for (cTimer *timer = Timers.First(); timer; timer = Timers.Next(timer)) {
#else
LOCK_TIMERS_READ;
for (const cTimer *timer = Timers->First(); timer; timer = Timers->Next(timer)) {
#endif
if (timer->Recording()) {
const cEvent *event = timer->Event();
if (!event)
Expand Down

0 comments on commit 7183c4b

Please sign in to comment.