summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitar Petrovski <dimeptr@gmail.com>2011-10-25 23:54:36 +0200
committerDimitar Petrovski <dimeptr@gmail.com>2011-10-25 23:54:36 +0200
commitd7ffd368b513b9fc5e03842add42eb7ded562a61 (patch)
treea5d05c488ee7749ecfbe7451481d9be8f67585ac
parenta57a6174875e05911039276f36f17cd538f494a3 (diff)
downloadvdr-plugin-eepg-d7ffd368b513b9fc5e03842add42eb7ded562a61.tar.gz
vdr-plugin-eepg-d7ffd368b513b9fc5e03842add42eb7ded562a61.tar.bz2
Add Program ID / Series ID
fix ratings
-rw-r--r--dish.c77
-rw-r--r--dish.h10
-rw-r--r--eepg.c42
3 files changed, 108 insertions, 21 deletions
diff --git a/dish.c b/dish.c
index 8e8c3f5..8a046f9 100644
--- a/dish.c
+++ b/dish.c
@@ -14,6 +14,7 @@
#include <libsi/si.h>
#include <libsi/descriptor.h>
#include <string.h>
+#include <string>
#include <stdlib.h>
#include <vdr/tools.h>
@@ -51,6 +52,9 @@ namespace SI
DishCategory = 0;
mpaaRating = 0;
starRating = 0;
+ originalAirDate = 0;
+ programId = NULL;
+ seriesId = NULL;
}
DishDescriptor::~DishDescriptor()
@@ -59,6 +63,10 @@ namespace SI
decompressedShort = NULL;
delete [] decompressedExtended;
decompressedExtended = NULL;
+ delete [] programId;
+ programId = NULL;
+ delete [] seriesId;
+ seriesId = NULL;
}
const char *DishDescriptor::getTheme()
@@ -322,6 +330,41 @@ namespace SI
return description?description:"";
}
+ const char *DishDescriptor::getProgramId(void) {
+ return programId?programId:"";
+ }
+
+ const char *DishDescriptor::getSeriesId(void) {
+ return seriesId?seriesId:"";
+ }
+
+ void DishDescriptor::setEpisodeInfo(CharArray data)
+ {
+ int series = (data[1] << 0x12) | (data[2] << 0x0a) | (data[3] << 0x02) | ((data[4] & 0xc0) >> 0x06);
+ int episode = ((data[4] & 0x3f) << 0x08) | data[5];
+ const char* prefix;
+
+ if (data[0] == 0x7c)
+ prefix = "MV";
+ else if (data[0] == 0x7d)
+ prefix = "SP";
+ else if (data[0] == 0x7e)
+ prefix = "EP";
+
+ programId = new char[17];
+ seriesId = new char[11];
+ //programId =
+ sprintf(programId, "%s%08d%04d", (data[0] == 0x7e && episode == 0 ? "SH" : prefix), series, episode);
+
+ if (data[0] == 0x7e)
+ sprintf(seriesId, "%s08d", prefix, series);
+
+ if (data.TwoBytes(6) != 0 && data.TwoBytes(6) != 0x9e8b ) {
+
+ originalAirDate = (data[6] << 0x08 | data[7]) - 40587 * 86400;
+ }
+ }
+
void DishDescriptor::setContent(ContentDescriptor::Nibble Nibble)
{
DishTheme = Nibble.getContentNibbleLevel2() & 0xF;
@@ -344,24 +387,36 @@ namespace SI
return ratings[mpaaRating];
}
- char buffer[19];
- buffer[0] = 0;
- strcpy(buffer, ratings[(mpaaRating >> 10) & 0x07]);
+ std::string str = ratings[(mpaaRating >> 10) & 0x07];
+// char buffer[19];
+// buffer[0] = 0;
+// strcpy(buffer, ratings[(mpaaRating >> 10) & 0x07]);
if (mpaaRating & 0x3A7F) {
- strcat(buffer, " [");
+ str += " [";
+// strcat(buffer, " [");
if (mpaaRating & 0x0230)
- strcat(buffer, "V,");
+ str += "V,";
+// strcat(buffer, "V,");
if (mpaaRating & 0x000A)
- strcat(buffer, "L,");
+ str += "L,";
+// strcat(buffer, "L,");
if (mpaaRating & 0x0044)
- strcat(buffer, "N,");
+ str += "N,";
+// strcat(buffer, "N,");
if (mpaaRating & 0x0101)
- strcat(buffer, "SC,");
- if (char *s = strrchr(buffer, ','))
- s[0] = ']';
+ str += "SC,";
+// strcat(buffer, "SC,");
+// if (char *s = strrchr(buffer, ','))
+// s[0] = ']';
+ if (str.find(',') != std::string::npos) {
+ str.erase(str.find_last_of(','));
}
+ str += "]";
+ }
+
+ return str.c_str();
- return isempty(buffer) ? "" : buffer;
+// return isempty(buffer) ? "" : buffer;
}
const char* DishDescriptor::getStarRating(){
diff --git a/dish.h b/dish.h
index c9fcfe1..07f0547 100644
--- a/dish.h
+++ b/dish.h
@@ -12,6 +12,7 @@
#include <libsi/util.h>
#include <libsi/descriptor.h>
+#include <time.h>
namespace SI
{
@@ -257,12 +258,16 @@ public:
const char *getCategory();
const char *getRating();
const char *getStarRating();
+ const char *getSeriesId();
+ const char *getProgramId();
+ time_t getOriginalAirDate() { return originalAirDate; }
bool hasTheme() {return DishTheme > 0;}
bool hasCategory() {return DishCategory > 0;}
void setShortData(unsigned char Tid, CharArray data);
void setExtendedtData(unsigned char Tid, CharArray data);
void setRating(uint16_t value);
void setContent(ContentDescriptor::Nibble Nibble);
+ void setEpisodeInfo(CharArray data);
protected:
// Decompress the byte array and stores the result to a text string
@@ -275,7 +280,10 @@ protected:
unsigned char DishTheme;
unsigned char DishCategory;
uint16_t mpaaRating;
- uint16_t starRating;
+ uint8_t starRating;
+ time_t originalAirDate;
+ char* seriesId;
+ char* programId;
struct HuffmanTable {
diff --git a/eepg.c b/eepg.c
index 096c85d..2d91546 100644
--- a/eepg.c
+++ b/eepg.c
@@ -2813,7 +2813,9 @@ namespace SI
enum DescriptorTagExt {
DishRatingDescriptorTag = 0x89,
DishShortEventDescriptorTag = 0x91,
- DishExtendedEventDescriptorTag = 0x92 };
+ DishExtendedEventDescriptorTag = 0x92,
+ DishSeriesDescriptorTag = 0x96,
+ };
// typedef InheritEnum< DescriptorTagExt, SI::DescriptorTag > ExtendedDescriptorTag;
@@ -3192,7 +3194,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat
if (!DishEventDescriptor) {
DishEventDescriptor = new SI::DishDescriptor();
}
- DishEventDescriptor->setExtendedtData(Tid, deed->getData());
+ DishEventDescriptor->setExtendedtData(Tid+1, deed->getData());
HasExternalData = true;
}
break;
@@ -3201,15 +3203,27 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat
if (!DishEventDescriptor) {
DishEventDescriptor = new SI::DishDescriptor();
}
- DishEventDescriptor->setShortData(Tid, dsed->getData());
+ DishEventDescriptor->setShortData(Tid+1, dsed->getData());
HasExternalData = true;
}
break;
case SI::DishRatingDescriptorTag: {
- if (d->getLength() == 4 && DishEventDescriptor) {
- uint16_t rating = d->getData().TwoBytes(2);
- DishEventDescriptor->setRating(rating);
- }
+ if (d->getLength() == 4) {
+ if (!DishEventDescriptor) {
+ DishEventDescriptor = new SI::DishDescriptor();
+ }
+ uint16_t rating = d->getData().TwoBytes(2);
+ DishEventDescriptor->setRating(rating);
+ }
+ }
+ break;
+ case SI::DishSeriesDescriptorTag: {
+ if (d->getLength() == 4) {
+ if (!DishEventDescriptor) {
+ DishEventDescriptor = new SI::DishDescriptor();
+ }
+ DishEventDescriptor->setEpisodeInfo(d->getData());
+ }
}
break;
default:
@@ -3268,14 +3282,24 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat
fmt = "%s";
if (0 != strcmp(DishEventDescriptor->getDescription(),"") && (0 != strcmp(DishEventDescriptor->getRating(),"") || 0 != strcmp(DishEventDescriptor->getStarRating(),""))) {
- fmt += "|";
+ fmt += "\nRating: ";
+ }
+ fmt += "%s %s";
+ if (0 != strcmp(DishEventDescriptor->getProgramId(),"")) {
+ fmt += "\n Program ID: ";
}
fmt += "%s %s";
+ fmt += DishEventDescriptor->getOriginalAirDate() == 0 ? "%s" : " Original Air Date: ";
Asprintf (&tmp, fmt.c_str(), DishEventDescriptor->getDescription()
, DishEventDescriptor->getRating()
- , DishEventDescriptor->getStarRating());
+ , DishEventDescriptor->getStarRating()
+ , DishEventDescriptor->getProgramId()
+ , DishEventDescriptor->getSeriesId()
+ , DishEventDescriptor->getOriginalAirDate() == 0 ? "" : ctime (&DishEventDescriptor->getOriginalAirDate()));
pEvent->SetDescription(tmp);
free(tmp);
+
+
//LogD(2, prep("DishDescription: %s"), DishExtendedEventDescriptor->getText());
//LogD(2, prep("DishShortText: %s"), DishExtendedEventDescriptor->getShortText());
}