Class: MkvToolNix::Modules::MkvPropEdit
- Inherits:
-
Object
- Object
- MkvToolNix::Modules::MkvPropEdit
- Includes:
- MkvModule
- Defined in:
- lib/mkvtoolnix/modules/mkvpropedit.rb
Overview
Instance Attribute Summary collapse
-
#abort_at_warning ⇒ Object
writeonly
Sets the attribute abort_at_warning.
-
#disable_language_ietf ⇒ Object
writeonly
Sets the attribute disable_language_ietf.
Instance Method Summary collapse
-
#add_attachment(file, attachment_file, name = nil, description = nil, uid = nil, mime_type = nil, full_parse_mode: false) ⇒ Object
adds an attachment to the mkv file.
-
#add_track_statistics_tags(file, full_parse_mode: false) ⇒ Object
calculates and adds the statistics tags.
-
#delete_track_statistics_tags(file, full_parse_mode: false) ⇒ Object
deletes the track statistics tags.
-
#initialize(bin_path) ⇒ MkvPropEdit
constructor
A new instance of MkvPropEdit.
-
#remove_attachment(file, selector, full_parse_mode: false) ⇒ Object
removes an attachment of the mkv file.
-
#remove_property(file, selector, properties, full_parse_mode: false) ⇒ Object
removes a property from the mkv file.
-
#replace_attachment(file, selector, attachment_file, name = nil, description = nil, uid = nil, mime_type = nil, full_parse_mode: false) ⇒ Object
replaces an attachment of the mkv file.
-
#set_chapters(file, chapter_file, full_parse_mode: false) ⇒ Object
adds or replaces the given chapter file to the given mkv file.
-
#set_property(file, selector, property, value, full_parse_mode: false) ⇒ Object
sets a property to the mkv file.
-
#set_tags(file, tag_file, selector, full_parse_mode: false) ⇒ Object
sets the given tags to the tag field matching the given selector.
-
#update_attachment(file, selector, name = nil, description = nil, uid = nil, mime_type = nil, full_parse_mode: false) ⇒ Object
updates an attachment of the mkv file.
-
#version ⇒ Object
returns the mkvpropedit version.
Methods included from MkvModule
Constructor Details
#initialize(bin_path) ⇒ MkvPropEdit
Returns a new instance of MkvPropEdit.
11 12 13 14 15 |
# File 'lib/mkvtoolnix/modules/mkvpropedit.rb', line 11 def initialize(bin_path) @bin_path = "#{bin_path}mkvpropedit" @abort_at_warning = false @disable_language_ietf = false end |
Instance Attribute Details
#abort_at_warning=(value) ⇒ Object (writeonly)
Sets the attribute abort_at_warning
9 10 11 |
# File 'lib/mkvtoolnix/modules/mkvpropedit.rb', line 9 def abort_at_warning=(value) @abort_at_warning = value end |
#disable_language_ietf=(value) ⇒ Object (writeonly)
Sets the attribute disable_language_ietf
9 10 11 |
# File 'lib/mkvtoolnix/modules/mkvpropedit.rb', line 9 def disable_language_ietf=(value) @disable_language_ietf = value end |
Instance Method Details
#add_attachment(file, attachment_file, name = nil, description = nil, uid = nil, mime_type = nil, full_parse_mode: false) ⇒ Object
adds an attachment to the mkv file
143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/mkvtoolnix/modules/mkvpropedit.rb', line 143 def (file, , name = nil, description = nil, uid = nil, mime_type = nil, full_parse_mode: false) cmd = [@bin_path] (cmd, full_parse_mode) cmd << file cmd << '--attachment-name' << name unless name.nil? cmd << '--attachment-description' << description unless description.nil? cmd << '--attachment-mime-type' << mime_type unless mime_type.nil? cmd << '--attachment-uid' << uid unless uid.nil? cmd << '--add-attachment' << call_cmd(cmd) end |
#add_track_statistics_tags(file, full_parse_mode: false) ⇒ Object
calculates and adds the statistics tags
46 47 48 49 50 51 52 53 |
# File 'lib/mkvtoolnix/modules/mkvpropedit.rb', line 46 def (file, full_parse_mode: false) cmd = [@bin_path] (cmd, full_parse_mode) cmd << file cmd << '--add-track-statistics-tags' call_cmd(cmd) end |
#delete_track_statistics_tags(file, full_parse_mode: false) ⇒ Object
deletes the track statistics tags
32 33 34 35 36 37 38 39 40 |
# File 'lib/mkvtoolnix/modules/mkvpropedit.rb', line 32 def (file, full_parse_mode: false) cmd = [@bin_path] cmd << '--parse-mode' << 'full' if full_parse_mode cmd << '--abort-on-warnings' if @abort_at_warning cmd << file cmd << '--delete-track-statistics-tags' call_cmd(cmd) end |
#remove_attachment(file, selector, full_parse_mode: false) ⇒ Object
removes an attachment of the mkv file
187 188 189 190 191 192 193 194 |
# File 'lib/mkvtoolnix/modules/mkvpropedit.rb', line 187 def (file, selector, full_parse_mode: false) cmd = [@bin_path] (cmd, full_parse_mode) cmd << file cmd << '--delete-attachment' << selector call_cmd(cmd) end |
#remove_property(file, selector, properties, full_parse_mode: false) ⇒ Object
removes a property from the mkv file
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/mkvtoolnix/modules/mkvpropedit.rb', line 95 def remove_property(file, selector, properties, full_parse_mode: false) props = properties.map { |it| it.is_a?(Types::PropEdit::Property) ? it : find_property(it) } cmd = [@bin_path] (cmd, full_parse_mode) cmd << file cmd << '--edit' cmd << selector props.each do |prop| raise Errors::MkvToolNixError, "Property is not removable: #{prop.property}" unless prop.removable cmd << '--delete' cmd << prop.property end call_cmd(cmd) end |
#replace_attachment(file, selector, attachment_file, name = nil, description = nil, uid = nil, mime_type = nil, full_parse_mode: false) ⇒ Object
replaces an attachment of the mkv file
168 169 170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/mkvtoolnix/modules/mkvpropedit.rb', line 168 def (file, selector, , name = nil, description = nil, uid = nil, mime_type = nil, full_parse_mode: false) cmd = [@bin_path] (cmd, full_parse_mode) cmd << file cmd << '--attachment-name' << name unless name.nil? cmd << '--attachment-description' << description unless description.nil? cmd << '--attachment-mime-type' << mime_type unless mime_type.nil? cmd << '--attachment-uid' << uid unless uid.nil? cmd << '--replace-attachment' << "#{selector}:#{}" call_cmd(cmd) end |
#set_chapters(file, chapter_file, full_parse_mode: false) ⇒ Object
adds or replaces the given chapter file to the given mkv file. If the chapter file is empty (valid xml file, but the <chapter/> tag is empty), it removes the chapters from the mkv file
61 62 63 64 65 66 67 68 69 |
# File 'lib/mkvtoolnix/modules/mkvpropedit.rb', line 61 def set_chapters(file, chapter_file, full_parse_mode: false) cmd = [@bin_path] (cmd, full_parse_mode) cmd << file cmd << '--chapters' cmd << chapter_file call_cmd(cmd) end |
#set_property(file, selector, property, value, full_parse_mode: false) ⇒ Object
sets a property to the mkv file
120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/mkvtoolnix/modules/mkvpropedit.rb', line 120 def set_property(file, selector, property, value, full_parse_mode: false) prop = property.is_a?(Types::PropEdit::Property) ? property : find_property(property) cmd = [@bin_path] (cmd, full_parse_mode) cmd << file cmd << '--edit' cmd << selector cmd << '--set' # noinspection RubyNilAnalysis cmd << "#{prop.property}=#{value}" call_cmd(cmd) end |
#set_tags(file, tag_file, selector, full_parse_mode: false) ⇒ Object
sets the given tags to the tag field matching the given selector. A selector can either be all, global or for a specific track.
78 79 80 81 82 83 84 85 86 |
# File 'lib/mkvtoolnix/modules/mkvpropedit.rb', line 78 def (file, tag_file, selector, full_parse_mode: false) cmd = [@bin_path] (cmd, full_parse_mode) cmd << file cmd << '--tags' cmd << "#{selector}:#{tag_file}" call_cmd(cmd) end |
#update_attachment(file, selector, name = nil, description = nil, uid = nil, mime_type = nil, full_parse_mode: false) ⇒ Object
updates an attachment of the mkv file
205 206 207 208 209 210 211 212 213 214 215 216 217 |
# File 'lib/mkvtoolnix/modules/mkvpropedit.rb', line 205 def (file, selector, name = nil, description = nil, uid = nil, mime_type = nil, full_parse_mode: false) cmd = [@bin_path] (cmd, full_parse_mode) cmd << file cmd << '--attachment-name' << name unless name.nil? cmd << '--attachment-description' << description unless description.nil? cmd << '--attachment-mime-type' << mime_type unless mime_type.nil? cmd << '--attachment-uid' << uid unless uid.nil? cmd << '--update-attachment' << selector call_cmd(cmd) end |
#version ⇒ Object
returns the mkvpropedit version
return [String] the version string
20 21 22 23 24 25 26 |
# File 'lib/mkvtoolnix/modules/mkvpropedit.rb', line 20 def version cmd = [@bin_path, '-V'] result = call_cmd(cmd) result.stdout.strip end |