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

Channel Improvements #241

Merged
merged 2 commits into from
Aug 24, 2023
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 pvr.nextpvr/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.nextpvr"
version="20.4.2"
version="20.4.3"
name="NextPVR PVR Client"
provider-name="Graeme Blackley">
<requires>@ADDON_DEPENDS@
Expand Down
4 changes: 4 additions & 0 deletions pvr.nextpvr/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
v20.4.3
- Add missing return ChannelGroup return code
- Stop caching LiveStreams.xml

v20.4.2
- Return error if channel calls are made when not connected
- Fast poll for servers after returning from sleep
Expand Down
8 changes: 5 additions & 3 deletions src/BackendRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ namespace NextPVR
int Request::DoRequest(std::string resource, std::string& response)
{
auto start = std::chrono::steady_clock::now();
char separator = resource.find("?") == std::string::npos ? '?' : '&';
std::unique_lock<std::mutex> lock(m_mutexRequest);
// build request string, adding SID if requred
const std::string URL = kodi::tools::StringUtils::Format("%s%s&sid=%s", m_settings->m_urlBase, resource.c_str(), GetSID());
// build request string, adding SID
const std::string URL = kodi::tools::StringUtils::Format("%s%s%csid=%s", m_settings->m_urlBase,
resource.c_str(), separator, GetSID());

// ask XBMC to read the URL for us
int resultCode = HTTP_NOTFOUND;
Expand All @@ -38,7 +40,7 @@ namespace NextPVR
}
stream.Close();
resultCode = HTTP_OK;
if ((response.empty() || strstr(response.c_str(), "<rsp stat=\"ok\">") == nullptr) && resource.find("channel.stream.info") == std::string::npos)
if (response.empty())
{
kodi::Log(ADDON_LOG_ERROR, "DoRequest failed, response=%s", response.c_str());
resultCode = HTTP_BADREQUEST;
Expand Down
12 changes: 8 additions & 4 deletions src/Channels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ PVR_ERROR Channels::GetChannelGroupMembers(const kodi::addon::PVRChannelGroup& g
results.Add(tag);
}
}
returnValue = PVR_ERROR_NO_ERROR;
}
else
{
Expand Down Expand Up @@ -350,14 +351,13 @@ bool Channels::IsChannelAPlugin(int uid)
/************************************************************/
void Channels::LoadLiveStreams()
{
std::string response;
const std::string URL = "/public/LiveStreams.xml";
m_liveStreams.clear();
if (m_request.FileCopy(URL.c_str(), m_settings->m_instanceDirectory + "LiveStreams.xml") == HTTP_OK)
if (m_request.DoRequest(URL, response) == HTTP_OK)
{
tinyxml2::XMLDocument doc;
std::string liveStreams = kodi::vfs::TranslateSpecialProtocol(m_settings->m_instanceDirectory + "LiveStreams.xml");
kodi::Log(ADDON_LOG_DEBUG, "Loading LiveStreams.xml %s", liveStreams.c_str());
if (doc.LoadFile(liveStreams.c_str()) == tinyxml2::XML_SUCCESS)
if (doc.Parse(response.c_str()) == tinyxml2::XML_SUCCESS)
{
tinyxml2::XMLNode* streamsNode = doc.FirstChildElement("streams");
if (streamsNode)
Expand All @@ -382,5 +382,9 @@ void Channels::LoadLiveStreams()
}
}
}
else
{
kodi::Log(ADDON_LOG_ERROR, "LiveStreams invalid xml");
}
}
}
Loading