From ca17640f001d4e97fff93e09201de630ad4101ed Mon Sep 17 00:00:00 2001 From: Kai Lepper Date: Wed, 10 Nov 2021 18:16:41 +0100 Subject: [PATCH] movie info show date as YYYY add col orig_lang --- show.sln | 4 +- show/curl_wrapper.cpp | 7 ++- show/lang.h | 1 + show/show.vcxproj | 114 ------------------------------------------ show/tmdb.cpp | 12 +++++ show/tmdb.h | 1 + show/tree_movie.cpp | 12 +++-- show/util.cpp | 26 ++++++---- show/util.h | 4 +- 9 files changed, 49 insertions(+), 132 deletions(-) diff --git a/show.sln b/show.sln index c6d5450..5faf5b8 100644 --- a/show.sln +++ b/show.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.0.31521.260 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31729.503 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "show", "show\show.vcxproj", "{38B0EE4C-79EC-4306-8920-52A7CDD8FEE2}" EndProject diff --git a/show/curl_wrapper.cpp b/show/curl_wrapper.cpp index 119463b..4b69a30 100644 --- a/show/curl_wrapper.cpp +++ b/show/curl_wrapper.cpp @@ -12,7 +12,12 @@ #include #include -#ifdef WIN32 + + + + + +#ifdef CURL_WIN32 constexpr bool WINDOWS {true}; #elif constexpr bool WINDOWS {false}; diff --git a/show/lang.h b/show/lang.h index 3cd1e73..b2421ab 100644 --- a/show/lang.h +++ b/show/lang.h @@ -18,5 +18,6 @@ inline char const* const DATE{ "Date" }; inline char const* const EXPECTED_FILE{ "argument is not a file!" }; inline char const* const EXPECTED_DIR{ "argument is not a directory!" }; inline char const* const NO_RESULT{ "no result!" }; +inline char const* const ORIG_LANG {"Lang"}; }//NS \ No newline at end of file diff --git a/show/show.vcxproj b/show/show.vcxproj index c1a37d4..bccae2d 100644 --- a/show/show.vcxproj +++ b/show/show.vcxproj @@ -9,14 +9,6 @@ Release Win32 - - Debug - x64 - - - Release - x64 - 16.0 @@ -43,23 +35,6 @@ - - Application - true - v142 - Unicode - - - - - Application - false - v142 - true - Unicode - - - @@ -71,12 +46,6 @@ - - - - - - true @@ -96,24 +65,6 @@ - - true - - - AllRules.ruleset - true - - - - - false - - - AllRules.ruleset - true - - - @@ -122,14 +73,6 @@ - - - - - - - - Level4 @@ -189,63 +132,6 @@ true - - - Level4 - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - stdcpplatest - false - TurnOffAllWarnings - true - true - Sync - NativeMinimumRules.ruleset - false - - - - - Size - ProgramDatabase - - - Console - DebugFastLink - true - - - - - Level4 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - stdcpplatest - false - TurnOffAllWarnings - true - true - Sync - NativeMinimumRules.ruleset - false - - - - - Size - - - Console - true - true - true - true - - diff --git a/show/tmdb.cpp b/show/tmdb.cpp index fcfecd8..231650d 100644 --- a/show/tmdb.cpp +++ b/show/tmdb.cpp @@ -120,6 +120,18 @@ void Movie::parse(boost::json::standalone::value const& json) popularity = value_or_default(json, "popularity", 0.0); vote_average = value_or_default(json, "vote_average", 0.0); + + auto const& pcs = json.at("production_countries").as_array(); + + for(auto const& pc : pcs) + { + std::string iso_3166_1 = value_or_default(pc, "iso_3166_1", ""s); + std::string name = value_or_default(pc, "name", ""s); + + + //this->production_countries.emplace_back(iso_3166_1, name); + + } } void TV::parse(boost::json::standalone::value const& json) diff --git a/show/tmdb.h b/show/tmdb.h index f3461ed..fff8d97 100644 --- a/show/tmdb.h +++ b/show/tmdb.h @@ -40,6 +40,7 @@ struct Movie std::string const url; void parse(boost::json::standalone::value const& json); + std::vector> production_countries {}; boolean adult {}, video {}; string backdrop_path {}, homepage {}, imdb_id {}, original_language {}, original_title {}, overview {}, release_date {}, tagline {}, title {}; integer budget {}, id {}, runtime {}, vote_count {}; diff --git a/show/tree_movie.cpp b/show/tree_movie.cpp index 7bdcd43..c75e55c 100644 --- a/show/tree_movie.cpp +++ b/show/tree_movie.cpp @@ -25,21 +25,27 @@ void Movie_info::func() size_t const len_title {std::max(size_t {10}, utf::count_codepoints(largest_title->title) + 2)}; size_t const len_id {std::max(util::count_digits(largest_id->id) + 2, size_t {8})}; - size_t constexpr len_date {12}; + size_t constexpr len_date {6}; + size_t constexpr len_lang {5}; std::cout << utf::fill_align(lang::TITLE, len_title, utf::Alignment::center) << utf::to_string(u8"║"); std::cout << utf::fill_align(lang::DATE, len_date, utf::Alignment::center) << utf::to_string(u8"║"); + std::cout << utf::fill_align(lang::ORIG_LANG, len_lang, utf::Alignment::center) << utf::to_string(u8"║"); std::cout << utf::fill_align("tmdb-ID", len_id, utf::Alignment::center) << '\n'; std::cout << utf::fill_align("", len_title, utf::Alignment::left, u8"═") << utf::to_string(u8"╬"); std::cout << utf::fill_align("", len_date, utf::Alignment::left, u8"═") << utf::to_string(u8"╬"); + std::cout << utf::fill_align("", len_lang, utf::Alignment::left, u8"═") << utf::to_string(u8"╬"); std::cout << utf::fill_align("", len_id, utf::Alignment::left, u8"═") << '\n'; for(auto const& mov : search_result.m_movies) { std::cout << utf::fill_align(mov.title, len_title, utf::Alignment::left) << utf::to_string(u8"║"); - std::cout << utf::fill_align(mov.release_date, len_date, utf::Alignment::center) << utf::to_string(u8"║"); + std::cout << utf::fill_align(util::year_from_date(mov.release_date), len_date, utf::Alignment::center) << utf::to_string(u8"║"); + std::cout << utf::fill_align(mov.original_language, len_lang, utf::Alignment::center) << utf::to_string(u8"║"); std::cout << utf::fill_align(std::to_string(mov.id), len_id, utf::Alignment::right) << '\n'; + + } std::cout << std::endl; } @@ -53,7 +59,7 @@ void Movie_by_id::func() auto const movie {tmdb::factory(id)}; - std::string plex_style {std::format("{} ({}) {{imdb-{}}}{}", movie.title, movie.release_date, movie.imdb_id, file.extension().string())}; + std::string plex_style {std::format("{0} ({1}) {{imdb-{2}}}{4}", movie.title, movie.release_date, movie.imdb_id, file.extension().string())}; util::make_ntfs_compliant(plex_style); P const old_path = file; diff --git a/show/util.cpp b/show/util.cpp index e1147d9..ee4ef76 100644 --- a/show/util.cpp +++ b/show/util.cpp @@ -8,15 +8,15 @@ std::unique_ptr ARGUMENTS {}; auto util::Args::num_of_arguments_left() const noexcept -> size_t { - return cmd_line.size(); + return cmd_line.size(); } auto util::Args::pop_front() noexcept -> std::string_view { - assert(cmd_line.size()); - std::string_view front = cmd_line.front(); - cmd_line = cmd_line.subspan(1); - return front; + assert(cmd_line.size()); + std::string_view front = cmd_line.front(); + cmd_line = cmd_line.subspan(1); + return front; } util::Args::Args(int argc, char** argv) noexcept : cmd_line(argv, argc) @@ -36,10 +36,18 @@ constexpr auto util::count_digits(__int64 n) noexcept -> size_t return digits; } - auto util::make_ntfs_compliant(std::string& in) -> void { - auto const bad_char = [](auto const& i) - { return i == '/' || i == '\\' || i == ':' || i == '*' || i == '?' || i == '"' || i == '<' || i == '>' || i == '|'; }; - in.erase(std::remove_if(in.begin(), in.end(), bad_char), in.end()); + auto const bad_char = [](auto const& i) + { return i == '/' || i == '\\' || i == ':' || i == '*' || i == '?' || i == '"' || i == '<' || i == '>' || i == '|'; }; + in.erase(std::remove_if(in.begin(), in.end(), bad_char), in.end()); } + +auto util::year_from_date(std::string const& date) -> std::string +{ + if(date.length() >= 4) + { + return std::string {date, 0, 4}; + } + return date; +} \ No newline at end of file diff --git a/show/util.h b/show/util.h index 0369180..727b4d0 100644 --- a/show/util.h +++ b/show/util.h @@ -5,11 +5,11 @@ #include #include - namespace util { extern constexpr auto count_digits(__int64 n) noexcept -> size_t; auto make_ntfs_compliant(std::string& in) -> void; +auto year_from_date(std::string const& date) -> std::string; struct Args { @@ -18,8 +18,6 @@ struct Args [[nodiscard]] auto num_of_arguments_left() const noexcept -> size_t; [[nodiscard]] auto pop_front() noexcept -> std::string_view; Args(int argc, char** argv) noexcept; - - }; } // namespace util