Skip to content

Commit

Permalink
movie info show date as YYYY add col orig_lang
Browse files Browse the repository at this point in the history
  • Loading branch information
Kai Lepper committed Nov 10, 2021
1 parent a9d831e commit ca17640
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 132 deletions.
4 changes: 2 additions & 2 deletions show.sln
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 6 additions & 1 deletion show/curl_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@
#include <gsl/gsl-lite.hpp>
#include <curl/curl.h>

#ifdef WIN32





#ifdef CURL_WIN32
constexpr bool WINDOWS {true};
#elif
constexpr bool WINDOWS {false};
Expand Down
1 change: 1 addition & 0 deletions show/lang.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
114 changes: 0 additions & 114 deletions show/show.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,6 @@
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
Expand All @@ -43,23 +35,6 @@
<EnableASAN>
</EnableASAN>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<EnableASAN>
</EnableASAN>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<EnableASAN>
</EnableASAN>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
Expand All @@ -71,12 +46,6 @@
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
Expand All @@ -96,24 +65,6 @@
<EnableMicrosoftCodeAnalysis>
</EnableMicrosoftCodeAnalysis>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<RunCodeAnalysis>
</RunCodeAnalysis>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<EnableClangTidyCodeAnalysis>true</EnableClangTidyCodeAnalysis>
<EnableMicrosoftCodeAnalysis>
</EnableMicrosoftCodeAnalysis>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<RunCodeAnalysis>
</RunCodeAnalysis>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<EnableClangTidyCodeAnalysis>true</EnableClangTidyCodeAnalysis>
<EnableMicrosoftCodeAnalysis>
</EnableMicrosoftCodeAnalysis>
</PropertyGroup>
<PropertyGroup Label="Vcpkg" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<VcpkgUseStatic>
</VcpkgUseStatic>
Expand All @@ -122,14 +73,6 @@
<VcpkgUseStatic>
</VcpkgUseStatic>
</PropertyGroup>
<PropertyGroup Label="Vcpkg" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<VcpkgUseStatic>
</VcpkgUseStatic>
</PropertyGroup>
<PropertyGroup Label="Vcpkg" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<VcpkgUseStatic>
</VcpkgUseStatic>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level4</WarningLevel>
Expand Down Expand Up @@ -189,63 +132,6 @@
<LinkStatus>true</LinkStatus>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level4</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpplatest</LanguageStandard>
<EnableModules>false</EnableModules>
<ExternalWarningLevel>TurnOffAllWarnings</ExternalWarningLevel>
<DisableAnalyzeExternal>true</DisableAnalyzeExternal>
<TreatAngleIncludeAsExternal>true</TreatAngleIncludeAsExternal>
<ExceptionHandling>Sync</ExceptionHandling>
<AnalyzeExternalRuleset>NativeMinimumRules.ruleset</AnalyzeExternalRuleset>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<TreatWarningAsError>
</TreatWarningAsError>
<DisableLanguageExtensions>
</DisableLanguageExtensions>
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>DebugFastLink</GenerateDebugInformation>
<LinkStatus>true</LinkStatus>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level4</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpplatest</LanguageStandard>
<EnableModules>false</EnableModules>
<ExternalWarningLevel>TurnOffAllWarnings</ExternalWarningLevel>
<DisableAnalyzeExternal>true</DisableAnalyzeExternal>
<TreatAngleIncludeAsExternal>true</TreatAngleIncludeAsExternal>
<ExceptionHandling>Sync</ExceptionHandling>
<AnalyzeExternalRuleset>NativeMinimumRules.ruleset</AnalyzeExternalRuleset>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<TreatWarningAsError>
</TreatWarningAsError>
<DisableLanguageExtensions>
</DisableLanguageExtensions>
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<LinkStatus>true</LinkStatus>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="cache.cpp" />
<ClCompile Include="curl_wrapper.cpp" />
Expand Down
12 changes: 12 additions & 0 deletions show/tmdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions show/tmdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ struct Movie
std::string const url;
void parse(boost::json::standalone::value const& json);

std::vector<std::pair<std::string, std::string>> 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 {};
Expand Down
12 changes: 9 additions & 3 deletions show/tree_movie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -53,7 +59,7 @@ void Movie_by_id::func()

auto const movie {tmdb::factory<tmdb::Movie>(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;
Expand Down
26 changes: 17 additions & 9 deletions show/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ std::unique_ptr<util::Args> 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)
Expand All @@ -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;
}
4 changes: 1 addition & 3 deletions show/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
#include <string>
#include <string_view>


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
{
Expand All @@ -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
Expand Down

0 comments on commit ca17640

Please sign in to comment.