Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Handle API backend error #332

Open
wants to merge 1 commit into
base: Omega
Choose a base branch
from
Open
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
21 changes: 18 additions & 3 deletions src/WaipuData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ std::string WaipuData::HttpRequestToCurl(Curl& curl,
{
content = curl.Get(url, statusCode);
}
if (statusCode >= 200 && statusCode < 300)
if ((statusCode >= 200 && statusCode < 300) or statusCode == 403)
return content;

kodi::Log(ADDON_LOG_ERROR, "[Http-GET-Request] error. status: %i, body: %s", statusCode,
Expand Down Expand Up @@ -1019,6 +1019,21 @@ std::string WaipuData::GetChannelStreamURL(int uniqueId,
return "";
}

if (streamURLDoc.HasMember("status") && streamURLDoc["status"].GetInt() == 403)
{
if (streamURLDoc.HasMember("type"))
{
std::string error_type = streamURLDoc["type"].GetString();
kodi::Log(ADDON_LOG_ERROR, "[GetStreamURL] ERROR 403: %s", error_type.c_str());
if (error_type == "stream-url-provider/channel-forbidden")
{
m_channels.clear();
kodi::addon::CInstancePVRClient::TriggerChannelUpdate();
}
return "";
}
}

if (!streamURLDoc.HasMember("streamUrl"))
{
kodi::Log(ADDON_LOG_ERROR, "[GetStreamURL] ERROR: missing param streamUrl");
Expand Down Expand Up @@ -1073,8 +1088,8 @@ PVR_ERROR WaipuData::GetChannelGroupMembers(const kodi::addon::PVRChannelGroup&
{
if (group.GetIsRadio())
{
kodi::Log(ADDON_LOG_ERROR,
"[%s] ERROR: Function was called with a group having 'radio: true'", __FUNCTION__);
kodi::Log(ADDON_LOG_ERROR, "[%s] ERROR: Function was called with a group having 'radio: true'",
__FUNCTION__);
return PVR_ERROR_INVALID_PARAMETERS;
}

Expand Down