TV_rename: return a vector of languages for windows

This commit is contained in:
zvon 2020-02-25 10:19:24 +01:00
parent 31d30bb42a
commit e6b2aeecad
2 changed files with 19 additions and 4 deletions

View File

@ -107,7 +107,7 @@ string showNameFromId( const string &id, const string &language ) {
json.Parse( request.get( TEXT( "/series/" ) + id ).c_str() );
if ( json.HasParseError() )
return "";
return TEXT( "" );
return toString( json["data"]["seriesName"].GetString() );
}
@ -138,7 +138,7 @@ std::vector< string > getEpisodeNames( const string &id, const string &season,
json.Parse( request.get( baseurl + page ).c_str() );
if ( json.HasParseError() )
return {};
if( json.FindMember("data") == json.MemberEnd() )
if ( json.FindMember( "data" ) == json.MemberEnd() )
break;
if ( json["data"].IsArray() ) {
@ -262,9 +262,14 @@ getRenamedFiles( const string &show, int season, const string id,
return renamed_files;
}
#ifndef _WIN32
std::map< string, string > getLangs() {
Request &request = _tv_rename_request;
std::map< string, string > langs;
#else
std::vector< std::pair< string, string > > getLangs() {
std::vector< std::pair< string, string > > langs;
#endif
Request &request = _tv_rename_request;
request.addHeader( TEXT( "Accept: application/json" ) );
request.addHeader( TEXT( "Authorization: Bearer " ) +
_tv_rename_api_token );
@ -273,8 +278,14 @@ std::map< string, string > getLangs() {
request.clearHeader();
rapidjson::Value &lang_data = d["data"];
for ( size_t i = 0; i < lang_data.Size(); i++ ) {
langs[ toString( lang_data[i]["abbreviation"].GetString() ) ] =
#ifndef _WIN32
langs[toString( lang_data[i]["abbreviation"].GetString() )] =
toString( lang_data[i]["name"].GetString() );
#else
langs.emplace_back(
toString( lang_data[i]["abbreviation"].GetString() ),
toString( lang_data[i]["name"].GetString() ) );
#endif
}
return langs;
}

View File

@ -46,7 +46,11 @@ getRenamedFiles( const string &show, int season, const string id,
const bool &linux, const std::map< int, string > &files,
bool dvd = false );
#ifndef _WIN32
std::map< string, string > getLangs();
#else
std::vector< std::pair< string, string > > getLangs();
#endif
#else