Class: MultimediaParadise::Video::CheckNumbers
- Inherits:
-
Base
- Object
- Base
- MultimediaParadise::Video::CheckNumbers
show all
- Defined in:
- lib/multimedia_paradise/video/check_numbers.rb
Overview
Constant Summary
collapse
- N_PAD =
45
- DATASET_CONTAINING_ALL_VIDEOS =
{}
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
Class Method Summary
collapse
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, #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, #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(check_this_entity = return_pwd, run_already = true) ⇒ CheckNumbers
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/multimedia_paradise/video/check_numbers.rb', line 50
def initialize(
check_this_entity = return_pwd,
run_already = true
)
reset
if block_given?
yielded = yield
case yielded
when :do_not_use_opn
@do_use_opn = false
end
end
set_check_this_entity(check_this_entity)
run if run_already
end
|
Class Method Details
.[](i = ARGV) ⇒ Object
242
243
244
|
# File 'lib/multimedia_paradise/video/check_numbers.rb', line 242
def self.[](i = ARGV)
new(i)
end
|
Instance Method Details
#check_this_entity? ⇒ Boolean
Also known as:
entity?
109
110
111
|
# File 'lib/multimedia_paradise/video/check_numbers.rb', line 109
def check_this_entity?
@check_this_entity
end
|
#check_whether_this_file_is_included(i, n_pad = N_PAD) ⇒ Object
#
check_whether_this_file_is_included
#
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
|
# File 'lib/multimedia_paradise/video/check_numbers.rb', line 187
def check_whether_this_file_is_included(
i,
n_pad = N_PAD
)
i = File.basename(i) if i.include? '/'
if i.include? '_VHS-RIP'
i.sub!(/_VHS-RIP/,'')
end
if i.include? '_' dataset = dataset?
splitted = i.split('_')
position = splitted.first.to_i
if dataset.has_key? position
title = dataset[position]['title']
compact_title = title.delete(" ':,") if i.delete('_').include? compact_title
yes_is_included_at_position(i, position, n_pad)
else no_is_NOT_included_at_position(i, position, n_pad)
e '---'
pp i
pp compact_title
e '---'
exit
end
else
opne swarn('The position ')+sfancy(position)+swarn(' was not found in '\
'the dataset.')+' This is the input `'+simp(i)+'`.'
opne 'Perhaps it can be deleted.'
exit end
end
end
|
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
# File 'lib/multimedia_paradise/video/check_numbers.rb', line 123
def handle_given_input
_ = entity?
if File.directory? _
these_video_files = select_only_video_files_from(Dir[_+'*'])
these_video_files.map! {|entry| File.basename(entry) }
these_video_files = these_video_files.sort_by {|entry|
first_number_part = entry.split('_').first.to_i
first_number_part
}
these_video_files.each {|entry|
check_whether_this_file_is_included(entry)
}
e
opne steelblue('All ')+
simp(these_video_files.size.to_s)+
steelblue(" videos are correct from the names alone, at the least.")
e
elsif File.file? _
check_whether_this_file_is_included(_)
else
opne rev+'No idea how to proceed with '+simp(_)+rev+'.'
unless File.exist? _
opne 'The input does not exist. Perhaps you have'
opne 'misspelled the name?'
end
end
end
|
#no_is_NOT_included_at_position(i, position, n_pad) ⇒ Object
#
no_is_NOT_included_at_position
#
178
179
180
181
182
|
# File 'lib/multimedia_paradise/video/check_numbers.rb', line 178
def no_is_NOT_included_at_position(i, position, n_pad)
opne "#{rev} No, #{sfancy(i.ljust(n_pad))}#{rev} is #{swarn('NOT')} "\
"#{rev}included. The position is "\
"#{simp(position.to_s.rjust(3))}#{rev}."
end
|
#opnn ⇒ Object
228
229
230
|
# File 'lib/multimedia_paradise/video/check_numbers.rb', line 228
def opnn
super(namespace?) if @do_use_opn
end
|
#reset ⇒ Object
75
76
77
78
79
80
|
# File 'lib/multimedia_paradise/video/check_numbers.rb', line 75
def reset
super()
infer_the_namespace
@do_use_opn = true
end
|
#run ⇒ Object
235
236
237
|
# File 'lib/multimedia_paradise/video/check_numbers.rb', line 235
def run
handle_given_input
end
|
#select_only_video_files_from(array) ⇒ Object
#
select_only_video_files_from
#
116
117
118
|
# File 'lib/multimedia_paradise/video/check_numbers.rb', line 116
def select_only_video_files_from(array)
array.select {|entry| is_video_file? entry }
end
|
#set_check_this_entity(i = :default) ⇒ Object
#
set_check_this_entity
The “entity” can be either a directory or a file.
#
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
# File 'lib/multimedia_paradise/video/check_numbers.rb', line 87
def set_check_this_entity(i = :default)
i = i.first if i.is_a? Array
if i.nil? and is_on_roebe?
i = :default
end
case i
when :default
i = '/home/x/video/realvids/'
end
i = i.to_s.dup
if File.directory? i
i << '/' unless i.end_with? '/'
end
@check_this_entity = i
end
|
#yes_is_included_at_position(i, position, n_pad = N_PAD) ⇒ Object
#
yes_is_included_at_position
#
170
171
172
173
|
# File 'lib/multimedia_paradise/video/check_numbers.rb', line 170
def yes_is_included_at_position(i, position, n_pad = N_PAD)
opne "#{rev}Yes, #{sfancy(i.ljust(n_pad))}#{rev} is included. The "\
"position is #{simp(position.to_s.rjust(3))}#{rev}."
end
|