Skip to content

Commit

Permalink
Merge pull request #137 from phunkyfish/load-config-if-enabled
Browse files Browse the repository at this point in the history
Load config if enabled
  • Loading branch information
phunkyfish committed Dec 21, 2018
2 parents c3d984b + 9c0e360 commit 5741f24
Show file tree
Hide file tree
Showing 14 changed files with 68 additions and 38 deletions.
6 changes: 6 additions & 0 deletions pvr.vuplus/addon.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,12 @@
<disclaimer lang="zh_TW">這是測試版軟體!其原創作者並無法對於以下情況負責,包含:錄影失敗,不正確的定時設定,多餘時數,或任何產生的其它不良影響...</disclaimer>
<platform>@PLATFORM@</platform>
<news>
v3.15.2
- Fixed: Only load Season info extractor and genre mappers config when enabled, fixes #136
- Fixed: 3.15.1 dont load/work on old DM800se, fixes #139
- Fixed: Missing default value from timeshift buffer path, fixes #140
- Fixed: Channel Group Member Order not preserved, fixes #141

v3.15.1
- Fixed: since 3.15.0 pvr manager cant start #134
- Added: Log Distro Version
Expand Down
6 changes: 6 additions & 0 deletions pvr.vuplus/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
v3.15.2
- Fixed: Only load Season info extractor and genre mappers config when enabled, fixes #136
- Fixed: 3.15.1 dont load/work on old DM800se, fixes #139
- Fixed: Missing default value from timeshift buffer path, fixes #140
- Fixed: Channel Group Member Order not preserved, fixes #141

v3.15.1
- Fixed: since 3.15.0 pvr manager cant start #134
- Added: Log Distro Version
Expand Down
2 changes: 1 addition & 1 deletion pvr.vuplus/resources/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@
</setting>
<setting id="timeshiftbufferpath" type="path" parent="enabletimeshift" label="30062">
<level>0</level>
<default></default>
<default>special://userdata/addon_data/pvr.vuplus</default>
<constraints>
<allowempty>true</allowempty>
<writable>true</writable>
Expand Down
11 changes: 4 additions & 7 deletions src/Enigma2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,10 @@ bool Enigma2::OpenLiveStream(const PVR_CHANNEL &channelinfo)
// Zapping is set to true, so send the zapping command to the PVR box
std::string strServiceReference = m_channels.GetChannel(channelinfo.iUniqueId)->GetServiceReference().c_str();

std::string strTmp;
strTmp = StringUtils::Format("web/zap?sRef=%s", WebUtils::URLEncodeInline(strServiceReference).c_str());
std::string strCmd = StringUtils::Format("web/zap?sRef=%s", WebUtils::URLEncodeInline(strServiceReference).c_str());

std::string strResult;
if(!WebUtils::SendSimpleCommand(strTmp, strResult))
if(!WebUtils::SendSimpleCommand(strCmd, strResult))
return false;
}
}
Expand Down Expand Up @@ -340,10 +339,8 @@ const std::string Enigma2::GetLiveStreamURL(const PVR_CHANNEL &channelinfo)
*/
std::string Enigma2::GetStreamURL(const std::string& strM3uURL)
{
std::string strTmp;
strTmp = strM3uURL;
std::string strM3U;
strM3U = WebUtils::GetHttpXML(strTmp);
std::string strTmp = strM3uURL;
std::string strM3U = WebUtils::GetHttpXML(strTmp);
std::istringstream streamM3U(strM3U);
std::string strURL = "";
while (std::getline(streamM3U, strURL))
Expand Down
9 changes: 6 additions & 3 deletions src/enigma2/Admin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,13 @@ bool Admin::LoadDeviceInfo()
// Get DistroVersion
if (!XMLUtils::GetString(pElem, "e2distroversion", strTmp))
{
Logger::Log(LEVEL_ERROR, "%s Could not parse e2distroversion from result!", __FUNCTION__);
return false;
Logger::Log(LEVEL_NOTICE, "%s Could not parse e2distroversion from result, continuing as not available in all images!", __FUNCTION__);
strTmp = LocalizedString(60081); //unknown
}
else
{
distroVersion = strTmp.c_str();
}
distroVersion = strTmp.c_str();
Logger::Log(LEVEL_NOTICE, "%s - E2DistroVersion: %s", __FUNCTION__, distroVersion.c_str());

// Get WebIfVersion
Expand Down
28 changes: 25 additions & 3 deletions src/enigma2/ChannelGroups.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ using namespace enigma2::utilities;

void ChannelGroups::GetChannelGroups(std::vector<PVR_CHANNEL_GROUP> &kodiChannelGroups, bool radio) const
{
Logger::Log(LEVEL_DEBUG, "%s - Starting to get ChannelGroups for PVR", __FUNCTION__);

for (const auto& channelGroup : m_channelGroups)
{
Logger::Log(LEVEL_DEBUG, "%s - Transfer channelGroup '%s', ChannelGroupIndex '%d'", __FUNCTION__, channelGroup->GetGroupName().c_str(), channelGroup->GetUniqueId());
Expand All @@ -32,14 +34,26 @@ void ChannelGroups::GetChannelGroups(std::vector<PVR_CHANNEL_GROUP> &kodiChannel
kodiChannelGroups.emplace_back(kodiChannelGroup);
}
}

Logger::Log(LEVEL_DEBUG, "%s - Finished getting ChannelGroups for PVR", __FUNCTION__);
}

PVR_ERROR ChannelGroups::GetChannelGroupMembers(std::vector<PVR_CHANNEL_GROUP_MEMBER> &channelGroupMembers, const std::string &groupName)
{
std::shared_ptr<ChannelGroup> channelGroup = GetChannelGroup(groupName);

if (!channelGroup)
{
Logger::Log(LEVEL_DEBUG, "%s - Channel Group not found, could not get ChannelGroupsMembers for PVR for group: %s", __FUNCTION__, groupName.c_str());

return PVR_ERROR_NO_ERROR;
}
else
{
Logger::Log(LEVEL_DEBUG, "%s - Starting to get ChannelGroupsMembers for PVR for group: %s", __FUNCTION__, groupName.c_str());
}

int channelNumberInGroup = 1;

for (const auto& channel : channelGroup->GetChannelList())
{
Expand All @@ -48,14 +62,18 @@ PVR_ERROR ChannelGroups::GetChannelGroupMembers(std::vector<PVR_CHANNEL_GROUP_ME

strncpy(tag.strGroupName, groupName.c_str(), sizeof(tag.strGroupName));
tag.iChannelUniqueId = channel->GetUniqueId();
tag.iChannelNumber = channel->GetChannelNumber();
tag.iChannelNumber = channelNumberInGroup; //Keep the channels in list order as per the groups on the STB

Logger::Log(LEVEL_DEBUG, "%s - add channel %s (%d) to group '%s' channel number %d",
__FUNCTION__, channel->GetChannelName().c_str(), tag.iChannelUniqueId, groupName.c_str(), channel->GetChannelNumber());

channelGroupMembers.emplace_back(tag);

channelNumberInGroup++;
}

Logger::Log(LEVEL_DEBUG, "%s - Finished getting ChannelGroupsMembers for PVR for group: %s", __FUNCTION__, groupName.c_str());

return PVR_ERROR_NO_ERROR;
}

Expand Down Expand Up @@ -151,6 +169,8 @@ bool ChannelGroups::LoadChannelGroups()

bool ChannelGroups::LoadTVChannelGroups()
{
int tempNumChannelGroups = m_channelGroups.size();

if ((Settings::GetInstance().GetTVFavouritesMode() == FavouritesGroupMode::AS_FIRST_GROUP &&
Settings::GetInstance().GetTVChannelGroupMode() != ChannelGroupMode::FAVOURITES_GROUP) ||
Settings::GetInstance().GetTVChannelGroupMode() == ChannelGroupMode::FAVOURITES_GROUP)
Expand Down Expand Up @@ -212,12 +232,14 @@ bool ChannelGroups::LoadTVChannelGroups()
AddTVFavouritesChannelGroup();
}

Logger::Log(LEVEL_INFO, "%s Loaded %d TV Channelgroups", __FUNCTION__, m_channelGroups.size());
Logger::Log(LEVEL_INFO, "%s Loaded %d TV Channelgroups", __FUNCTION__, m_channelGroups.size() - tempNumChannelGroups);
return true;
}

bool ChannelGroups::LoadRadioChannelGroups()
{
int tempNumChannelGroups = m_channelGroups.size();

if ((Settings::GetInstance().GetRadioFavouritesMode() == FavouritesGroupMode::AS_FIRST_GROUP &&
Settings::GetInstance().GetRadioChannelGroupMode() != ChannelGroupMode::FAVOURITES_GROUP) ||
Settings::GetInstance().GetRadioChannelGroupMode() == ChannelGroupMode::FAVOURITES_GROUP)
Expand Down Expand Up @@ -279,7 +301,7 @@ bool ChannelGroups::LoadRadioChannelGroups()
AddRadioFavouritesChannelGroup();
}

Logger::Log(LEVEL_INFO, "%s Loaded %d Radio Channelgroups", __FUNCTION__, m_channelGroups.size());
Logger::Log(LEVEL_INFO, "%s Loaded %d Radio Channelgroups", __FUNCTION__, m_channelGroups.size() - tempNumChannelGroups);
return true;
}

Expand Down
3 changes: 1 addition & 2 deletions src/enigma2/Channels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,7 @@ bool Channels::LoadChannels(const std::string groupServiceReference, const std::
{
Logger::Log(LEVEL_INFO, "%s loading channel group: '%s'", __FUNCTION__, groupName.c_str());

std::string strTmp;
strTmp = StringUtils::Format("%sweb/getservices?sRef=%s", Settings::GetInstance().GetConnectionURL().c_str(), WebUtils::URLEncodeInline(groupServiceReference).c_str());
std::string strTmp = StringUtils::Format("%sweb/getservices?sRef=%s", Settings::GetInstance().GetConnectionURL().c_str(), WebUtils::URLEncodeInline(groupServiceReference).c_str());

std::string strXML = WebUtils::GetHttpXML(strTmp);

Expand Down
6 changes: 2 additions & 4 deletions src/enigma2/Recordings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ bool Recordings::LoadLocations()

for (; pNode != nullptr; pNode = pNode->NextSiblingElement("e2location"))
{
std::string strTmp;
strTmp = pNode->GetText();
std::string strTmp = pNode->GetText();

m_locations.emplace_back(strTmp);

Expand Down Expand Up @@ -176,8 +175,7 @@ bool Recordings::GetRecordingsFromLocation(std::string recordingLocation)
directory = recordingLocation;
}

std::string strXML;
strXML = WebUtils::GetHttpXML(url);
std::string strXML = WebUtils::GetHttpXML(url);

TiXmlDocument xmlDoc;
if (!xmlDoc.Parse(strXML.c_str()))
Expand Down
11 changes: 4 additions & 7 deletions src/enigma2/Timers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ PVR_ERROR Timers::AddTimer(const PVR_TIMER &timer)
startTime = timer.startTime - (timer.iMarginStart * 60);
endTime = timer.endTime + (timer.iMarginEnd * 60);

if (!m_settings.GetRecordingPath().compare(""))
if (!m_settings.GetRecordingPath().empty())
strTmp = StringUtils::Format("web/timeradd?sRef=%s&repeated=%d&begin=%d&end=%d&name=%s&description=%s&eit=%d&tags=%s&dirname=&s",
WebUtils::URLEncodeInline(strServiceReference).c_str(), timer.iWeekdays, startTime, endTime,
WebUtils::URLEncodeInline(timer.strTitle).c_str(), WebUtils::URLEncodeInline(timer.strSummary).c_str(), timer.iEpgUid,
Expand Down Expand Up @@ -568,7 +568,6 @@ PVR_ERROR Timers::UpdateTimer(const PVR_TIMER &timer)

Logger::Log(LEVEL_DEBUG, "%s timer channelid '%d'", __FUNCTION__, timer.iClientChannelUid);

std::string strTmp;
std::string strServiceReference = m_channels.GetChannel(timer.iClientChannelUid)->GetServiceReference().c_str();

const auto it = std::find_if(m_timers.cbegin(), m_timers.cend(), [timer](const Timer& myTimer)
Expand All @@ -586,7 +585,7 @@ PVR_ERROR Timers::UpdateTimer(const PVR_TIMER &timer)
if (timer.state == PVR_TIMER_STATE_CANCELLED)
iDisabled = 1;

strTmp = StringUtils::Format("web/timerchange?sRef=%s&begin=%d&end=%d&name=%s&eventID=&description=%s&tags=%s&afterevent=3&eit=0&disabled=%d&justplay=0&repeated=%d&channelOld=%s&beginOld=%d&endOld=%d&deleteOldOnSave=1",
std::string strTmp = StringUtils::Format("web/timerchange?sRef=%s&begin=%d&end=%d&name=%s&eventID=&description=%s&tags=%s&afterevent=3&eit=0&disabled=%d&justplay=0&repeated=%d&channelOld=%s&beginOld=%d&endOld=%d&deleteOldOnSave=1",
WebUtils::URLEncodeInline(strServiceReference).c_str(), timer.startTime, timer.endTime,
WebUtils::URLEncodeInline(timer.strTitle).c_str(), WebUtils::URLEncodeInline(timer.strSummary).c_str(),
WebUtils::URLEncodeInline(oldTimer.GetTags()).c_str(), iDisabled, timer.iWeekdays,
Expand Down Expand Up @@ -734,14 +733,13 @@ PVR_ERROR Timers::DeleteTimer(const PVR_TIMER &timer)
if (IsAutoTimer(timer))
return DeleteAutoTimer(timer);

std::string strTmp;
std::string strServiceReference = m_channels.GetChannel(timer.iClientChannelUid)->GetServiceReference().c_str();

time_t startTime, endTime;
startTime = timer.startTime - (timer.iMarginStart * 60);
endTime = timer.endTime + (timer.iMarginEnd * 60);

strTmp = StringUtils::Format("web/timerdelete?sRef=%s&begin=%d&end=%d", WebUtils::URLEncodeInline(strServiceReference).c_str(), startTime, endTime);
std::string strTmp = StringUtils::Format("web/timerdelete?sRef=%s&begin=%d&end=%d", WebUtils::URLEncodeInline(strServiceReference).c_str(), startTime, endTime);

std::string strResult;
if (!WebUtils::SendSimpleCommand(strTmp, strResult))
Expand All @@ -766,8 +764,7 @@ PVR_ERROR Timers::DeleteAutoTimer(const PVR_TIMER &timer)
{
AutoTimer timerToDelete = *it;

std::string strTmp;
strTmp = StringUtils::Format("autotimer/remove?id=%u", timerToDelete.GetBackendId());
std::string strTmp = StringUtils::Format("autotimer/remove?id=%u", timerToDelete.GetBackendId());

std::string strResult;
if (!WebUtils::SendSimpleCommand(strTmp, strResult))
Expand Down
4 changes: 2 additions & 2 deletions src/enigma2/data/ChannelGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ bool ChannelGroup::UpdateFrom(TiXmlElement* groupNode, bool radio)
if (!radio && Settings::GetInstance().GetTVChannelGroupMode() == ChannelGroupMode::ONLY_ONE_GROUP &&
Settings::GetInstance().GetOneTVGroupName() != groupName)
{
Logger::Log(LEVEL_DEBUG, "%s Only one TV group is set, but current e2servicename '%s' does not match requested name '%s'", __FUNCTION__, serviceReference.c_str(), Settings::GetInstance().GetOneTVGroupName().c_str());
Logger::Log(LEVEL_DEBUG, "%s Only one TV group is set, but current e2servicename '%s' does not match requested name '%s'", __FUNCTION__, groupName.c_str(), Settings::GetInstance().GetOneTVGroupName().c_str());
return false;
}
else if (radio && Settings::GetInstance().GetRadioChannelGroupMode() == ChannelGroupMode::ONLY_ONE_GROUP &&
Settings::GetInstance().GetOneRadioGroupName() != groupName)
{
Logger::Log(LEVEL_DEBUG, "%s Only one Radio group is set, but current e2servicename '%s' does not match requested name '%s'", __FUNCTION__, serviceReference.c_str(), Settings::GetInstance().GetOneRadioGroupName().c_str());
Logger::Log(LEVEL_DEBUG, "%s Only one Radio group is set, but current e2servicename '%s' does not match requested name '%s'", __FUNCTION__, groupName.c_str(), Settings::GetInstance().GetOneRadioGroupName().c_str());
return false;
}

Expand Down
10 changes: 7 additions & 3 deletions src/enigma2/extract/EpgEntryExtractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ EpgEntryExtractor::EpgEntryExtractor()
: IExtractor()
{
FileUtils::CopyDirectory(FileUtils::GetResourceDataPath() + GENRE_DIR, GENRE_ADDON_DATA_BASE_DIR, true);
FileUtils::CopyDirectory(FileUtils::GetResourceDataPath() + SHOW_INFO_DIR, SHOW_INFO_ADDON_DATA_BASE_DIR, true);

m_extractors.emplace_back(new GenreIdMapper());
m_extractors.emplace_back(new GenreRytecTextMapper());
m_extractors.emplace_back(new ShowInfoExtractor());
if (Settings::GetInstance().GetMapGenreIds())
m_extractors.emplace_back(new GenreIdMapper());
if (Settings::GetInstance().GetMapRytecTextGenres())
m_extractors.emplace_back(new GenreRytecTextMapper());
if (Settings::GetInstance().GetExtractShowInfo())
m_extractors.emplace_back(new ShowInfoExtractor());

m_anyExtractorEnabled = false;
for (auto& extractor : m_extractors)
Expand Down
5 changes: 4 additions & 1 deletion src/enigma2/extract/EpgEntryExtractor.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ namespace enigma2
namespace extract
{
static const std::string GENRE_DIR = "/genres";
static const std::string GENRE_ADDON_DATA_BASE_DIR = "special://userdata/addon_data/pvr.vuplus" + GENRE_DIR;
static const std::string ADDON_DATA_BASE_DIR = "special://userdata/addon_data/pvr.vuplus";
static const std::string GENRE_ADDON_DATA_BASE_DIR = ADDON_DATA_BASE_DIR + GENRE_DIR;
static const std::string SHOW_INFO_DIR = "/showInfo";
static const std::string SHOW_INFO_ADDON_DATA_BASE_DIR = ADDON_DATA_BASE_DIR + SHOW_INFO_DIR;

class EpgEntryExtractor
: public IExtractor
Expand Down
2 changes: 0 additions & 2 deletions src/enigma2/extract/ShowInfoExtractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ using namespace enigma2::utilities;
ShowInfoExtractor::ShowInfoExtractor()
: IExtractor()
{
FileUtils::CopyDirectory(FileUtils::GetResourceDataPath() + SHOW_INFO_DIR, SHOW_INFO_ADDON_DATA_BASE_DIR, true);

if (!LoadShowInfoPatternsFile(Settings::GetInstance().GetExtractShowInfoFile(), m_episodeSeasonPatterns, m_yearPatterns))
Logger::Log(LEVEL_ERROR, "%s Could not load show info patterns file: %s", __FUNCTION__, Settings::GetInstance().GetExtractShowInfoFile().c_str());
}
Expand Down
3 changes: 0 additions & 3 deletions src/enigma2/extract/ShowInfoExtractor.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@

namespace enigma2
{
static const std::string SHOW_INFO_DIR = "/showInfo";
static const std::string SHOW_INFO_ADDON_DATA_BASE_DIR = "special://userdata/addon_data/pvr.vuplus" + SHOW_INFO_DIR;

namespace extract
{
// (S4E37) (S04E37) (S2 Ep3/6) (S2 Ep7)
Expand Down

0 comments on commit 5741f24

Please sign in to comment.