module MultimediaParadise::GUI::ChangeMetadataWidgetModule
Constants
- ARRAY_SUPPORTED_VIDEO_FILES
#¶ ↑
ARRAY_SUPPORTED_VIDEO_FILES
¶ ↑List all supported video files here in this array.
#¶ ↑
- HEIGHT
#¶ ↑
HEIGHT
¶ ↑#¶ ↑
- SMALLER_FONT
#¶ ↑
SMALLER_FONT
¶ ↑#¶ ↑
- TITLE
#¶ ↑
TITLE
¶ ↑#¶ ↑
- USE_THIS_FONT
#¶ ↑
USE_THIS_FONT
¶ ↑#¶ ↑
- WIDTH
#¶ ↑
WIDTH
¶ ↑#¶ ↑
Public Instance Methods
border_size?()
click to toggle source
clear_the_old_entries()
click to toggle source
create_skeleton()
click to toggle source
create_the_entries()
click to toggle source
#¶ ↑
create_the_entries
(entries tag, entry tag)¶ ↑
#¶ ↑
# File lib/multimedia_paradise/gui/shared_code/change_metadata_widget/change_metadata_widget_module.rb, line 421 def create_the_entries # ======================================================================= # # === @entry_input_file # ======================================================================= # @entry_input_file = entry('foobar.mp4') @entry_input_file.width_height(600, 30) @entry_input_file.very_light_yellowish_background @entry_input_file.use_this_font = SMALLER_FONT @entry_input_file.enable_scroll_events # ======================================================================= # # === @entry_output_file # ======================================================================= # @entry_output_file = entry(File.absolute_path('output.mp4')) @entry_output_file.width_height(600, 30) @entry_output_file.very_light_yellowish_background @entry_output_file.use_this_font = SMALLER_FONT # ======================================================================= # # === @entry_title # ======================================================================= # @entry_title = entry @entry_title.width_height(600, 30) @entry_title.very_light_yellowish_background @entry_title.use_this_font = SMALLER_FONT # ======================================================================= # # === @entry_comment # ======================================================================= # @entry_comment = entry @entry_comment.width_height(600, 30) @entry_comment.very_light_yellowish_background @entry_comment.use_this_font = SMALLER_FONT # ======================================================================= # # === @entry_year # ======================================================================= # @entry_year = entry @entry_year.width_height(600, 30) @entry_year.very_light_yellowish_background @entry_year.use_this_font = SMALLER_FONT end
create_the_grid()
click to toggle source
#¶ ↑
create_the_grid
(grid tag)¶ ↑
#¶ ↑
# File lib/multimedia_paradise/gui/shared_code/change_metadata_widget/change_metadata_widget_module.rb, line 134 def create_the_grid # ======================================================================= # # === @grid # ======================================================================= # @grid = default_grid end
create_the_header()
click to toggle source
#¶ ↑
create_the_header
(header tag)¶ ↑
#¶ ↑
# File lib/multimedia_paradise/gui/shared_code/change_metadata_widget/change_metadata_widget_module.rb, line 300 def create_the_header # ======================================================================= # # === @header # ======================================================================= # @header = default_header @header.set_title('Change Metadata') button_open_file = button('Open file') button_open_file.on_clicked { do_open_a_local_file } @header.add_right(button_open_file) icon = gtk_icon('media-playback-start') button_play_the_video = event_box(icon) button_play_the_video.hint = 'Play the video file listed under '\ '"Input file to use:".' button_play_the_video.on_clicked { Thread.new { esystem "mpv #{work_on_which_file?}" } } @header.add_left(button_play_the_video) end
create_the_spinner()
click to toggle source
default_output_file?()
click to toggle source
do_analyse_this_file(i)
click to toggle source
#¶ ↑
do_analyse_this_file
(open tag)¶ ↑
#¶ ↑
# File lib/multimedia_paradise/gui/shared_code/change_metadata_widget/change_metadata_widget_module.rb, line 463 def do_analyse_this_file(i) @entry_input_file.set_text(i) read_the_title_and_then_assign_it read_the_comment_and_then_assign_it if is_on_roebe? old_value = @entry_output_file.text?.dup original_filename = File.basename(i).delete_suffix(File.extname(i)) old_value.delete_suffix!(File.extname(old_value)) old_value.sub!(/output/, '') old_value << "#{original_filename}_output#{File.extname(i)}" @entry_output_file.set_text(old_value) # ===================================================================== # # We may also infer the title if the entry is empty. # ===================================================================== # if entry_title? and entry_title?.empty? new_name = File.basename(input_file_name?).delete_suffix( File.extname(i) ) if new_name.include?('_') and (new_name =~ /^\d+/) splitted = new_name.split('_') new_name = splitted[1 .. -1].join('_') end new_name.tr!('_',' ') entry_title?.set_text(new_name) end end end
Also aliased as: do_open_this_file, work_on_this_file_now
do_open_a_local_file()
click to toggle source
#¶ ↑
do_open_a_local_file
(open tag)¶ ↑
#¶ ↑
# File lib/multimedia_paradise/gui/shared_code/change_metadata_widget/change_metadata_widget_module.rb, line 393 def do_open_a_local_file new_open_file_dialog {{ name_for_the_file_chooser_dialog: :custom_dialog, use_this_as_the_current_folder: return_pwd, filter_for: ARRAY_SUPPORTED_VIDEO_FILES, additional_folders: %w( /Depot/j/ /home/x/video/Realvids/ ) }} _ = main_file? if _ and File.exist?(_) # ===================================================================== # # First, clear the old entries that contain meta-data. # ===================================================================== # clear_the_old_entries # ===================================================================== # # Next proceed by analysing the file. # ===================================================================== # do_analyse_this_file(_) sync_the_output_directory_based_on_this_file(_) end end
do_rename_the_newly_created_file_to_the_original_file()
click to toggle source
#¶ ↑
do_rename_the_newly_created_file_to_the_original_file
¶ ↑
#¶ ↑
# File lib/multimedia_paradise/gui/shared_code/change_metadata_widget/change_metadata_widget_module.rb, line 213 def do_rename_the_newly_created_file_to_the_original_file newly_created_file = @entry_output_file.text? original_file = @entry_input_file.text? unless is_still_spinning? if File.exist? newly_created_file FileUtils.mv(newly_created_file, original_file) end end end
entry2?()
click to toggle source
entry_comment?()
click to toggle source
entry_input?()
click to toggle source
entry_title?()
click to toggle source
entry_year?()
click to toggle source
#¶ ↑
entry_year?¶ ↑
#¶ ↑
# File lib/multimedia_paradise/gui/shared_code/change_metadata_widget/change_metadata_widget_module.rb, line 375 def entry_year? @entry_year end
Also aliased as: entry5?
input_file_name?()
click to toggle source
#¶ ↑
input_file_name?¶ ↑
#¶ ↑
# File lib/multimedia_paradise/gui/shared_code/change_metadata_widget/change_metadata_widget_module.rb, line 292 def input_file_name? @entry_input_file.text? end
Also aliased as: work_on_which_file?, file?
is_still_spinning?()
click to toggle source
log_dir?()
click to toggle source
log_this_file_has_been_modified(this_file)
click to toggle source
#¶ ↑
log_this_file_has_been_modified
(log tag)¶ ↑
This method will log which file has been modified. Knowing this information is helpful when we want to copy only those video files that were modified.
What information must we save?
The file name, as well as the time when the file was modified.
#¶ ↑
# File lib/multimedia_paradise/gui/shared_code/change_metadata_widget/change_metadata_widget_module.rb, line 248 def log_this_file_has_been_modified(this_file) what = this_file.dup what << ' # '+dd_mm_yyyy?+' '+hh_mm_ss? into = log_dir?+'metadata_of_video_files_that_were_modified.md' if File.exist? into what.prepend(File.read(into)) end if is_on_roebe? e "Storing log-information into the file "\ "at `#{sfile(into)}`." end write_what_into("#{what}\n", into) end
padding?()
click to toggle source
read_the_comment_and_then_assign_it()
click to toggle source
#¶ ↑
read_the_comment_and_then_assign_it
¶ ↑
#¶ ↑
# File lib/multimedia_paradise/gui/shared_code/change_metadata_widget/change_metadata_widget_module.rb, line 265 def read_the_comment_and_then_assign_it _ = file? result_from_exiftool = `exiftool #{_}` begin if result_from_exiftool.include? 'Comment' current_comment = result_from_exiftool.split("\n").select {|entry| entry.include? 'Comment' }.flatten.first.sub(/Comment/,'').strip.delete(':').strip @entry_comment.set_text(current_comment) end rescue ArgumentError => error pp error end end
read_the_title_and_then_assign_it()
click to toggle source
#¶ ↑
read_the_title_and_then_assign_it
¶ ↑
#¶ ↑
# File lib/multimedia_paradise/gui/shared_code/change_metadata_widget/change_metadata_widget_module.rb, line 179 def read_the_title_and_then_assign_it _ = file? result_from_exiftool = `exiftool #{_}` if result_from_exiftool.include? 'Title' begin splitted = result_from_exiftool.split("\n") current_title = splitted.select {|entry| entry.include? 'Title' }.flatten.first.sub(/Title/,'').strip.delete(':').strip entry_title?.set_text(current_title) rescue ArgumentError => error pp error end end end
respond_to_scroll_events_of_the_first_entry()
click to toggle source
#¶ ↑
respond_to_scroll_events_of_the_first_entry
¶ ↑
#¶ ↑
# File lib/multimedia_paradise/gui/shared_code/change_metadata_widget/change_metadata_widget_module.rb, line 521 def respond_to_scroll_events_of_the_first_entry @entry_input_file.on_scroll_event {|widget, event| # ===================================================================== # # If the user scrolls then a new random file will be selected. # ===================================================================== # base_dir = File.dirname( File.absolute_path(@entry_input_file.text?) )+'/' this_new_file = Dir["#{base_dir}*"].select {|entry| ARRAY_SUPPORTED_VIDEO_FILES.include?(File.extname(entry).delete('.')) }.sample clear_the_old_entries work_on_this_file_now(this_new_file) sync_the_output_directory_based_on_this_file(this_new_file) } end
return_spinner_widget()
click to toggle source
return_text1()
click to toggle source
return_text2()
click to toggle source
return_text3()
click to toggle source
return_text4()
click to toggle source
return_text5()
click to toggle source
set_output_file_to_use(i)
click to toggle source
sync_the_output_directory_based_on_this_file(_)
click to toggle source
#¶ ↑
sync_the_output_directory_based_on_this_file
¶ ↑
#¶ ↑
# File lib/multimedia_paradise/gui/shared_code/change_metadata_widget/change_metadata_widget_module.rb, line 504 def sync_the_output_directory_based_on_this_file(_) # ======================================================================= # # Sync the output directory too: # ======================================================================= # base_dir = File.dirname(_) new_filename = File.basename(_).dup new_filename.delete_suffix!(File.extname(new_filename)) new_filename.sub!(/output/, '') new_filename = "#{new_filename}_output#{File.extname(_)}" # This will be like "004_Cube_output.avi" set_output_file_to_use("#{base_dir}/#{new_filename}") end