From c194adf9d50cfd369a25803c06948780dc12862c Mon Sep 17 00:00:00 2001 From: flubshi Date: Mon, 24 Jun 2024 18:32:00 +0200 Subject: [PATCH] Add setting option to retrieve additional options from waipu backend --- .../resource.language.en_gb/strings.po | 4 + pvr.waipu/resources/settings.xml | 5 ++ src/WaipuData.cpp | 86 +++++++++---------- 3 files changed, 52 insertions(+), 43 deletions(-) diff --git a/pvr.waipu/resources/language/resource.language.en_gb/strings.po b/pvr.waipu/resources/language/resource.language.en_gb/strings.po index 176b072..094220f 100644 --- a/pvr.waipu/resources/language/resource.language.en_gb/strings.po +++ b/pvr.waipu/resources/language/resource.language.en_gb/strings.po @@ -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 "" diff --git a/pvr.waipu/resources/settings.xml b/pvr.waipu/resources/settings.xml index 1dc718b..f3e1b49 100644 --- a/pvr.waipu/resources/settings.xml +++ b/pvr.waipu/resources/settings.xml @@ -175,6 +175,11 @@ 3 false + + + 3 + false + 3 diff --git a/src/WaipuData.cpp b/src/WaipuData.cpp index 1c9dfea..760a011 100644 --- a/src/WaipuData.cpp +++ b/src/WaipuData.cpp @@ -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(); @@ -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; } @@ -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; }