diff --git a/functions.cpp b/functions.cpp index fccc2ab..2007dca 100644 --- a/functions.cpp +++ b/functions.cpp @@ -41,6 +41,7 @@ std::vector< RenameLibrary > getLibraries(const std::vector getOptions( const RenameObject &search ); bool renamePath( const string &path, const RenameObject &renamer ); std::vector< string > getCustomKeys(); const string getName(); +const bool canRenameMultipleFiles(); } #endif // TV_RENAME_HPP diff --git a/main.cpp b/main.cpp index 5833eea..ff56d6f 100644 --- a/main.cpp +++ b/main.cpp @@ -53,22 +53,23 @@ bool verifyLogin( const std::shared_ptr< restbed::Session > &session, rapidjson: return res; } -std::vector> getTypes() { - std::vector> result{}; +std::vector> getLibraries() { + std::vector> result{}; for(size_t i = 0; i < libraries.size(); i++) { - result.emplace_back(libraries[i].getName(), i); + result.emplace_back(&libraries[i], i); } return result; } -std::string getTypesJson() { - auto types = getTypes(); +std::string getLibrariesJson() { + auto libraries = getLibraries(); std::ostringstream result; - result << "{\n \"types\": [\n"; - if(!types.empty()) { - for(const auto &type : types) { - result << " {\n \"id\": " << type.second << ",\n"; - result << " \"name\": \"" << safeJson(type.first) << "\"\n },\n"; + result << "{\n \"libraries\": [\n"; + if(!libraries.empty()) { + for(const auto &library : libraries) { + result << " {\n \"id\": " << library.second << ",\n"; + result << " \"name\": \"" << safeJson(library.first->getName()) << "\"\n,"; + result << " \"multiple_files\": " << (library.first->canRenameMultipleFiles() ? "true" : "false") << "\n },\n"; } result.seekp(-2, std::ios_base::end); result << "\n"; @@ -78,8 +79,8 @@ std::string getTypesJson() { return res; } -void getTypesRest( const std::shared_ptr< restbed::Session > &session ) { - sendResponse(getTypesJson(), restbed::OK, session); +void getLibrariesRest( const std::shared_ptr< restbed::Session > &session ) { + sendResponse(getLibrariesJson(), restbed::OK, session); } std::vector< RenameObject > getOptions(const RenameObject &search) { @@ -512,10 +513,10 @@ int main(int argc, char **argv) { restbed::Service service; - auto get_types = std::make_shared< restbed::Resource >(); - get_types->set_path("/get_types"); - get_types->set_method_handler( "GET", getTypesRest ); - service.publish(get_types); + auto get_libraries = std::make_shared< restbed::Resource >(); + get_libraries->set_path("/get_libraries"); + get_libraries->set_method_handler( "GET", getLibrariesRest ); + service.publish(get_libraries); auto search = std::make_shared< restbed::Resource >(); search->set_path("/search"); diff --git a/rename_library.hpp b/rename_library.hpp index 2bf0337..7cfc6c1 100644 --- a/rename_library.hpp +++ b/rename_library.hpp @@ -10,6 +10,7 @@ struct RenameLibrary { bool ( *renamePath )( const std::string &, const RenameObject & ); std::vector< std::string > ( *getCustomKeys )(); const std::string ( *getName )(); + const bool ( *canRenameMultipleFiles )(); void *libhndl; std::string name; std::string config; diff --git a/simple_rename/simple.cpp b/simple_rename/simple.cpp index 9202a38..a7a707b 100644 --- a/simple_rename/simple.cpp +++ b/simple_rename/simple.cpp @@ -51,5 +51,9 @@ std::vector< string > getCustomKeys() { } const string getName() { - return "simple rename"; + return "Simple Rename"; +} + +const bool canRenameMultipleFiles() { + return false; } diff --git a/themoviedb/moviedb.cpp b/themoviedb/moviedb.cpp index bf4ae90..a7102ea 100644 --- a/themoviedb/moviedb.cpp +++ b/themoviedb/moviedb.cpp @@ -282,5 +282,9 @@ std::vector< string > getCustomKeys() { } const string getName() { - return "themoviedb"; + return "TheMovieDB"; +} + +const bool canRenameMultipleFiles() { + return false; } diff --git a/thetvdb/tv_rename.cpp b/thetvdb/tv_rename.cpp index a1b05a5..86c9170 100644 --- a/thetvdb/tv_rename.cpp +++ b/thetvdb/tv_rename.cpp @@ -406,5 +406,9 @@ std::vector< string > getCustomKeys() { } const string getName() { - return "thetvdb"; + return "TheTVDB"; +} + +const bool canRenameMultipleFiles() { + return true; }