propedit: add option for specifying chapter charset when reading chapters

Implements #3276.
This commit is contained in:
Moritz Bunkus 2022-03-05 12:50:32 +01:00
parent c8cf655933
commit ebad8afc7b
No known key found for this signature in database
GPG Key ID: 74AF00ADF2E32C85
7 changed files with 21 additions and 5 deletions

View File

@ -1,5 +1,11 @@
# Version ?
## New features and enhancements
* mkvpropedit: added a new option `--chapter-charset` allowing the user to
specify the character set to use when reading the following chapter
file. Implements #3276.
## Bug fixes
* MKVToolNix GUI: multiplexer: fixed several issues with the tab order of

View File

@ -35,7 +35,7 @@ chapter_target_c::operator ==(target_c const &cmp)
void
chapter_target_c::validate() {
if (!m_file_name.empty() && !m_new_chapters)
m_new_chapters = mtx::chapters::parse(m_file_name);
m_new_chapters = mtx::chapters::parse(m_file_name, 0, -1, 0, {}, m_charset);
}
void
@ -53,8 +53,10 @@ chapter_target_c::has_changes()
}
void
chapter_target_c::parse_chapter_spec(std::string const &spec) {
chapter_target_c::parse_chapter_spec(std::string const &spec,
std::string const &charset) {
m_file_name = spec;
m_charset = charset;
}
void

View File

@ -18,6 +18,7 @@
class chapter_target_c: public target_c {
protected:
mtx::chapters::kax_cptr m_new_chapters;
std::string m_charset;
public:
chapter_target_c();
@ -27,7 +28,7 @@ public:
virtual bool operator ==(target_c const &cmp) const override;
virtual void parse_chapter_spec(const std::string &spec);
virtual void parse_chapter_spec(std::string const &spec, std::string const &charset);
virtual void dump_info() const override;
virtual bool has_changes() const override;

View File

@ -106,7 +106,7 @@ options_c::add_tags(std::string const &spec) {
void
options_c::add_chapters(const std::string &spec) {
target_cptr target{new chapter_target_c{}};
static_cast<chapter_target_c *>(target.get())->parse_chapter_spec(spec);
static_cast<chapter_target_c *>(target.get())->parse_chapter_spec(spec, m_chapter_charset);
m_targets.push_back(target);
}

View File

@ -20,7 +20,7 @@
class options_c {
public:
std::string m_file_name;
std::string m_file_name, m_chapter_charset;
std::vector<target_cptr> m_targets;
bool m_show_progress;
kax_analyzer_c::parse_mode_e m_parse_mode;

View File

@ -69,6 +69,11 @@ propedit_cli_parser_c::add_tags() {
}
}
void
propedit_cli_parser_c::set_chapter_charset() {
m_options->m_chapter_charset = m_next_arg;
}
void
propedit_cli_parser_c::add_chapters() {
try {
@ -225,6 +230,7 @@ propedit_cli_parser_c::init_parser() {
add_section_header(YT("Actions for handling tags and chapters"));
add_option("t|tags=<selector:filename>", std::bind(&propedit_cli_parser_c::add_tags, this), YT("Add or replace tags in the file with the ones from 'filename' or remove them if 'filename' is empty (see below and man page for syntax)"));
add_option("c|chapters=<filename>", std::bind(&propedit_cli_parser_c::add_chapters, this), YT("Add or replace chapters in the file with the ones from 'filename' or remove them if 'filename' is empty"));
add_option("chapter-charset=<charset>", std::bind(&propedit_cli_parser_c::set_chapter_charset, this), YT("Set the charset to use when reading chapter files using the simple chapter format"));
add_option("add-track-statistics-tags", std::bind(&propedit_cli_parser_c::handle_track_statistics_tags, this), YT("Calculate statistics for all tracks and add new/update existing tags for them"));
add_option("delete-track-statistics-tags", std::bind(&propedit_cli_parser_c::handle_track_statistics_tags, this), YT("Delete all existing track statistics tags"));

View File

@ -35,6 +35,7 @@ protected:
void add_change();
void add_tags();
void add_chapters();
void set_chapter_charset();
void set_parse_mode();
void set_file_name();
void disable_language_ietf();