Skip to content

Commit

Permalink
Improve and fix loading EPG data
Browse files Browse the repository at this point in the history
  • Loading branch information
rbuehlma committed Aug 2, 2024
1 parent a0a7519 commit 6a0e3f4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion pvr.zattoo/addon.xml.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon id="pvr.zattoo"
version="21.0.2"
version="21.0.3"
name="Zattoo PVR Client"
provider-name="trummerjo,rbuehlma">
<requires>
Expand Down
2 changes: 2 additions & 0 deletions pvr.zattoo/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
v21.0.3
- Improve and fix loading EPG data
v21.0.2
- Add smart tv option
v21.0.1
Expand Down
17 changes: 7 additions & 10 deletions src/epg/ZattooEpgProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ bool ZattooEpgProvider::LoadEPGForChannel(ZatChannel &notUsed, time_t iStart, ti
doc.Parse(jsonString.c_str());
if (doc.GetParseError())
{
kodi::Log(ADDON_LOG_ERROR, "Loading epg faild from %lu to %lu", iStart, iEnd);
kodi::Log(ADDON_LOG_ERROR, "Loading epg failed from %lu to %lu", iStart, iEnd);
return false;
}
RegisterAlreadyLoaded(tempStart, tempEnd);
Expand All @@ -69,8 +69,6 @@ bool ZattooEpgProvider::LoadEPGForChannel(ZatChannel &notUsed, time_t iStart, ti
m_epgDB.BeginTransaction();
for (Value::ConstMemberIterator iter = channels.MemberBegin(); iter != channels.MemberEnd(); ++iter) {
std::string cid = iter->name.GetString();

int uniqueChannelId = Utils::GetChannelId(cid.c_str());

if (m_visibleChannelsByCid.count(cid) == 0) {
continue;
Expand Down Expand Up @@ -107,9 +105,6 @@ bool ZattooEpgProvider::LoadEPGForChannel(ZatChannel &notUsed, time_t iStart, ti
epgDBInfo.endTime = program["e"].GetInt();
epgDBInfo.title = Utils::JsonStringOrEmpty(program, "t");
epgDBInfo.subtitle = Utils::JsonStringOrEmpty(program, "et");
if (!epgDBInfo.detailsLoaded) {
epgDBInfo.description = Utils::JsonStringOrEmpty(program, "et");
}
epgDBInfo.genre = genreString;
epgDBInfo.imageToken = Utils::JsonStringOrEmpty(program, "i_t");
epgDBInfo.cid = cid;
Expand Down Expand Up @@ -218,7 +213,7 @@ void ZattooEpgProvider::DetailsThread()
kodi::Log(ADDON_LOG_DEBUG, "Details thread started");
while (m_detailsThreadRunning)
{
std::list<EpgDBInfo> epgDBInfos = m_epgDB.GetWithWhere("DETAILS_LOADED=0 order by abs(strftime('%s','now')-END_TIME) limit 300;");
std::list<EpgDBInfo> epgDBInfos = m_epgDB.GetWithWhere("DETAILS_LOADED=0 order by abs(strftime('%s','now')-END_TIME) limit 20;");
kodi::Log(ADDON_LOG_DEBUG, "Loading details for %d epg entries.", epgDBInfos.size());
if (epgDBInfos.size() > 0) {
std::lock_guard<std::mutex> lock(sendEpgToKodiMutex);
Expand Down Expand Up @@ -266,8 +261,10 @@ void ZattooEpgProvider::DetailsThread()
epgDBInfo->season = program.HasMember("s_no") && !program["s_no"].IsNull() ? program["s_no"].GetInt() : -1;
epgDBInfo->episode = program.HasMember("e_no") && !program["e_no"].IsNull() ? program["e_no"].GetInt() : -1;

epgDBInfo->detailsLoaded=1;
m_epgDB.Update(*epgDBInfo);
epgDBInfo->detailsLoaded = 1;
if (!m_epgDB.Update(*epgDBInfo)) {
kodi::Log(ADDON_LOG_ERROR, "Failed to update epg data.");
}
SendEpgDBInfo(*epgDBInfo);
}
}
Expand All @@ -280,7 +277,7 @@ void ZattooEpgProvider::DetailsThread()
m_epgDB.EndTransaction();
}

for (int i = 0; i < 100; i++) {
for (int i = 0; i < 10; i++) {
if (!m_detailsThreadRunning) {
break;
}
Expand Down

0 comments on commit 6a0e3f4

Please sign in to comment.