mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-28 07:51:11 +02:00
imdb/tmdb: code formatations using astyle
Origin commit data
------------------
Branch: ni/coolstream
Commit: 13224efbf1
Author: vanhofen <vanhofen@gmx.de>
Date: 2021-04-10 (Sat, 10 Apr 2021)
Origin message was:
------------------
- imdb/tmdb: code formatations using astyle
------------------
No further description and justification available within origin commit message!
------------------
This commit was generated by Migit
This commit is contained in:
@@ -71,13 +71,16 @@ std::string CIMDB::utf82url(std::string s)
|
|||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
for (size_t i = 0; i < s.length(); ++i)
|
for (size_t i = 0; i < s.length(); ++i)
|
||||||
{
|
{
|
||||||
if (unsigned(s[i]) <= ' ') {
|
if (unsigned(s[i]) <= ' ')
|
||||||
|
{
|
||||||
ss << '+';
|
ss << '+';
|
||||||
}
|
}
|
||||||
else if (unsigned(s[i]) <= '\x27') {
|
else if (unsigned(s[i]) <= '\x27')
|
||||||
|
{
|
||||||
ss << "%" << std::hex << unsigned(s[i]);
|
ss << "%" << std::hex << unsigned(s[i]);
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
ss << s[i];
|
ss << s[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -330,7 +333,8 @@ int CIMDB::getMovieDetails(const std::string& epgTitle)
|
|||||||
std::string origURL("300");
|
std::string origURL("300");
|
||||||
std::string replURL("600");
|
std::string replURL("600");
|
||||||
|
|
||||||
if (m["Poster"].compare(m["Poster"].size()-7,3,origURL) == 0){
|
if (m["Poster"].compare(m["Poster"].size() - 7, 3, origURL) == 0)
|
||||||
|
{
|
||||||
//std::cout << "########## " << m["Poster"] << " contains " << origURL << '\n';
|
//std::cout << "########## " << m["Poster"] << " contains " << origURL << '\n';
|
||||||
m["Poster"].replace(m["Poster"].size() - 7, 3, replURL);
|
m["Poster"].replace(m["Poster"].size() - 7, 3, replURL);
|
||||||
//std::cout << "########## New string: " << m["Poster"] << '\n';
|
//std::cout << "########## New string: " << m["Poster"] << '\n';
|
||||||
@@ -338,7 +342,8 @@ int CIMDB::getMovieDetails(const std::string& epgTitle)
|
|||||||
|
|
||||||
if (httpTool.downloadFile(m["Poster"], posterfile.c_str()))
|
if (httpTool.downloadFile(m["Poster"], posterfile.c_str()))
|
||||||
return 2;
|
return 2;
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
if (access(posterfile.c_str(), F_OK) == 0)
|
if (access(posterfile.c_str(), F_OK) == 0)
|
||||||
unlink(posterfile.c_str());
|
unlink(posterfile.c_str());
|
||||||
return 1;
|
return 1;
|
||||||
@@ -456,7 +461,8 @@ std::string CIMDB::getFilename(CZapitChannel * channel, uint64_t id)
|
|||||||
StringReplace(FilenameTemplate, "__", "_");
|
StringReplace(FilenameTemplate, "__", "_");
|
||||||
|
|
||||||
std::string channel_name = channel->getName();
|
std::string channel_name = channel->getName();
|
||||||
if (!(channel_name.empty())) {
|
if (!(channel_name.empty()))
|
||||||
|
{
|
||||||
strcpy(buf, UTF8_TO_FILESYSTEM_ENCODING(channel_name.c_str()));
|
strcpy(buf, UTF8_TO_FILESYSTEM_ENCODING(channel_name.c_str()));
|
||||||
ZapitTools::replace_char(buf);
|
ZapitTools::replace_char(buf);
|
||||||
StringReplace(FilenameTemplate, "%C", buf);
|
StringReplace(FilenameTemplate, "%C", buf);
|
||||||
@@ -465,8 +471,10 @@ std::string CIMDB::getFilename(CZapitChannel * channel, uint64_t id)
|
|||||||
StringReplace(FilenameTemplate, "%C", "no_channel");
|
StringReplace(FilenameTemplate, "%C", "no_channel");
|
||||||
|
|
||||||
CShortEPGData epgdata;
|
CShortEPGData epgdata;
|
||||||
if(CEitManager::getInstance()->getEPGidShort(id, &epgdata)) {
|
if (CEitManager::getInstance()->getEPGidShort(id, &epgdata))
|
||||||
if (!(epgdata.title.empty())) {
|
{
|
||||||
|
if (!(epgdata.title.empty()))
|
||||||
|
{
|
||||||
strcpy(buf, epgdata.title.c_str());
|
strcpy(buf, epgdata.title.c_str());
|
||||||
ZapitTools::replace_char(buf);
|
ZapitTools::replace_char(buf);
|
||||||
StringReplace(FilenameTemplate, "%T", buf);
|
StringReplace(FilenameTemplate, "%T", buf);
|
||||||
@@ -474,7 +482,8 @@ std::string CIMDB::getFilename(CZapitChannel * channel, uint64_t id)
|
|||||||
else
|
else
|
||||||
StringReplace(FilenameTemplate, "%T", "no_title");
|
StringReplace(FilenameTemplate, "%T", "no_title");
|
||||||
|
|
||||||
if (!(epgdata.info1.empty())) {
|
if (!(epgdata.info1.empty()))
|
||||||
|
{
|
||||||
strcpy(buf, epgdata.info1.c_str());
|
strcpy(buf, epgdata.info1.c_str());
|
||||||
ZapitTools::replace_char(buf);
|
ZapitTools::replace_char(buf);
|
||||||
StringReplace(FilenameTemplate, "%I", buf);
|
StringReplace(FilenameTemplate, "%I", buf);
|
||||||
@@ -496,7 +505,8 @@ void CIMDB::StringReplace(std::string &str, const std::string search, const std:
|
|||||||
{
|
{
|
||||||
std::string::size_type ptr = 0;
|
std::string::size_type ptr = 0;
|
||||||
std::string::size_type pos = 0;
|
std::string::size_type pos = 0;
|
||||||
while((ptr = str.find(search,pos)) != std::string::npos){
|
while ((ptr = str.find(search, pos)) != std::string::npos)
|
||||||
|
{
|
||||||
str.replace(ptr, search.length(), rstr);
|
str.replace(ptr, search.length(), rstr);
|
||||||
pos = ptr + rstr.length();
|
pos = ptr + rstr.length();
|
||||||
}
|
}
|
||||||
|
@@ -74,7 +74,8 @@ void CTMDB::setTitle(std::string epgtitle)
|
|||||||
if ((minfo.result < 1 || minfo.overview.empty()) && lang != "en")
|
if ((minfo.result < 1 || minfo.overview.empty()) && lang != "en")
|
||||||
getMovieDetails("en", true);
|
getMovieDetails("en", true);
|
||||||
|
|
||||||
if(hintbox){
|
if (hintbox)
|
||||||
|
{
|
||||||
hintbox->hide();
|
hintbox->hide();
|
||||||
delete hintbox;
|
delete hintbox;
|
||||||
hintbox = NULL;
|
hintbox = NULL;
|
||||||
@@ -89,7 +90,8 @@ bool CTMDB::getData(std::string url, Json::Value *root)
|
|||||||
|
|
||||||
std::string errMsg = "";
|
std::string errMsg = "";
|
||||||
bool ok = parseJsonFromString(answer, root, &errMsg);
|
bool ok = parseJsonFromString(answer, root, &errMsg);
|
||||||
if (!ok) {
|
if (!ok)
|
||||||
|
{
|
||||||
printf("Failed to parse JSON\n");
|
printf("Failed to parse JSON\n");
|
||||||
printf("%s\n", errMsg.c_str());
|
printf("%s\n", errMsg.c_str());
|
||||||
return false;
|
return false;
|
||||||
@@ -107,11 +109,13 @@ bool CTMDB::getMovieDetails(std::string lang, bool second)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
minfo.result = root.get("total_results", 0).asInt();
|
minfo.result = root.get("total_results", 0).asInt();
|
||||||
if(minfo.result == 0){
|
if (minfo.result == 0)
|
||||||
|
{
|
||||||
std::string title = minfo.epgtitle;
|
std::string title = minfo.epgtitle;
|
||||||
size_t pos1 = title.find_last_of("(");
|
size_t pos1 = title.find_last_of("(");
|
||||||
size_t pos2 = title.find_last_of(")");
|
size_t pos2 = title.find_last_of(")");
|
||||||
if(pos1 != std::string::npos && pos2 != std::string::npos && pos2 > pos1){
|
if (pos1 != std::string::npos && pos2 != std::string::npos && pos2 > pos1)
|
||||||
|
{
|
||||||
printf("[TMDB]: second try\n");
|
printf("[TMDB]: second try\n");
|
||||||
title.replace(pos1, pos2 - pos1 + 1, "");
|
title.replace(pos1, pos2 - pos1 + 1, "");
|
||||||
url = urlapi + "search/multi?api_key=" + key + "&language=" + lang + "&query=" + encodeUrl(title);
|
url = urlapi + "search/multi?api_key=" + key + "&language=" + lang + "&query=" + encodeUrl(title);
|
||||||
@@ -123,18 +127,21 @@ bool CTMDB::getMovieDetails(std::string lang, bool second)
|
|||||||
}
|
}
|
||||||
printf("[TMDB]: results: %d\n", minfo.result);
|
printf("[TMDB]: results: %d\n", minfo.result);
|
||||||
|
|
||||||
if (minfo.result > 0) {
|
if (minfo.result > 0)
|
||||||
|
{
|
||||||
Json::Value elements = root["results"];
|
Json::Value elements = root["results"];
|
||||||
int use_result = 0;
|
int use_result = 0;
|
||||||
|
|
||||||
if ((minfo.result > 1) && (!second))
|
if ((minfo.result > 1) && (!second))
|
||||||
selectResult(elements, minfo.result, use_result);
|
selectResult(elements, minfo.result, use_result);
|
||||||
|
|
||||||
if (!second) {
|
if (!second)
|
||||||
|
{
|
||||||
minfo.id = elements[use_result].get("id", -1).asInt();
|
minfo.id = elements[use_result].get("id", -1).asInt();
|
||||||
minfo.media_type = elements[use_result].get("media_type", "").asString();
|
minfo.media_type = elements[use_result].get("media_type", "").asString();
|
||||||
}
|
}
|
||||||
if (minfo.id > -1) {
|
if (minfo.id > -1)
|
||||||
|
{
|
||||||
url = urlapi + minfo.media_type + "/" + to_string(minfo.id) + "?api_key=" + key + "&language=" + lang + "&append_to_response=credits";
|
url = urlapi + minfo.media_type + "/" + to_string(minfo.id) + "?api_key=" + key + "&language=" + lang + "&append_to_response=credits";
|
||||||
if (!(getData(url, &root)))
|
if (!(getData(url, &root)))
|
||||||
return false;
|
return false;
|
||||||
@@ -146,27 +153,31 @@ bool CTMDB::getMovieDetails(std::string lang, bool second)
|
|||||||
minfo.vote_average = root.get("vote_average", "").asString();;
|
minfo.vote_average = root.get("vote_average", "").asString();;
|
||||||
minfo.vote_count = root.get("vote_count", 0).asInt();;
|
minfo.vote_count = root.get("vote_count", 0).asInt();;
|
||||||
minfo.runtime = root.get("runtime", 0).asInt();;
|
minfo.runtime = root.get("runtime", 0).asInt();;
|
||||||
if (minfo.media_type == "tv") {
|
if (minfo.media_type == "tv")
|
||||||
|
{
|
||||||
minfo.original_title = root.get("original_name", "").asString();;
|
minfo.original_title = root.get("original_name", "").asString();;
|
||||||
minfo.episodes = root.get("number_of_episodes", 0).asInt();;
|
minfo.episodes = root.get("number_of_episodes", 0).asInt();;
|
||||||
minfo.seasons = root.get("number_of_seasons", 0).asInt();;
|
minfo.seasons = root.get("number_of_seasons", 0).asInt();;
|
||||||
minfo.release_date = root.get("first_air_date", "").asString();;
|
minfo.release_date = root.get("first_air_date", "").asString();;
|
||||||
elements = root["episode_run_time"];
|
elements = root["episode_run_time"];
|
||||||
minfo.runtimes = elements[0].asString();
|
minfo.runtimes = elements[0].asString();
|
||||||
for (unsigned int i= 1; i<elements.size();i++) {
|
for (unsigned int i = 1; i < elements.size(); i++)
|
||||||
|
{
|
||||||
minfo.runtimes += + ", " + elements[i].asString();
|
minfo.runtimes += + ", " + elements[i].asString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
elements = root["genres"];
|
elements = root["genres"];
|
||||||
minfo.genres = elements[0].get("name", "").asString();
|
minfo.genres = elements[0].get("name", "").asString();
|
||||||
for (unsigned int i= 1; i<elements.size();i++) {
|
for (unsigned int i = 1; i < elements.size(); i++)
|
||||||
|
{
|
||||||
minfo.genres += ", " + elements[i].get("name", "").asString();
|
minfo.genres += ", " + elements[i].get("name", "").asString();
|
||||||
}
|
}
|
||||||
|
|
||||||
elements = root["credits"]["cast"];
|
elements = root["credits"]["cast"];
|
||||||
minfo.cast.clear();
|
minfo.cast.clear();
|
||||||
for (unsigned int i= 0; i<elements.size() && i<10;i++) {
|
for (unsigned int i = 0; i < elements.size() && i < 10; i++)
|
||||||
|
{
|
||||||
minfo.cast += " " + elements[i].get("character", "").asString() + " (" + elements[i].get("name", "").asString() + ")\n";
|
minfo.cast += " " + elements[i].get("character", "").asString() + " (" + elements[i].get("name", "").asString() + ")\n";
|
||||||
//printf("test: %s (%s)\n",elements[i].get("character","").asString().c_str(),elements[i].get("name","").asString().c_str());
|
//printf("test: %s (%s)\n",elements[i].get("character","").asString().c_str(),elements[i].get("name","").asString().c_str());
|
||||||
}
|
}
|
||||||
@@ -178,7 +189,8 @@ bool CTMDB::getMovieDetails(std::string lang, bool second)
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -233,7 +245,8 @@ void CTMDB::cleanup()
|
|||||||
|
|
||||||
void CTMDB::selectResult(Json::Value elements, int results, int &use_result)
|
void CTMDB::selectResult(Json::Value elements, int results, int &use_result)
|
||||||
{
|
{
|
||||||
if(hintbox){
|
if (hintbox)
|
||||||
|
{
|
||||||
hintbox->hide();
|
hintbox->hide();
|
||||||
delete hintbox;
|
delete hintbox;
|
||||||
hintbox = NULL;
|
hintbox = NULL;
|
||||||
|
@@ -27,7 +27,8 @@
|
|||||||
#include <system/helpers-json.h>
|
#include <system/helpers-json.h>
|
||||||
#include <gui/widget/hintbox.h>
|
#include <gui/widget/hintbox.h>
|
||||||
|
|
||||||
typedef struct {
|
typedef struct
|
||||||
|
{
|
||||||
std::string epgtitle;
|
std::string epgtitle;
|
||||||
std::string poster_path;
|
std::string poster_path;
|
||||||
std::string overview;
|
std::string overview;
|
||||||
|
Reference in New Issue
Block a user