mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-26 23:13:00 +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;
|
||||
for (size_t i = 0; i < s.length(); ++i)
|
||||
{
|
||||
if (unsigned(s[i]) <= ' ') {
|
||||
if (unsigned(s[i]) <= ' ')
|
||||
{
|
||||
ss << '+';
|
||||
}
|
||||
else if (unsigned(s[i]) <= '\x27') {
|
||||
else if (unsigned(s[i]) <= '\x27')
|
||||
{
|
||||
ss << "%" << std::hex << unsigned(s[i]);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
ss << s[i];
|
||||
}
|
||||
}
|
||||
@@ -330,7 +333,8 @@ int CIMDB::getMovieDetails(const std::string& epgTitle)
|
||||
std::string origURL("300");
|
||||
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';
|
||||
m["Poster"].replace(m["Poster"].size() - 7, 3, replURL);
|
||||
//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()))
|
||||
return 2;
|
||||
else {
|
||||
else
|
||||
{
|
||||
if (access(posterfile.c_str(), F_OK) == 0)
|
||||
unlink(posterfile.c_str());
|
||||
return 1;
|
||||
@@ -456,7 +461,8 @@ std::string CIMDB::getFilename(CZapitChannel * channel, uint64_t id)
|
||||
StringReplace(FilenameTemplate, "__", "_");
|
||||
|
||||
std::string channel_name = channel->getName();
|
||||
if (!(channel_name.empty())) {
|
||||
if (!(channel_name.empty()))
|
||||
{
|
||||
strcpy(buf, UTF8_TO_FILESYSTEM_ENCODING(channel_name.c_str()));
|
||||
ZapitTools::replace_char(buf);
|
||||
StringReplace(FilenameTemplate, "%C", buf);
|
||||
@@ -465,8 +471,10 @@ std::string CIMDB::getFilename(CZapitChannel * channel, uint64_t id)
|
||||
StringReplace(FilenameTemplate, "%C", "no_channel");
|
||||
|
||||
CShortEPGData epgdata;
|
||||
if(CEitManager::getInstance()->getEPGidShort(id, &epgdata)) {
|
||||
if (!(epgdata.title.empty())) {
|
||||
if (CEitManager::getInstance()->getEPGidShort(id, &epgdata))
|
||||
{
|
||||
if (!(epgdata.title.empty()))
|
||||
{
|
||||
strcpy(buf, epgdata.title.c_str());
|
||||
ZapitTools::replace_char(buf);
|
||||
StringReplace(FilenameTemplate, "%T", buf);
|
||||
@@ -474,7 +482,8 @@ std::string CIMDB::getFilename(CZapitChannel * channel, uint64_t id)
|
||||
else
|
||||
StringReplace(FilenameTemplate, "%T", "no_title");
|
||||
|
||||
if (!(epgdata.info1.empty())) {
|
||||
if (!(epgdata.info1.empty()))
|
||||
{
|
||||
strcpy(buf, epgdata.info1.c_str());
|
||||
ZapitTools::replace_char(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 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);
|
||||
pos = ptr + rstr.length();
|
||||
}
|
||||
|
@@ -74,7 +74,8 @@ void CTMDB::setTitle(std::string epgtitle)
|
||||
if ((minfo.result < 1 || minfo.overview.empty()) && lang != "en")
|
||||
getMovieDetails("en", true);
|
||||
|
||||
if(hintbox){
|
||||
if (hintbox)
|
||||
{
|
||||
hintbox->hide();
|
||||
delete hintbox;
|
||||
hintbox = NULL;
|
||||
@@ -89,7 +90,8 @@ bool CTMDB::getData(std::string url, Json::Value *root)
|
||||
|
||||
std::string errMsg = "";
|
||||
bool ok = parseJsonFromString(answer, root, &errMsg);
|
||||
if (!ok) {
|
||||
if (!ok)
|
||||
{
|
||||
printf("Failed to parse JSON\n");
|
||||
printf("%s\n", errMsg.c_str());
|
||||
return false;
|
||||
@@ -107,11 +109,13 @@ bool CTMDB::getMovieDetails(std::string lang, bool second)
|
||||
return false;
|
||||
|
||||
minfo.result = root.get("total_results", 0).asInt();
|
||||
if(minfo.result == 0){
|
||||
if (minfo.result == 0)
|
||||
{
|
||||
std::string title = minfo.epgtitle;
|
||||
size_t pos1 = 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");
|
||||
title.replace(pos1, pos2 - pos1 + 1, "");
|
||||
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);
|
||||
|
||||
if (minfo.result > 0) {
|
||||
if (minfo.result > 0)
|
||||
{
|
||||
Json::Value elements = root["results"];
|
||||
int use_result = 0;
|
||||
|
||||
if ((minfo.result > 1) && (!second))
|
||||
selectResult(elements, minfo.result, use_result);
|
||||
|
||||
if (!second) {
|
||||
if (!second)
|
||||
{
|
||||
minfo.id = elements[use_result].get("id", -1).asInt();
|
||||
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";
|
||||
if (!(getData(url, &root)))
|
||||
return false;
|
||||
@@ -146,27 +153,31 @@ bool CTMDB::getMovieDetails(std::string lang, bool second)
|
||||
minfo.vote_average = root.get("vote_average", "").asString();;
|
||||
minfo.vote_count = root.get("vote_count", 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.episodes = root.get("number_of_episodes", 0).asInt();;
|
||||
minfo.seasons = root.get("number_of_seasons", 0).asInt();;
|
||||
minfo.release_date = root.get("first_air_date", "").asString();;
|
||||
elements = root["episode_run_time"];
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
elements = root["genres"];
|
||||
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();
|
||||
}
|
||||
|
||||
elements = root["credits"]["cast"];
|
||||
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";
|
||||
//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;
|
||||
}
|
||||
} else
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
return false;
|
||||
@@ -233,7 +245,8 @@ void CTMDB::cleanup()
|
||||
|
||||
void CTMDB::selectResult(Json::Value elements, int results, int &use_result)
|
||||
{
|
||||
if(hintbox){
|
||||
if (hintbox)
|
||||
{
|
||||
hintbox->hide();
|
||||
delete hintbox;
|
||||
hintbox = NULL;
|
||||
|
@@ -27,7 +27,8 @@
|
||||
#include <system/helpers-json.h>
|
||||
#include <gui/widget/hintbox.h>
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
std::string epgtitle;
|
||||
std::string poster_path;
|
||||
std::string overview;
|
||||
|
Reference in New Issue
Block a user