Skip to content

Commit

Permalink
Add setting option to retrieve additional options from waipu backend
Browse files Browse the repository at this point in the history
  • Loading branch information
flubshi committed Jun 24, 2024
1 parent ac6725d commit c194adf
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@ msgctxt "#30054"
msgid "By default, inputstream.adaptive is used for playing HLS. Check this option to use inputstream.ffmpegdirect instead."
msgstr ""

msgctxt "#30055"
msgid "Recordings: Load description and year"
msgstr ""

msgctxt "#30500"
msgid "Inputstream error"
msgstr ""
Expand Down
5 changes: 5 additions & 0 deletions pvr.waipu/resources/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,11 @@
<level>3</level>
<default>false</default>
<control type="toggle"/>
</setting>
<setting id="recordings_additional_infos" type="boolean" label="30055" help="">
<level>3</level>
<default>false</default>
<control type="toggle"/>
</setting>
<setting id="epg_show_preview_images" type="boolean" label="30042" help="">
<level>3</level>
Expand Down
86 changes: 43 additions & 43 deletions src/WaipuData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,19 +609,16 @@ ADDON_STATUS WaipuData::SetSetting(const std::string& settingName,
return ADDON_STATUS_NEED_RESTART;
}
}

else if (settingName == "protocol")
{
m_protocol = settingValue.GetString();
return ADDON_STATUS_OK;
}

else if (settingName == "epg_show_preview_images")
{
m_epg_show_preview_images = settingValue.GetBoolean();
return ADDON_STATUS_OK;
}

else if (settingName == "provider_select")
{
WAIPU_PROVIDER tmpProvider = settingValue.GetEnum<WAIPU_PROVIDER>();
Expand Down Expand Up @@ -657,6 +654,10 @@ ADDON_STATUS WaipuData::SetSetting(const std::string& settingName,
kodi::addon::SetSettingString("refresh_token", "");
return ADDON_STATUS_NEED_RESTART;
}
else if (settingName == "recordings_additional_infos")
{
kodi::addon::CInstancePVRClient::TriggerRecordingUpdate();
}

return ADDON_STATUS_OK;
}
Expand Down Expand Up @@ -1625,46 +1626,45 @@ kodi::addon::PVRRecording WaipuData::ParseRecordingEntry(const rapidjson::Value&
}

// Additional program details like year or plot are on available in an additional details request. Maybe we should provide this as settings option?
// const bool fetchAdditionalInfos = false;
// if (fetchAdditionalInfos)
// {
//
// std::string json = HttpGet("https://recording.waipu.tv/api/recordings/" + recordingId,
// {{"Accept", "application/vnd.waipu.recording-v4+json"}});
// kodi::Log(ADDON_LOG_DEBUG, "[recordings] %s", json.c_str());
//
// rapidjson::Document doc;
// doc.Parse(json.c_str());
// if (!doc.HasParseError())
// {
// if (doc.HasMember("programDetails"))
// {
// if (doc["programDetails"].HasMember("textContent"))
// {
// if (doc["programDetails"]["textContent"].HasMember("descLong"))
// {
// std::string descr = doc["programDetails"]["textContent"]["descLong"].GetString();
// tag.SetPlot(descr);
// tag.SetPlotOutline(descr);
// }
// else if (doc["programDetails"]["textContent"].HasMember("descShort"))
// {
// std::string descr = doc["programDetails"]["textContent"]["descShort"].GetString();
// tag.SetPlot(descr);
// tag.SetPlotOutline(descr);
// }
// }
// if (doc["programDetails"].HasMember("production"))
// {
// if (doc["programDetails"]["production"].HasMember("year"))
// {
// std::string year = doc["programDetails"]["production"]["year"].GetString();
// tag.SetYear(Utils::StringToInt(year, 1970));
// }
// }
// }
// }
// }
if (kodi::addon::GetSettingBoolean("recordings_additional_infos", false))
{

std::string json = HttpGet("https://recording.waipu.tv/api/recordings/" + recordingId,
{{"Accept", "application/vnd.waipu.recording-v4+json"}});
kodi::Log(ADDON_LOG_DEBUG, "[recordings] %s", json.c_str());

rapidjson::Document doc;
doc.Parse(json.c_str());
if (!doc.HasParseError())
{
if (doc.HasMember("programDetails"))
{
if (doc["programDetails"].HasMember("textContent"))
{
if (doc["programDetails"]["textContent"].HasMember("descLong"))
{
std::string descr = doc["programDetails"]["textContent"]["descLong"].GetString();
tag.SetPlot(descr);
tag.SetPlotOutline(descr);
}
else if (doc["programDetails"]["textContent"].HasMember("descShort"))
{
std::string descr = doc["programDetails"]["textContent"]["descShort"].GetString();
tag.SetPlot(descr);
tag.SetPlotOutline(descr);
}
}
if (doc["programDetails"].HasMember("production"))
{
if (doc["programDetails"]["production"].HasMember("year"))
{
std::string year = doc["programDetails"]["production"]["year"].GetString();
tag.SetYear(Utils::StringToInt(year, 1970));
}
}
}
}
}
return tag;
}

Expand Down

0 comments on commit c194adf

Please sign in to comment.