mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-09-03 02:41:21 +02:00
Use parseJsonFromString() for parsing json data in
- CMoviePlayerGui::luaGetUrl() - CTimerList::RemoteBoxChanExists() - CTimerList::RemoteBoxTimerList() - CTimerList::paintItem() - cTmdb::GetMovieDetails() - cYTFeedParser::parseFeedJSON() - cYTFeedParser::parseFeedDetailsJSON()
This commit is contained in:
@@ -38,6 +38,7 @@
|
||||
#include <OpenThreads/ScopedLock>
|
||||
#include "settings.h"
|
||||
#include "helpers.h"
|
||||
#include "helpers-json.h"
|
||||
#include "set_threadname.h"
|
||||
#include <global.h>
|
||||
#include <json/json.h>
|
||||
@@ -288,25 +289,25 @@ std::string cYTFeedParser::getXmlData(xmlNodePtr node)
|
||||
|
||||
bool cYTFeedParser::parseFeedJSON(std::string &answer)
|
||||
{
|
||||
string errMsg = "";
|
||||
Json::Value root;
|
||||
Json::Reader reader;
|
||||
|
||||
std::ostringstream ss;
|
||||
std::ifstream fh(curfeedfile.c_str(),std::ifstream::in);
|
||||
ss << fh.rdbuf();
|
||||
std::string filedata = ss.str();
|
||||
|
||||
bool parsedSuccess = reader.parse(filedata,root,false);
|
||||
bool parsedSuccess = parseJsonFromString(filedata, &root, NULL);
|
||||
|
||||
if(!parsedSuccess)
|
||||
{
|
||||
parsedSuccess = reader.parse(answer,root,false);
|
||||
parsedSuccess = parseJsonFromString(answer, &root, &errMsg);
|
||||
}
|
||||
|
||||
if(!parsedSuccess)
|
||||
{
|
||||
printf("Failed to parse JSON\n");
|
||||
printf("%s\n", reader.getFormattedErrorMessages().c_str());
|
||||
printf("%s\n", errMsg.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -383,15 +384,16 @@ bool cYTFeedParser::parseFeedDetailsJSON(cYTVideoInfo* vinfo)
|
||||
if (!getUrl(url, answer))
|
||||
return false;
|
||||
|
||||
string errMsg = "";
|
||||
Json::Value root;
|
||||
Json::Reader reader;
|
||||
bool parsedSuccess = reader.parse(answer, root, false);
|
||||
bool parsedSuccess = parseJsonFromString(answer, &root, &errMsg);
|
||||
if (!parsedSuccess) {
|
||||
printf("Failed to parse JSON\n");
|
||||
printf("%s\n", reader.getFormattedErrorMessages().c_str());
|
||||
printf("%s\n", errMsg.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Json::Value elements = root["items"];
|
||||
std::string duration = elements[0]["contentDetails"].get("duration", "").asString();
|
||||
if (duration.find("PT") != std::string::npos) {
|
||||
|
Reference in New Issue
Block a user