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..b155408 100644 --- a/show/lang.h +++ b/show/lang.h @@ -1,9 +1,7 @@ #pragma once - -namespace lang { - - +namespace lang +{ //class Lang //{ // std::string_view TITLE{ " Title" }; @@ -11,12 +9,11 @@ namespace lang { // std::string_view NO_RESULT{ "no result!" }; //}; +inline char const* const TITLE {"Title"}; +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"}; - -inline char const* const TITLE{ "Title" }; -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!" }; - -}//NS \ No newline at end of file +} // namespace lang \ 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..3d3f10f 100644 --- a/show/tmdb.cpp +++ b/show/tmdb.cpp @@ -90,8 +90,7 @@ Movie::Movie(integer movie_id) : url {std::format("{}movie/{}?{}&{}", prefix(), { } -TV::TV(integer tv_id, integer season_number_) - : url {std::format("{}tv/{}/season/{}?{}&", prefix(), tv_id, season_number_, key(), lang())} +TV::TV(integer tv_id, integer season_number_) : url {std::format("{}tv/{}/season/{}?{}&", prefix(), tv_id, season_number_, key(), lang())} { } @@ -120,6 +119,15 @@ 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) @@ -132,9 +140,9 @@ void TV::parse(boost::json::standalone::value const& json) overview = value_or_default(json, "overview", ""s); poster_path = value_or_default(json, "poster_path", ""s); - id = value_or_default(json, "id", tmdb::integer {0}); - season_number = value_or_default(json, "season_number", tmdb::integer {0}); - auto const& eps = json.at("episodes").as_array(); + id = value_or_default(json, "id", tmdb::integer {0}); + season_number = value_or_default(json, "season_number", tmdb::integer {0}); + auto const& eps = json.at("episodes").as_array(); for(auto const& ep : eps) { @@ -157,7 +165,6 @@ void TV::parse(boost::json::standalone::value const& json) } } - void Movie_search::parse(boost::json::standalone::value const& json) { using namespace boost::json; @@ -178,13 +185,11 @@ void Movie_search::parse(boost::json::standalone::value const& json) } } -Movie_search::Movie_search(string const& query) - : url {std::format("{0}search/movie?{1}&{2}&query={3}", prefix(), key(), lang(), curl::percent_encode(query))} +Movie_search::Movie_search(string const& query) : url {std::format("{0}search/movie?{1}&{2}&query={3}", prefix(), key(), lang(), curl::percent_encode(query))} { } -Series_search::Series_search(string const& query) - : url {std::format("{0}search/tv?{1}&{2}&query={3}", prefix(), key(), lang(), curl::percent_encode(query))} +Series_search::Series_search(string const& query) : url {std::format("{0}search/tv?{1}&{2}&query={3}", prefix(), key(), lang(), curl::percent_encode(query))} { } @@ -228,13 +233,19 @@ Error::Error(boost::json::standalone::value const& json) { auto const& errs = json.at("errors").as_array(); - for(auto const& err : errs) { errors.emplace_back(err.as_string()); } + for(auto const& err : errs) + { + errors.emplace_back(err.as_string()); + } } Error::operator std::string() { std::string out {}; - for(auto const& e : this->errors) { out += e + '\n'; } + for(auto const& e : this->errors) + { + out += e + '\n'; + } return out; } 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..58c4900 100644 --- a/show/tree_movie.cpp +++ b/show/tree_movie.cpp @@ -25,20 +25,24 @@ 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 {4}; 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 +57,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/tree_util.h b/show/tree_util.h index d34ad7a..afabc3a 100644 --- a/show/tree_util.h +++ b/show/tree_util.h @@ -203,7 +203,7 @@ constexpr auto get_child_index(std::integer_sequence, std::string_view return std::ranges::count(candidates, best_candidate.second, &std::pair::second) == 1 ? best_candidate.first : std::numeric_limits::max(); } -#pragma warning( suppress : 26497) +#pragma warning(suppress : 26497) template void call_next_node(std::integer_sequence, size_t next) { 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