From 49d32f9023722306c18fcaf182390d864005cd84 Mon Sep 17 00:00:00 2001 From: zv0n Date: Sun, 6 Mar 2022 16:40:15 +0100 Subject: [PATCH] Added getCustomKeyOptions and getCustomKeyDefault functions --- functions.cpp | 14 ++- library.hpp | 7 +- main.cpp | 14 ++- rename_library.hpp | 5 +- simple_rename/simple.cpp | 24 ++-- themoviedb/moviedb.cpp | 242 +++++++++++++++++++++++++++++++++++- thetvdb/tv_rename.cpp | 262 ++++++++++++++++++++++++++++++++++++--- 7 files changed, 530 insertions(+), 38 deletions(-) diff --git a/functions.cpp b/functions.cpp index f7db7b8..132badd 100644 --- a/functions.cpp +++ b/functions.cpp @@ -34,12 +34,24 @@ std::vector< RenameLibrary > getLibraries(const std::vector >( * )() )dlsym( + rl.getCustomKeys = ( std::vector< std::unordered_map< std::string, std::string > >( * )() )dlsym( libhndl, "getCustomKeys" ); if ( !rl.getCustomKeys ) { result.push_back( rl ); goto dlsymerror; } + rl.getCustomKeyOptions = ( std::vector< std::pair< std::string, std::string > >( * )(const std::string &) )dlsym( + libhndl, "getCustomKeyOptions" ); + if ( !rl.getCustomKeyOptions ) { + result.push_back( rl ); + goto dlsymerror; + } + rl.getCustomKeyDefault = ( const std::string( * )(const std::string &) )dlsym( + libhndl, "getCustomKeyDefault" ); + if ( !rl.getCustomKeyDefault ) { + result.push_back( rl ); + goto dlsymerror; + } rl.getName = ( const std::string(*)() ) dlsym( libhndl, "getName" ); rl.canRenameMultipleFiles = ( const bool(*)() ) dlsym( libhndl, "canRenameMultipleFiles" ); rl.config = library.second; diff --git a/library.hpp b/library.hpp index 9774a2c..4a76f2b 100644 --- a/library.hpp +++ b/library.hpp @@ -20,12 +20,17 @@ using string = std::string; #define YEAR_TYPE "year" #define DATE_TYPE "date" #define BOOL_TYPE "bool" +#define MULTICHOICE_TYPE "multichoice" extern "C" { bool init(const string &configuration); std::vector< RenameObject > getOptions( const RenameObject &search ); bool renamePath( const string &path, const RenameObject &renamer ); -std::vector< std::pair > getCustomKeys(); +// key name, key type +std::vector< std::unordered_map > getCustomKeys(); +// option internal representation, option display value +std::vector< std::pair > getCustomKeyOptions(const string &key); +const string getCustomKeyDefault(const string &key); const string getName(); const bool canRenameMultipleFiles(); } diff --git a/main.cpp b/main.cpp index 9b1a238..17341c4 100644 --- a/main.cpp +++ b/main.cpp @@ -16,6 +16,8 @@ #include "config/config.hpp" #include "fileobject.hpp" +// TODO add customKeyOptions and customKeyDefault endpoints + std::vector libraries{}; Configuration cfg; @@ -138,7 +140,7 @@ void getOptionsRest( const std::shared_ptr< restbed::Session > &session, rapidjs sendResponse(getOptionsJson(search), 200, session); } -std::vector< std::pair< std::string, std::string > > getCustomKeys(size_t library_id) { +std::vector< std::unordered_map< std::string, std::string > > getCustomKeys(size_t library_id) { if(library_id >= libraries.size()) { return {}; } @@ -148,16 +150,20 @@ std::vector< std::pair< std::string, std::string > > getCustomKeys(size_t librar std::string getCustomKeysJson(size_t library_id) { std::ostringstream res; - res << "{\n \"custom_keys\": {\n"; + res << "{\n \"custom_keys\": [\n"; auto custom_keys = getCustomKeys(library_id); if(!custom_keys.empty()) { for(auto &key : custom_keys) { - res << "\"" << safeJson(key.first) << "\": \"" << safeJson(key.second) << "\",\n"; + res << " {\n"; + res << " \"name\": \"" << safeJson(key["name"]) << "\",\n"; + res << " \"type\": \"" << safeJson(key["type"]) << "\",\n"; + res << " \"input\": \"" << safeJson(key["input"]) << "\"\n"; + res << " },\n"; } res.seekp( -2, std::ios_base::end ); res << "\n"; } - res << " }\n}"; + res << " ]\n}"; return res.str(); } diff --git a/rename_library.hpp b/rename_library.hpp index 82b7fdc..f2c6aab 100644 --- a/rename_library.hpp +++ b/rename_library.hpp @@ -2,13 +2,16 @@ #define RENAME_LIBRARY_H #include +#include #include "rename_object.hpp" struct RenameLibrary { bool ( *init )( const std::string & ); std::vector< RenameObject > ( *getOptions )( const RenameObject & ); bool ( *renamePath )( const std::string &, const RenameObject & ); - std::vector< std::pair< std::string, std::string > > ( *getCustomKeys )(); + std::vector< std::unordered_map< std::string, std::string > > ( *getCustomKeys )(); + std::vector< std::pair< std::string, std::string > > ( *getCustomKeyOptions )(const std::string &); + const std::string ( *getCustomKeyDefault )(const std::string &); const std::string ( *getName )(); const bool ( *canRenameMultipleFiles )(); void *libhndl; diff --git a/simple_rename/simple.cpp b/simple_rename/simple.cpp index 261c484..d55778d 100644 --- a/simple_rename/simple.cpp +++ b/simple_rename/simple.cpp @@ -31,12 +31,8 @@ std::vector< RenameObject > getOptions( const RenameObject & /*UNUSED*/ ) { } bool renamePath( const string &path, const RenameObject &renamer ) { - string new_name = ""; - - if ( renamer.getCustomFields().find( "new_name" ) != - renamer.getCustomFields().end() ) { - new_name = renamer.getCustomFields().at( "new_name" ); - } else { + string new_name = renamer.getPresentedName(); + if(new_name.empty()) { return false; } @@ -49,8 +45,20 @@ bool renamePath( const string &path, const RenameObject &renamer ) { new_name ); } -std::vector< std::pair< string, string > > getCustomKeys() { - return { { "new_name", STRING_TYPE } }; +std::vector< std::unordered_map< string, string > > getCustomKeys() { + return {}; +} + +std::vector< std::pair< string, string > > getCustomKeyOptions(const string &key) { + return {}; +} + +const string getCustomKeyDefault(const string &key) { + return ""; +} + +const string choiceDisplay() { + return "\%name"; } const string getName() { diff --git a/themoviedb/moviedb.cpp b/themoviedb/moviedb.cpp index 6683eca..605567d 100644 --- a/themoviedb/moviedb.cpp +++ b/themoviedb/moviedb.cpp @@ -43,6 +43,196 @@ constexpr const char_t *_tv_rename_dir_divider = "/"; #endif +const std::vector< std::pair< std::string, std::string > > languages = { + { "aa", "Afar" }, + { "ab", "Abkhazian" }, + { "ae", "Avestan" }, + { "af", "Afrikaans" }, + { "ak", "Akan" }, + { "am", "Amharic" }, + { "an", "Aragonese" }, + { "ar", "العربية" }, + { "as", "Assamese" }, + { "av", "Avaric" }, + { "ay", "Aymara" }, + { "az", "Azərbaycan" }, + { "ba", "Bashkir" }, + { "be", "беларуская мова" }, + { "bg", "български език" }, + { "bi", "Bislama" }, + { "bm", "Bamanankan" }, + { "bn", "বাংলা" }, + { "bo", "Tibetan" }, + { "br", "Breton" }, + { "bs", "Bosanski" }, + { "ca", "Català" }, + { "ce", "Chechen" }, + { "ch", "Finu' Chamorro" }, + { "cn", "广州话 / 廣州話" }, + { "co", "Corsican" }, + { "cr", "Cree" }, + { "cs", "Český" }, + { "cu", "Slavic" }, + { "cv", "Chuvash" }, + { "cy", "Cymraeg" }, + { "da", "Dansk" }, + { "de", "Deutsch" }, + { "dv", "Divehi" }, + { "dz", "Dzongkha" }, + { "ee", "Èʋegbe" }, + { "el", "ελληνικά" }, + { "en", "English" }, + { "eo", "Esperanto" }, + { "es", "Español" }, + { "et", "Eesti" }, + { "eu", "euskera" }, + { "fa", "فارسی" }, + { "ff", "Fulfulde" }, + { "fi", "suomi" }, + { "fj", "Fijian" }, + { "fo", "Faroese" }, + { "fr", "Français" }, + { "fy", "Frisian" }, + { "ga", "Gaeilge" }, + { "gd", "Gaelic" }, + { "gl", "Galego" }, + { "gn", "Guarani" }, + { "gu", "Gujarati" }, + { "gv", "Manx" }, + { "ha", "Hausa" }, + { "he", "עִבְרִית" }, + { "hi", "हिन्दी" }, + { "ho", "Hiri Motu" }, + { "hr", "Hrvatski" }, + { "ht", "Haitian; Haitian Creole" }, + { "hu", "Magyar" }, + { "hy", "Armenian" }, + { "hz", "Herero" }, + { "ia", "Interlingua" }, + { "id", "Bahasa indonesia" }, + { "ie", "Interlingue" }, + { "ig", "Igbo" }, + { "ii", "Yi" }, + { "ik", "Inupiaq" }, + { "io", "Ido" }, + { "is", "Íslenska" }, + { "it", "Italiano" }, + { "iu", "Inuktitut" }, + { "ja", "日本語" }, + { "jv", "Javanese" }, + { "ka", "ქართული" }, + { "kg", "Kongo" }, + { "ki", "Kikuyu" }, + { "kj", "Kuanyama" }, + { "kk", "қазақ" }, + { "kl", "Kalaallisut" }, + { "km", "Khmer" }, + { "kn", "Kannada" }, + { "ko", "한국어/조선말" }, + { "kr", "Kanuri" }, + { "ks", "Kashmiri" }, + { "ku", "Kurdish" }, + { "kv", "Komi" }, + { "kw", "Cornish" }, + { "ky", "Kirghiz" }, + { "la", "Latin" }, + { "lb", "Letzeburgesch" }, + { "lg", "Ganda" }, + { "li", "Limburgish" }, + { "ln", "Lingala" }, + { "lo", "Lao" }, + { "lt", "Lietuvių" }, + { "lu", "Luba-Katanga" }, + { "lv", "Latviešu" }, + { "mg", "Malagasy" }, + { "mh", "Marshall" }, + { "mi", "Maori" }, + { "mk", "Macedonian" }, + { "ml", "Malayalam" }, + { "mn", "Mongolian" }, + { "mo", "Moldavian" }, + { "mr", "Marathi" }, + { "ms", "Bahasa melayu" }, + { "mt", "Malti" }, + { "my", "Burmese" }, + { "na", "Nauru" }, + { "nb", "Bokmål" }, + { "nd", "Ndebele" }, + { "ne", "Nepali" }, + { "ng", "Ndonga" }, + { "nl", "Nederlands" }, + { "nn", "Norwegian Nynorsk" }, + { "no", "Norsk" }, + { "nr", "Ndebele" }, + { "nv", "Navajo" }, + { "ny", "Chichewa; Nyanja" }, + { "oc", "Occitan" }, + { "oj", "Ojibwa" }, + { "om", "Oromo" }, + { "or", "Oriya" }, + { "os", "Ossetian; Ossetic" }, + { "pa", "ਪੰਜਾਬੀ" }, + { "pi", "Pali" }, + { "pl", "Polski" }, + { "ps", "پښتو" }, + { "pt", "Português" }, + { "qu", "Quechua" }, + { "rm", "Raeto-Romance" }, + { "rn", "Kirundi" }, + { "ro", "Română" }, + { "ru", "Pусский" }, + { "rw", "Kinyarwanda" }, + { "sa", "Sanskrit" }, + { "sc", "Sardinian" }, + { "sd", "Sindhi" }, + { "se", "Northern Sami" }, + { "sg", "Sango" }, + { "sh", "Serbo-Croatian" }, + { "si", "සිංහල" }, + { "sk", "Slovenčina" }, + { "sl", "Slovenščina" }, + { "sm", "Samoan" }, + { "sn", "Shona" }, + { "so", "Somali" }, + { "sq", "shqip" }, + { "sr", "Srpski" }, + { "ss", "Swati" }, + { "st", "Sotho" }, + { "su", "Sundanese" }, + { "sv", "svenska" }, + { "sw", "Kiswahili" }, + { "ta", "தமிழ்" }, + { "te", "తెలుగు" }, + { "tg", "Tajik" }, + { "th", "ภาษาไทย" }, + { "ti", "Tigrinya" }, + { "tk", "Turkmen" }, + { "tl", "Tagalog" }, + { "tn", "Tswana" }, + { "to", "Tonga" }, + { "tr", "Türkçe" }, + { "ts", "Tsonga" }, + { "tt", "Tatar" }, + { "tw", "Twi" }, + { "ty", "Tahitian" }, + { "ug", "Uighur" }, + { "uk", "Український" }, + { "ur", "اردو" }, + { "uz", "ozbek" }, + { "ve", "Venda" }, + { "vi", "Tiếng Việt" }, + { "vo", "Volapük" }, + { "wa", "Walloon" }, + { "wo", "Wolof" }, + { "xh", "Xhosa" }, + { "xx", "No Language" }, + { "yi", "Yiddish" }, + { "yo", "Èdè Yorùbá" }, + { "za", "Zhuang" }, + { "zh", "普通话" }, + { "zu", "Zulu" } +}; + string _moviedb_api_token{}; Request _moviedb_request; @@ -277,12 +467,52 @@ bool renamePath( const string &path, const RenameObject &renamer ) { year ); } -std::vector< std::pair< string, string > > getCustomKeys() { - return { { "id", NUM_TYPE }, - { "language", STRING_TYPE }, - { "year", YEAR_TYPE }, - { "original_title", STRING_TYPE }, - { "use_original", BOOL_TYPE } }; +std::vector< std::unordered_map< string, string > > getCustomKeys() { + return { { + { "name", "id"}, + {"type", NUM_TYPE}, + {"input", "true"} + }, + { + { "name", "language" }, + { "type", MULTICHOICE_TYPE }, + { "input", "true" }, + }, + { + { "name", "year" }, + { "type", YEAR_TYPE }, + { "input", "true" }, + }, + { + { "name", "original_title" }, + { "type", STRING_TYPE }, + { "input", "false" }, + }, + { + { "name", "use_original" }, + { "type", BOOL_TYPE }, + { "input", "true" }, + }, + }; +} + +std::vector< std::pair< string, string > > +getCustomKeyOptions( const string &key ) { + if ( key == "language" ) { + return languages; + } + return {}; +} + +const string getCustomKeyDefault( const string &key ) { + if ( key == "language" ) { + return "en"; + } + return ""; +} + +const string choiceDisplay() { + return "\%name (\%original_title) (\%year)"; } const string getName() { diff --git a/thetvdb/tv_rename.cpp b/thetvdb/tv_rename.cpp index e6faa0d..37386fa 100644 --- a/thetvdb/tv_rename.cpp +++ b/thetvdb/tv_rename.cpp @@ -46,6 +46,191 @@ constexpr const char_t *_tv_rename_dir_divider = "/"; #define TV_LINUX 0x0400 #define TV_DVD 0x0800 +const std::vector< std::pair< std::string, std::string > > languages = { + { "aa", "Afaraf" }, + { "ab", "аҧсуабызшәа" }, + { "ae", "avesta" }, + { "af", "Afrikaans" }, + { "ak", "Akan" }, + { "am", "አማርኛ" }, + { "an", "aragonés" }, + { "ar", "العربية" }, + { "as", "অসমীয়া" }, + { "av", "авармацӀ" }, + { "ay", "aymararu" }, + { "az", "azərbaycandili" }, + { "ba", "башҡорттеле" }, + { "be", "беларускаямова" }, + { "bg", "българскиезик" }, + { "bh", "भोजपुरी" }, + { "bi", "Bislama" }, + { "bm", "bamanankan" }, + { "bn", "বাংলা" }, + { "bo", "བོད་ཡིག" }, + { "br", "brezhoneg" }, + { "bs", "bosanskijezik" }, + { "ca", "català" }, + { "ce", "нохчийнмотт" }, + { "ch", "Chamoru" }, + { "co", "corsu" }, + { "cr", "ᓀᐦᐃᔭᐍᐏᐣ" }, + { "cs", "čeština" }, + { "cu", "ѩзыкъсловѣньскъ" }, + { "cv", "чӑвашчӗлхи" }, + { "cy", "Cymraeg" }, + { "da", "dansk" }, + { "de", "Deutsch" }, + { "dv", "ދިވެހި" }, + { "dz", "རྫོང་ཁ" }, + { "ee", "Eʋegbe" }, + { "el", "ελληνικήγλώσσα" }, + { "en", "English" }, + { "eo", "Esperanto" }, + { "es", "español" }, + { "et", "eesti" }, + { "eu", "euskara" }, + { "fa", "فارسی" }, + { "ff", "Fulfulde" }, + { "fi", "suomi" }, + { "fj", "vosaVakaviti" }, + { "fo", "føroyskt" }, + { "fr", "français" }, + { "fy", "Frysk" }, + { "ga", "Gaeilge" }, + { "gd", "Gàidhlig" }, + { "gl", "galego" }, + { "gn", "Avañe'ẽ" }, + { "gu", "ગુજરાતી" }, + { "gv", "Gaelg" }, + { "ha", "هَوُسَ" }, + { "he", "עברית" }, + { "hi", "हिन्दी" }, + { "ho", "HiriMotu" }, + { "hr", "hrvatskijezik" }, + { "ht", "Kreyòlayisyen" }, + { "hu", "Magyar" }, + { "hy", "Հայերեն" }, + { "hz", "Otjiherero" }, + { "ia", "Interlingua" }, + { "id", "BahasaIndonesia" }, + { "ie", "Interlingue" }, + { "ig", "AsụsụIgbo" }, + { "ii", "Nuosuhxop" }, + { "ik", "Iñupiaq" }, + { "io", "Ido" }, + { "is", "Íslenska" }, + { "it", "italiano" }, + { "iu", "ᐃᓄᒃᑎᑐᑦ" }, + { "ja", "日本語" }, + { "jv", "basaJawa" }, + { "ka", "ქართული" }, + { "kg", "KiKongo" }, + { "ki", "Gĩkũyũ" }, + { "kj", "Kuanyama" }, + { "kk", "қазақтілі" }, + { "kl", "kalaallisut" }, + { "km", "ខ្មែរ" }, + { "kn", "ಕನ್ನಡ" }, + { "ko", "한국어" }, + { "kr", "Kanuri" }, + { "ks", "कश्मीरी" }, + { "ku", "Kurdî" }, + { "kv", "комикыв" }, + { "kw", "Kernewek" }, + { "ky", "кыргызтили" }, + { "la", "latine" }, + { "lb", "Lëtzebuergesch" }, + { "lg", "Luganda" }, + { "li", "Limburgs" }, + { "ln", "Lingála" }, + { "lo", "ພາສາລາວ" }, + { "lt", "lietuviųkalba" }, + { "lu", "Luba-Katanga" }, + { "lv", "latviešuvaloda" }, + { "mg", "Malagasyfiteny" }, + { "mh", "KajinM̧ajeļ" }, + { "mi", "tereoMāori" }, + { "mk", "македонскијазик" }, + { "ml", "മലയാളം" }, + { "mn", "монгол" }, + { "mr", "मराठी" }, + { "ms", "bahasaMelayu" }, + { "mt", "Malti" }, + { "my", "Burmese" }, + { "na", "EkakairũNaoero" }, + { "nd", "isiNdebele" }, + { "ne", "नेपाली" }, + { "ng", "Owambo" }, + { "nl", "Nederlands" }, + { "no", "Norskbokmål" }, + { "nr", "isiNdebele" }, + { "nv", "Dinébizaad" }, + { "ny", "chiCheŵa" }, + { "oc", "occitan" }, + { "oj", "ᐊᓂᔑᓈᐯᒧᐎᓐ" }, + { "om", "AfaanOromoo" }, + { "or", "ଓଡ଼ିଆ" }, + { "os", "иронæвзаг" }, + { "pa", "ਪੰਜਾਬੀ" }, + { "pi", "पाऴि" }, + { "pl", "językpolski" }, + { "ps", "پښتو" }, + { "pt", "Português-Brasil" }, + { "qu", "RunaSimi" }, + { "rm", "rumantschgrischun" }, + { "rn", "Ikirundi" }, + { "ro", "limbaromână" }, + { "ru", "русскийязык" }, + { "rw", "Ikinyarwanda" }, + { "sa", "संस्कृतम्" }, + { "sc", "sardu" }, + { "sd", "सिन्धी" }, + { "se", "Davvisámegiella" }, + { "sg", "yângâtîsängö" }, + { "si", "සිංහල" }, + { "sk", "slovenčina" }, + { "sl", "slovenskijezik" }, + { "sm", "gaganafa'aSamoa" }, + { "sn", "chiShona" }, + { "so", "Soomaaliga" }, + { "sq", "gjuhashqipe" }, + { "sr", "српскијезик" }, + { "ss", "SiSwati" }, + { "st", "Sesotho" }, + { "su", "BasaSunda" }, + { "sv", "svenska" }, + { "sw", "Kiswahili" }, + { "ta", "தமிழ்" }, + { "te", "తెలుగు" }, + { "tg", "тоҷикӣ" }, + { "th", "ไทย" }, + { "ti", "ትግርኛ" }, + { "tk", "Türkmen" }, + { "tl", "WikangTagalog" }, + { "tn", "Setswana" }, + { "to", "fakaTonga" }, + { "tr", "Türkçe" }, + { "ts", "Xitsonga" }, + { "tt", "татартеле" }, + { "tw", "Twi" }, + { "ty", "ReoTahiti" }, + { "ug", "Uyƣurqə" }, + { "uk", "українськамова" }, + { "ur", "اردو" }, + { "uz", "Ozbek" }, + { "ve", "Tshivenḓa" }, + { "vi", "TiếngViệt" }, + { "vo", "Volapük" }, + { "wa", "walon" }, + { "wo", "Wollof" }, + { "xh", "isiXhosa" }, + { "yi", "ייִדיש" }, + { "yo", "Yorùbá" }, + { "za", "Saɯcueŋƅ" }, + { "zh", "大陆简体" }, + { "zu", "isiZulu" } +}; + string _tv_rename_api_token{}; Request _tv_rename_request; @@ -71,11 +256,11 @@ bool authenticate( const std::string &api_key ) { return true; } -bool init(const string &config_path) { +bool init( const string &config_path ) { return authenticate( "42B66F5E-C6BF-423F-ADF9-CC97163472F6" ); } -std::vector< std::pair< string, string > > +std::vector< std::tuple< string, string, string > > searchShow( const string &show, const string &language ) { Request &request = _tv_rename_request; request.addHeader( TEXT( "Accept: application/json" ) ); @@ -86,8 +271,7 @@ searchShow( const string &show, const string &language ) { auto encoded_show = encodeUrl( show ); rapidjson::Document json; - json.Parse( - request.get( TEXT( "/search/series?name=" ) + encoded_show ).c_str() ); + json.Parse( request.get( TEXT( "/search/series?name=" ) + encoded_show ).c_str() ); if ( json.HasParseError() ) return {}; @@ -96,13 +280,15 @@ searchShow( const string &show, const string &language ) { return {}; } - std::vector< std::pair< string, string > > ret; + std::vector< std::tuple< string, string, string > > ret; // find all possible shows for ( size_t i = 0; i < results.Size(); i++ ) { auto show = toString( results[i]["seriesName"].GetString() ); auto id = toString( std::to_string( results[i]["id"].GetInt() ) ); - ret.emplace_back( show, id ); + std::string date = toString( results[i]["firstAired"].GetString() ); + auto year = date.substr(0, date.find('-')); + ret.emplace_back( show, id, year ); } request.clearHeader(); return ret; @@ -335,14 +521,15 @@ void allSeasons( const string &id, const string &path, const string &show, } } -RenameObject showToRenameObject( const std::pair< string, string > &show, +RenameObject showToRenameObject( const std::tuple< string, string, string > &show, const std::string &language ) { RenameObject result; - result.setPresentedName( show.first ); - result.addCustomField( "id", show.second ); + result.setPresentedName( std::get<0>(show) ); + result.addCustomField( "id", std::get<1>(show) ); result.addCustomField( "language", language ); result.addCustomField( "order", "aired" ); result.addCustomField( "pattern", getDefaultPattern() ); + result.addCustomField( "year", std::get<2>(show) ); return result; } @@ -379,9 +566,10 @@ bool renamePath( const string &path, const RenameObject &renamer ) { auto results = searchShow( renamer.getPresentedName(), lang ); if ( results.empty() ) return false; - id = results[0].second; - show = results[0].first; - } else if( renamer.getCustomFields().find("id") != renamer.getCustomFields().end()) { + id = std::get<1>(results[0]); + show = std::get<0>(results[0]); + } else if ( renamer.getCustomFields().find( "id" ) != + renamer.getCustomFields().end() ) { id = renamer.getCustomFields().at( "id" ); show = showFromId( id ); } @@ -401,11 +589,51 @@ bool renamePath( const string &path, const RenameObject &renamer ) { return true; } -std::vector< std::pair< string, string > > getCustomKeys() { - return { { "id", NUM_TYPE }, - { "language", STRING_TYPE }, - { "pattern", STRING_TYPE }, - { "order", STRING_TYPE } }; +std::vector< std::unordered_map< string, string > > getCustomKeys() { + return { { + { "name", "id"}, + {"type", NUM_TYPE}, + {"input", "true"} + }, + { + { "name", "language" }, + { "type", STRING_TYPE }, + { "input", "true" }, + }, + { + { "name", "pattern" }, + { "type", STRING_TYPE }, + { "input", "true" }, + }, + { + { "name", "order" }, + { "type", MULTICHOICE_TYPE }, + { "input", "true" }, + }, + { + { "name", "year" }, + { "type", YEAR_TYPE }, + { "input", "false" }, + } + }; +} + +std::vector< std::pair< string, string > > getCustomKeyOptions(const string &key) { + if(key == "language") { + return languages; + } + return {}; +} + +const string choiceDisplay() { + return "\%name (\%year)"; +} + +const string getCustomKeyDefault(const string &key) { + if(key == "language") { + return "en"; + } + return ""; } const string getName() {