Skip to content

Commit

Permalink
Change EPG broadcast identifier values to be based on a hash of the c…
Browse files Browse the repository at this point in the history
…hannel and program start/end times
  • Loading branch information
djp952 committed Oct 14, 2018
1 parent 00a1685 commit beb2308
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
3 changes: 2 additions & 1 deletion pvr.hdhomerundvr/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
v1.3.5 (2018.10.xx)
v1.3.5 (2018.10.13)
- Update SQLite database engine to version 3.25.2
- Automatically delete and recreate the PVR database if any exceptions occur opening it during startup
- Fix bug causing internal exception when trying to poke the HDHomeRun RECORD engine after deleting a recording rule
- Change EPG broadcast identifier values to be based on a hash of the channel and program start/end times

v1.3.4 (2018.09.21)
- Update SQLite database engine to version 3.25.1
Expand Down
24 changes: 13 additions & 11 deletions src/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1594,6 +1594,7 @@ void enumerate_guideentries(sqlite3* instance, union channelid channelid, time_t
auto sql = "with deviceauth(code) as (select url_encode(group_concat(json_extract(data, '$.DeviceAuth'), '')) from device) "
"select json_extract(entry.value, '$.SeriesID') as seriesid, "
"json_extract(entry.value, '$.Title') as title, "
"fnv_hash(?2, json_extract(value, '$.StartTime'), json_extract(value, '$.EndTime')) as broadcastid, "
"json_extract(entry.value, '$.StartTime') as starttime, "
"json_extract(entry.value, '$.EndTime') as endtime, "
"json_extract(entry.value, '$.Synopsis') as synopsis, "
Expand Down Expand Up @@ -1639,18 +1640,19 @@ void enumerate_guideentries(sqlite3* instance, union channelid channelid, time_t
struct guideentry item;
item.seriesid = reinterpret_cast<char const*>(sqlite3_column_text(statement, 0));
item.title = reinterpret_cast<char const*>(sqlite3_column_text(statement, 1));
item.broadcastid = static_cast<unsigned int>(sqlite3_column_int(statement, 2));
item.channelid = channelid.value;
item.starttime = static_cast<unsigned int>(sqlite3_column_int(statement, 2));
item.endtime = static_cast<unsigned int>(sqlite3_column_int(statement, 3));
item.synopsis = reinterpret_cast<char const*>(sqlite3_column_text(statement, 4));
item.year = sqlite3_column_int(statement, 5);
item.iconurl = reinterpret_cast<char const*>(sqlite3_column_text(statement, 6));
item.genretype = sqlite3_column_int(statement, 7);
item.genres = reinterpret_cast<char const*>(sqlite3_column_text(statement, 8));
item.originalairdate = sqlite3_column_int(statement, 9);
item.seriesnumber = sqlite3_column_int(statement, 10);
item.episodenumber = sqlite3_column_int(statement, 11);
item.episodename = reinterpret_cast<char const*>(sqlite3_column_text(statement, 12));
item.starttime = static_cast<unsigned int>(sqlite3_column_int(statement, 3));
item.endtime = static_cast<unsigned int>(sqlite3_column_int(statement, 4));
item.synopsis = reinterpret_cast<char const*>(sqlite3_column_text(statement, 5));
item.year = sqlite3_column_int(statement, 6);
item.iconurl = reinterpret_cast<char const*>(sqlite3_column_text(statement, 7));
item.genretype = sqlite3_column_int(statement, 8);
item.genres = reinterpret_cast<char const*>(sqlite3_column_text(statement, 9));
item.originalairdate = sqlite3_column_int(statement, 10);
item.seriesnumber = sqlite3_column_int(statement, 11);
item.episodenumber = sqlite3_column_int(statement, 12);
item.episodename = reinterpret_cast<char const*>(sqlite3_column_text(statement, 13));

// Move the starttime to the last seen endtime to continue the backend queries
if(item.endtime > starttime) starttime = item.endtime;
Expand Down
1 change: 1 addition & 0 deletions src/database.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ struct guideentry {

char const* seriesid;
char const* title;
unsigned int broadcastid;
unsigned int channelid;
time_t starttime;
time_t endtime;
Expand Down
3 changes: 2 additions & 1 deletion src/pvr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,8 @@ static bool try_getepgforchannel(ADDON_HANDLE handle, PVR_CHANNEL const& channel
memset(&epgtag, 0, sizeof(EPG_TAG)); // Initialize the structure

// iUniqueBroadcastId (required)
epgtag.iUniqueBroadcastId = static_cast<unsigned int>(item.starttime);
assert(item.broadcastid > EPG_TAG_INVALID_UID);
epgtag.iUniqueBroadcastId = item.broadcastid;

// strTitle (required)
if(item.title == nullptr) return;
Expand Down

0 comments on commit beb2308

Please sign in to comment.