Skip to content

Commit

Permalink
Merge pull request #12 from afedchin/fix_spamming
Browse files Browse the repository at this point in the history
Fixed possible traffic spamming
  • Loading branch information
afedchin committed Apr 8, 2015
2 parents 38a72e5 + a2e6c6f commit 000ff75
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 15 deletions.
2 changes: 1 addition & 1 deletion pvr.iptvsimple/addon.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon
id="pvr.iptvsimple"
version="1.11.0"
version="1.11.1"
name="PVR IPTV Simple Client"
provider-name="nightik">
<requires>
Expand Down
3 changes: 3 additions & 0 deletions pvr.iptvsimple/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
v1.11.1
- fixed EPG loading.

v1.11.0
- updated to API v1.9.6
- new feature: channel logos from xmltv
Expand Down
17 changes: 4 additions & 13 deletions src/PVRIptvData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ PVRIptvData::PVRIptvData(void)
m_bTSOverride = g_bTSOverride;
m_iLastStart = 0;
m_iLastEnd = 0;
m_bEGPLoaded = false;

m_channels.clear();
m_groups.clear();
Expand Down Expand Up @@ -109,7 +108,6 @@ bool PVRIptvData::LoadEPG(time_t iStart, time_t iEnd)
if (m_strXMLTVUrl.empty())
{
XBMC->Log(LOG_NOTICE, "EPG file path is not configured. EPG not loaded.");
m_bEGPLoaded = true;
return false;
}

Expand All @@ -134,9 +132,6 @@ bool PVRIptvData::LoadEPG(time_t iStart, time_t iEnd)
if (iReaded == 0)
{
XBMC->Log(LOG_ERROR, "Unable to load EPG file '%s': file is missing or empty. After %d tries.", m_strXMLTVUrl.c_str(), iCount);
m_bEGPLoaded = true;
m_iLastStart = iStart;
m_iLastEnd = iEnd;
return false;
}

Expand All @@ -148,7 +143,6 @@ bool PVRIptvData::LoadEPG(time_t iStart, time_t iEnd)
if (!GzipInflate(data, decompressed))
{
XBMC->Log(LOG_ERROR, "Invalid EPG file '%s': unable to decompress file.", m_strXMLTVUrl.c_str());
m_bEGPLoaded = true;
return false;
}
buffer = &(decompressed[0]);
Expand All @@ -169,7 +163,6 @@ bool PVRIptvData::LoadEPG(time_t iStart, time_t iEnd)
else
{
XBMC->Log(LOG_ERROR, "Invalid EPG file '%s': unable to parse file.", m_strXMLTVUrl.c_str());
m_bEGPLoaded = true;
return false;
}
}
Expand All @@ -183,15 +176,13 @@ bool PVRIptvData::LoadEPG(time_t iStart, time_t iEnd)
catch(parse_error p)
{
XBMC->Log(LOG_ERROR, "Unable parse EPG XML: %s", p.what());
m_bEGPLoaded = true;
return false;
}

xml_node<> *pRootElement = xmlDoc.first_node("tv");
if (!pRootElement)
{
XBMC->Log(LOG_ERROR, "Invalid EPG XML: no <tv> tag found");
m_bEGPLoaded = true;
return false;
}

Expand Down Expand Up @@ -294,7 +285,6 @@ bool PVRIptvData::LoadEPG(time_t iStart, time_t iEnd)
xmlDoc.clear();
LoadGenres();

m_bEGPLoaded = true;
XBMC->Log(LOG_NOTICE, "EPG Loaded.");

if (g_iEPGLogos > 0)
Expand Down Expand Up @@ -665,10 +655,12 @@ PVR_ERROR PVRIptvData::GetEPGForChannel(ADDON_HANDLE handle, const PVR_CHANNEL &
if (myChannel->iUniqueId != (int) channel.iUniqueId)
continue;

if (!m_bEGPLoaded || iStart > m_iLastStart || iEnd > m_iLastEnd)
if (iStart > m_iLastStart || iEnd > m_iLastEnd)
{
if (LoadEPG(iStart, iEnd))
// reload EPG for new time interval only
LoadEPG(iStart, iEnd);
{
// doesn't matter is epg loaded or not we shouldn't try to load it for same interval
m_iLastStart = iStart;
m_iLastEnd = iEnd;
}
Expand Down Expand Up @@ -1030,7 +1022,6 @@ void PVRIptvData::ReloadEPG(const char * strNewPath)
if (strNewPath != m_strXMLTVUrl)
{
m_strXMLTVUrl = strNewPath;
m_bEGPLoaded = false;
// TODO clear epg for all channels

if (LoadEPG(m_iLastStart, m_iLastEnd))
Expand Down
1 change: 0 additions & 1 deletion src/PVRIptvData.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ class PVRIptvData : public PLATFORM::CThread

private:
bool m_bTSOverride;
bool m_bEGPLoaded;
int m_iEPGTimeShift;
int m_iLastStart;
int m_iLastEnd;
Expand Down

0 comments on commit 000ff75

Please sign in to comment.