Skip to content
This repository has been archived by the owner on Apr 15, 2023. It is now read-only.

[iptvsimple] new version 1.9.3. #257

Merged
merged 1 commit into from
Jan 25, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion addons/pvr.iptvsimple/addon/addon.xml.in
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.9.2"
version="1.9.3"
name="PVR IPTV Simple Client"
provider-name="nightik">
<requires>
Expand Down
7 changes: 7 additions & 0 deletions addons/pvr.iptvsimple/addon/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
v1.9.3
- added setting to disable cache m3u/epg
- added support <icon src=""/> for programme in epg
- added possibility to specify logo path as URL
- changed tvg-logo should contains full logo filename (with extention)
- changed don't try download xmltv if it doesn't load after 3 attempt.

v1.9.2
- add timeshift buffer functions

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ msgstr ""
#settings labels

msgctxt "#30000"
msgid "File Location"
msgid "Location"
msgstr ""

msgctxt "#30001"
Expand Down Expand Up @@ -67,10 +67,22 @@ msgctxt "#30024"
msgid "EPG Time Shift (hours)"
msgstr ""

msgctxt "#30025"
msgid "Cache m3u at local storage"
msgstr ""

msgctxt "#30026"
msgid "Cache XMLTV at local storage"
msgstr ""

msgctxt "#30030"
msgid "Channels Logos"
msgstr ""

msgctxt "#30031"
msgid "Channels Logos Folder"
msgstr ""

msgctxt "#30032"
msgid "Channels Logos Base URL"
msgstr ""
9 changes: 6 additions & 3 deletions addons/pvr.iptvsimple/addon/resources/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<setting id="m3uPathType" type="enum" label="30000" lvalues="30001|30002" default="1" />
<setting id="m3uPath" type="file" label="30011" default="" visible="eq(-1,0)"/>
<setting id="m3uUrl" type="text" label="30012" default="" visible="eq(-2,1)"/>
<setting id="m3uCache" type="bool" label="30025" default="true" visible="eq(-3,1)"/>
<setting id="startNum" type="number" label="30013" default="1" />
</category>

Expand All @@ -15,14 +16,16 @@
<setting id="epgPathType" type="enum" label="30000" lvalues="30001|30002" default="1" />
<setting id="epgPath" type="file" label="30021" default="" visible="eq(-1,0)"/>
<setting id="epgUrl" type="text" label="30022" default="" visible="eq(-2,1)"/>
<!-- <setting id="epgTimeShift" type="slider" label="30024" default="0" range="-12,.5,12" option="float"/>-->
<setting id="epgTimeShift_" type="enum" label="30024" default="12" values="-12|-11|-10|-9|-8|-7|-6|-5|-4|-3|-2|-1|0|+1|+2|+3|+4|+5|+6|+7|+8|+9|+10|+11|+12"/>-->
<setting id="epgCache" type="bool" label="30026" default="true" visible="eq(-3,1)"/>
<setting id="epgTimeShift" type="slider" label="30024" default="0" range="-12,.5,12" option="float"/>
<setting id="epgTSOverride" type="bool" label="30023" default="false"/>
</category>

<!-- Logos -->
<category label="30030">
<setting id="sep3" label="30030" type="lsep"/>
<setting id="logoPath" type="folder" label="30031" default="" />
<setting id="logoPathType" type="enum" label="30000" lvalues="30001|30002" default="1" />
<setting id="logoPath" type="folder" label="30031" default="" visible="eq(-1,0)"/>
<setting id="logoBaseUrl" type="text" label="30032" default="" visible="eq(-2,1)"/>
</category>
</settings>
39 changes: 27 additions & 12 deletions addons/pvr.iptvsimple/src/PVRIptvData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,21 +115,23 @@ bool PVRIptvData::LoadEPG(time_t iStart, time_t iEnd)
int iCount = 0;
while(iCount < 3) // max 3 tries
{
if ((iReaded = GetCachedFileContents(TVG_FILE_NAME, m_strXMLTVUrl, data)) != 0)
if ((iReaded = GetCachedFileContents(TVG_FILE_NAME, m_strXMLTVUrl, data, g_bCacheEPG)) != 0)
{
break;
}
XBMC->Log(LOG_ERROR, "Unable to load EPG file '%s': file is missing or empty. :%dth try.", m_strXMLTVUrl.c_str(), ++iCount);
if (iCount < 3)
{
usleep(5 * 1000 * 1000); // sleep 5 sec before next try.
usleep(2 * 1000 * 1000); // sleep 2 sec before next try.
}
}

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 Down Expand Up @@ -283,13 +285,24 @@ bool PVRIptvData::LoadEPG(time_t iStart, time_t iEnd)
GetNodeValue(pChannelNode, "category", strCategory);
GetNodeValue(pChannelNode, "desc", strDesc);

CStdString strIconPath;
xml_node<> *pIconNode = pChannelNode->first_node("icon");
if (pIconNode != NULL)
{
if (!GetAttributeValue(pIconNode, "src", strIconPath))
{
strIconPath = "";
}
}

PVRIptvEpgEntry entry;
entry.iBroadcastId = ++iBroadCastId;
entry.iGenreType = 0;
entry.iGenreSubType = 0;
entry.strTitle = strTitle;
entry.strPlot = strDesc;
entry.strPlotOutline = "";
entry.strIconPath = strIconPath;
entry.startTime = iTmpStart;
entry.endTime = iTmpEnd;
entry.strGenreString = strCategory;
Expand All @@ -314,7 +327,7 @@ bool PVRIptvData::LoadPlayList(void)
}

CStdString strPlaylistContent;
if (!GetCachedFileContents(M3U_FILE_NAME, m_strM3uUrl, strPlaylistContent))
if (!GetCachedFileContents(M3U_FILE_NAME, m_strM3uUrl, strPlaylistContent, g_bCacheM3U))
{
XBMC->Log(LOG_ERROR, "Unable to load playlist file '%s': file is missing or empty.", m_strM3uUrl.c_str());
return false;
Expand Down Expand Up @@ -607,8 +620,7 @@ PVR_ERROR PVRIptvData::GetEPGForChannel(ADDON_HANDLE handle, const PVR_CHANNEL &
continue;
}

if (!m_bEGPLoaded ||
iStart > m_iLastStart || iEnd > m_iLastEnd)
if (!m_bEGPLoaded || iStart > m_iLastStart || iEnd > m_iLastEnd)
{
if (LoadEPG(iStart, iEnd))
{
Expand All @@ -618,8 +630,7 @@ PVR_ERROR PVRIptvData::GetEPGForChannel(ADDON_HANDLE handle, const PVR_CHANNEL &
}

PVRIptvEpgChannel *epg;
if ((epg = FindEpgForChannel(*myChannel)) == NULL
|| epg->epg.size() == 0)
if ((epg = FindEpgForChannel(*myChannel)) == NULL || epg->epg.size() == 0)
{
return PVR_ERROR_NO_ERROR;
}
Expand Down Expand Up @@ -852,21 +863,23 @@ bool PVRIptvData::GzipInflate( const std::string& compressedBytes, std::string&
return true ;
}

int PVRIptvData::GetCachedFileContents(const std::string &strCachedName, const std::string &filePath, std::string &strContents)
int PVRIptvData::GetCachedFileContents(const std::string &strCachedName, const std::string &filePath,
std::string &strContents, const bool bUseCache /* false */)
{
bool bNeedReload = false;
CStdString strCachedPath = GetUserFilePath(strCachedName);
CStdString strFilePath = filePath;

if (XBMC->FileExists(strCachedPath, false))
// check cached file is exists
if (bUseCache && XBMC->FileExists(strCachedPath, false))
{
struct __stat64 statCached;
struct __stat64 statOrig;

XBMC->StatFile(strCachedPath, &statCached);
XBMC->StatFile(strFilePath, &statOrig);

bNeedReload = statCached.st_mtime < statOrig.st_mtime;
bNeedReload = statCached.st_mtime < statOrig.st_mtime || statOrig.st_mtime == 0;
}
else
{
Expand All @@ -876,7 +889,9 @@ int PVRIptvData::GetCachedFileContents(const std::string &strCachedName, const s
if (bNeedReload)
{
GetFileContents(strFilePath, strContents);
if (strContents.length() > 0)

// write to cache
if (bUseCache && strContents.length() > 0)
{
void* fileHandle = XBMC->OpenFileForWrite(strCachedPath, true);
if (fileHandle)
Expand All @@ -900,7 +915,7 @@ void PVRIptvData::ApplyChannelsLogos()
for(channel = m_channels.begin(); channel < m_channels.end(); channel++)
{
channel->strLogoPath = PathCombine(m_strLogoPath, channel->strTvgLogo);
channel->strLogoPath.append(CHANNEL_LOGO_EXTENSION);
//channel->strLogoPath.append(CHANNEL_LOGO_EXTENSION);
}
}

Expand Down
3 changes: 2 additions & 1 deletion addons/pvr.iptvsimple/src/PVRIptvData.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ class PVRIptvData : public PLATFORM::CThread
virtual PVRIptvEpgChannel *FindEpgForChannel(PVRIptvChannel &channel);
virtual int ParseDateTime(CStdString strDate, bool iDateFormat = true);
virtual bool GzipInflate( const std::string &compressedBytes, std::string &uncompressedBytes);
virtual int GetCachedFileContents(const std::string &strCachedName, const std::string &strFilePath, std::string &strContent);
virtual int GetCachedFileContents(const std::string &strCachedName, const std::string &strFilePath,
std::string &strContent, const bool bUseCache = false);
virtual void ApplyChannelsLogos();
virtual CStdString ReadMarkerValue(std::string &strLine, const char * strMarkerName);
virtual int GetChannelId(const char * strChannelName, const char * strStreamUrl);
Expand Down
62 changes: 44 additions & 18 deletions addons/pvr.iptvsimple/src/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ std::string g_strLogoPath = "";
int g_iEPGTimeShift = 0;
int g_iStartNumber = 1;
bool g_bTSOverride = true;
bool g_bCacheM3U = false;
bool g_bCacheEPG = false;

extern std::string PathCombine(const std::string &strPath, const std::string &strFileName)
{
Expand Down Expand Up @@ -94,10 +96,24 @@ void ADDON_ReadSettings(void)
{
iPathType = 1;
}
CStdString strSettingName = iPathType ? "m3uUrl" : "m3uPath";
if (XBMC->GetSetting(strSettingName, &buffer))
if (iPathType)
{
g_strM3UPath = buffer;
if (XBMC->GetSetting("m3uUrl", &buffer))
{
g_strM3UPath = buffer;
}
if (!XBMC->GetSetting("m3uCache", &g_bCacheM3U))
{
g_bCacheM3U = true;
}
}
else
{
if (XBMC->GetSetting("m3uPath", &buffer))
{
g_strM3UPath = buffer;
}
g_bCacheM3U = false;
}
if (g_strM3UPath == "")
{
Expand All @@ -111,29 +127,39 @@ void ADDON_ReadSettings(void)
{
iPathType = 1;
}
strSettingName = iPathType ? "epgUrl" : "epgPath";
if (XBMC->GetSetting(strSettingName, &buffer))
if (iPathType)
{
g_strTvgPath = buffer;
if (XBMC->GetSetting("epgUrl", &buffer))
{
g_strTvgPath = buffer;
}
if (!XBMC->GetSetting("epgCache", &g_bCacheEPG))
{
g_bCacheEPG = true;
}
}
// BUG! xbmc does not return slider value
//float dTimeShift;
//if (XBMC->GetSetting("epgTimeShift", &dTimeShift))
//{
// g_iEPGTimeShift = (int)(dTimeShift * 3600.0); // hours to seconds
//}
int itmpShift;
if (XBMC->GetSetting("epgTimeShift_", &itmpShift))
else
{
itmpShift -= 12;
g_iEPGTimeShift = (int)(itmpShift * 3600.0); // hours to seconds
if (XBMC->GetSetting("epgPath", &buffer))
{
g_strTvgPath = buffer;
}
g_bCacheEPG = false;
}
float fShift;
if (XBMC->GetSetting("epgTimeShift", &fShift))
{
g_iEPGTimeShift = (int)(fShift * 3600.0); // hours to seconds
}
if (!XBMC->GetSetting("epgTSOverride", &g_bTSOverride))
{
g_bTSOverride = true;
}

if (XBMC->GetSetting("logoPath", &buffer))
if (!XBMC->GetSetting("logoPathType", &iPathType))
{
iPathType = 1;
}
if (XBMC->GetSetting(iPathType ? "logoBaseUrl" : "logoPath", &buffer))
{
g_strLogoPath = buffer;
}
Expand Down
4 changes: 3 additions & 1 deletion addons/pvr.iptvsimple/src/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include "libXBMC_pvr.h"
#include "libXBMC_gui.h"

#define PVR_CLIENT_VERSION "1.8.1"
#define PVR_CLIENT_VERSION "1.9.3"
#define M3U_FILE_NAME "iptv.m3u.cache"
#define TVG_FILE_NAME "xmltv.xml.cache"

Expand All @@ -49,6 +49,8 @@ extern std::string g_strLogoPath;
extern int g_iEPGTimeShift;
extern int g_iStartNumber;
extern bool g_bTSOverride;
extern bool g_bCacheM3U;
extern bool g_bCacheEPG;

extern std::string PathCombine(const std::string &strPath, const std::string &strFileName);
extern std::string GetClientFilePath(const std::string &strFileName);
Expand Down