Class: MultimediaParadise::SrtRegex
- Inherits:
-
Base
- Object
- Base
- MultimediaParadise::SrtRegex
show all
- Defined in:
- lib/multimedia_paradise/video/srt_regex.rb
Overview
Constant Summary
collapse
- SHALL_WE_DEBUG =
false
- ARROW =
'-->'
- THIS_FILE =
MultimediaParadise.project_base_dir+'video/srt_regex.rb'
- MODIFIER_IN_MS =
#
MODIFIER_IN_MS
Here, specify how many ms we shall add to our new .srt file Because it is in milliseconds, append 1000 to it, in order to know how many seconds you must add. So for example, 30.000 milliseconds means that we have 30 seconds.
#
5_057
Constants inherited
from Base
Base::ERROR, Base::ERROR_LINE, Base::NAMESPACE, Base::USE_THIS_NAMESPACE_FOR_THE_COLOURS, Base::USE_THIS_NAMESPACE_FOR_THE_CORE_COLOURS
Instance Method Summary
collapse
Methods inherited from Base
[], #actions, #append_what_into, #be_silent, #be_verbose?, #beautiful_url, #cartoons_directory?, #clear_the_internal_hash, #cliner, #cliner_with_time_stamp, #colourized_comment, #copy_file, #crimson, #dataset_from_file_video_collection, #dd_mm_yyyy, #debug?, #default_readlines, #directory_to_realvids?, #do_not_use_opn, #dodgerblue, #does_the_video_player_support_this_commandline?, #e, #ecomment, #ecrimson, #efancy, #enable_debug, #ensure_main_encoding, #ensure_that_the_output_directory_exists, #eparse, #erev, #esystem, #ewarn, #file_video_collection?, #filter_for_audio_files, #filter_for_video_files, #forestgreen, #gold, #grey, #hh_mm_ss, #home_x_video?, #indianred, #infer_the_namespace, #internal_hash?, #is_audio_file?, #is_mkv?, #is_mp3?, #is_mp4?, #is_multimedia_file?, #is_on_roebe?, #is_video_file?, #konsole_colour_peru, #lightblue, #lightgreen, #load_yaml, #local_audio_directory?, #log_dir?, #map_symbol_to_locally_existing_file, #mediumorchid, #mediumpurple, #mediumslateblue, #mkdir, #move_file, #namespace?, #no_file_exists, #no_file_exists_at, #olive, #olivedrab, #opne, #opnecomment, #opnn, #orange, #palegoldenrod, #palegreen, #powderblue, #project_base_directory?, #rds, #register_sigint, #remove_file, #report_pwd, #reset_the_internal_hash, #return_all_video_files, #return_pwd, #return_random_video, #rev, #royalblue, #save_what_into, #sdir, #seagreen, #seconds_to_time_format, #select_only_video_files_from, #set_be_verbose, #set_use_colours, #sfancy, #sfile, #simp, #skyblue, #slateblue, #springgreen, #steelblue, #swarn, #teal, #time_right_now, #to_hh_mm_ss, #tomato, #true_rev, #try_to_rename_kde_konsole_tab, #ucliner, #use_colours?, #use_opn?, #use_which_video_player?, #verbose_truth, #video_collection?, #violet, #yaml_directory?, #yel
#all_input_starts_with_a_number?, #commandline_arguments?, #commandline_arguments_as_a_string, #first_argument?, #first_non_hyphened_commandline_argument?, #set_commandline_arguments
Constructor Details
#initialize(i = nil, run_already = true) ⇒ SrtRegex
68
69
70
71
72
73
74
75
|
# File 'lib/multimedia_paradise/video/srt_regex.rb', line 68
def initialize(
i = nil,
run_already = true
)
reset
set_input(i)
run if run_already
end
|
Instance Method Details
#clear_new_dataset ⇒ Object
91
92
93
|
# File 'lib/multimedia_paradise/video/srt_regex.rb', line 91
def clear_new_dataset
@new_dataset = []
end
|
#create_new_file ⇒ Object
#
create_new_file
This method will create a new file, with the name being prepended to “NEW_”.
#
190
191
192
193
194
195
|
# File 'lib/multimedia_paradise/video/srt_regex.rb', line 190
def create_new_file
_ = 'NEW_'+@input
_ = @input if @shall_we_overwrite
e 'We will create a new file `'+sfile(_)+'`.'
save_file(@new_dataset, _)
end
|
#read_in_file ⇒ Object
152
153
154
|
# File 'lib/multimedia_paradise/video/srt_regex.rb', line 152
def read_in_file
@dataset = File.readlines(@input)
end
|
#reset ⇒ Object
80
81
82
83
84
85
86
|
# File 'lib/multimedia_paradise/video/srt_regex.rb', line 80
def reset
super()
clear_new_dataset
@modifier_in_ms = MODIFIER_IN_MS
@debug = SHALL_WE_DEBUG
@shall_we_overwrite = false
end
|
#run ⇒ Object
200
201
202
203
204
|
# File 'lib/multimedia_paradise/video/srt_regex.rb', line 200
def run
read_in_file
process_file
create_new_file
end
|
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
# File 'lib/multimedia_paradise/video/srt_regex.rb', line 98
def set_input(i = nil)
if i.empty?
i = try_to_find_srt_files_in_current_working_directory()
if i.empty?
e 'No arg given for '+sfile(__FILE__)+', exiting now.'
exit
end
end
if i.is_a? Array
if i[1]
@modifier_in_ms = i[1].to_f
end
@shall_we_overwrite = true if i[2] == 'OVERWRITE'
i = i.first
end
case i when 'HELP','help','--help'
show_help
exit
end
@input = i
end
|
#show_help ⇒ Object
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
# File 'lib/multimedia_paradise/video/srt_regex.rb', line 127
def show_help
opn; e 'How to use this class?'
e
e ' srtt *InfernalAff*.srt 7_250'
e ' srtt *InfernalAff*.srt 1_250 OVERWRITE'
e
if ENV['IS_ROEBE'].to_s == '1' _ = File.readlines(THIS_FILE).select {|entry| entry.start_with? '# rsub' }
_.each {|line|
line = line.gsub(/^# rsub/, 'srtt')
e ' '+line
}
end; e
end
|
#try_to_find_srt_files_in_current_working_directory ⇒ Object
#
try_to_find_srt_files_in_current_working_directory
#
145
146
147
|
# File 'lib/multimedia_paradise/video/srt_regex.rb', line 145
def try_to_find_srt_files_in_current_working_directory
return Dir['*.srt']
end
|