Class: Roebe::TalesFromTheCrypt
- Inherits:
-
Base
show all
- Defined in:
- lib/roebe/classes/tales_from_the_crypt.rb
Overview
Constant Summary
collapse
- YAML_FILE =
'/usr/lib/ruby/site_ruby/3.1.0/multimedia_paradise/yaml/tales_from_the_crypt/tales_from_the_crypt.yml'
- REMOTE_LOGO =
'https://i.imgur.com/vn3T36A.png'
- STORE_IN_THIS_FILE =
#
STORE_IN_THIS_FILE
Where to put this into. This is catering to my home setup.
#
'/home/x/programming/ruby/src/roebe/lib/roebe/www/tales_from_the_crypt/'\
'tales_from_the_crypt.html'
- LOCAL_DIRECTORY_TO_THE_TALES_FROM_THE_CRYPT_VIDEOS =
'/home/x/video/Tales_from_the_crypt/'
- MAIN_DIRECTORY =
LOCAL_DIRECTORY_TO_THE_TALES_FROM_THE_CRYPT_VIDEOS
Constants inherited
from Base
Base::COLOURS, Base::HOME_DIRECTORY_OF_USER_X, Base::N, Base::NAMESPACE
Class Method Summary
collapse
-
.[](i = ARGV) ⇒ Object
# === Roebe::TalesFromTheCrypt[] ========================================================================= #.
Instance Method Summary
collapse
Methods inherited from Base
#actions, #append_this_onto_that_file, #append_what_into, #be_silent, #be_verbose?, #beautiful_url, #burlywood, #call_next, #chdir, #cheerful_guy, #cliner, #complex_esystem, #convert_global_env, #copy_directory, #copy_file, #cornflowerblue, #create_directory, #crimson, #current_month?, #current_time?, #current_year?, #cyan, #darkcyan, #darkgreen, #darkkhaki, #darkslateblue, #deeppink, #delete_symlink, #do_not_use_the_base_colours, #do_use_the_base_colours, #e, #ecomment, #editor_to_use?, #efancy, #eimp, #emphasis, #ensure_main_encoding, #ensure_utf_encoding, #eparse, #erev, #esteelblue, #etomato, #ewarn, #exit_program, #firebrick, #get_current_day, #get_current_month, #get_files_and_directories, #get_files_from, #get_german_name_for_this_weekday, #gold, #green, #grey, #hh_mm_ss, #hh_mm_ss_day_month_year, #home_dir?, #home_directory_of_user_x?, #infer_the_namespace, #internal_hash?, #is_a_directory?, #is_a_file?, #is_a_jpg_file?, #is_an_image_file?, #is_archive?, #is_audio_file?, #is_in_studium_dir?, #is_multimedia_file?, #is_on_roebe?, #is_on_windows?, #is_studium_available?, #is_symlink?, #is_this_a_ruby_file?, #is_video_file?, #iso_encoding?, #le, #left_colour, #lightblue, #lightgreen, #lightseagreen, #lightsteelblue, #lime, #limegreen, #localhost_to_data, #log_directory?, #main_encoding?, #mediumorchid, #mediumpurple, #mediumseagreen, #mediumslateblue, #mediumspringgreen, #mediumturquoise, #mkdir_p, #mv, #n_days_in_this_month, #n_pages_in_this_pdf_file?, #namespace?, #no_file_exists_at, #ogrey, #olive, #olivedrab, #open_in_browser, #opne, #opnesystem, #opnn, #orange, #orchid, #orev, #palegoldenrod, #palevioletred, #pink, #powderblue, #programs_dir?, #project_base_dir?, #random_html_colour, #rds, #read_file_in_iso_encoding, #read_file_via_the_default_encoding, #read_lines_via_iso_encoding, #readlines_with_main_encoding, #red, #register_sigint, #remove, #remove_directory, #remove_file, #rename_kde_konsole_tab, #replace_localhost_with_data, #report_pwd, #require_rescue, #reset_the_internal_hash, #return_all_directories_from_this_directory, #return_all_files_from_this_directory, #return_current_directory, #return_dd_mm_yyyy, #return_file_or_directory_of, #return_files_from_pwd, #return_last_part_of_the_current_directory, #return_utc, #rev, #right_arrow?, #right_colour, #roebe_log_directory?, #rosybrown, #royalblue, #ruby_base_directory?, #run_in_background, #run_rcfiles_then_run_ata_via_qdbus, #sandybrown, #sdir, #seagreen, #set_be_verbose, #set_xorg_buffer, #sfancy, #sfile, #silent_redirection?, #simp, #simple_esystem, #skyblue, #slateblue, #slategray, #springgreen, #steelblue, #string_italic, #swarn, #symlink, #teal, #temp_dir?, #to_camelcase, #to_counted_hash, #tomato, #touch, #try_to_require_the_beautiful_url_gem, #try_to_require_the_html_template, #try_to_require_the_open_gem, #try_to_require_the_program_information_gem, #try_to_require_the_xorg_buffer, #use_colours?, #verbose_truth, #weekday?, #word_wrap, #write_what_into, #yellow
#append_onto_the_commandline_arguments, #clear_commandline_arguments, #commandline_arguments?, #commandline_arguments_as_string?, #commandline_arguments_without_leading_hyphens?, #first_argument?, #first_argument_without_leading_hyphens?, #has_an_argument_been_passed?, #remove_hyphened_arguments_from_the_commandline_arguments, #return_commandline_arguments_with_leading_hyphens, #second_argument?, #set_commandline_arguments
Constructor Details
#initialize(i = nil, run_already = true) ⇒ TalesFromTheCrypt
80
81
82
83
84
85
86
87
|
# File 'lib/roebe/classes/tales_from_the_crypt.rb', line 80
def initialize(
i = nil,
run_already = true
)
reset
set_input(i)
run if run_already
end
|
Class Method Details
.[](i = ARGV) ⇒ Object
#
Roebe::TalesFromTheCrypt[]
#
534
535
536
|
# File 'lib/roebe/classes/tales_from_the_crypt.rb', line 534
def self.[](i = ARGV)
new(i)
end
|
Instance Method Details
#considering_purging_all_gmon_out_files ⇒ Object
#
considering_purging_all_gmon_out_files
#
362
363
364
365
366
|
# File 'lib/roebe/classes/tales_from_the_crypt.rb', line 362
def considering_purging_all_gmon_out_files
if File.exist? 'gmon.out'
delete_file('gmon.out')
end
end
|
#do_batch_download_all_tales_from_the_crypt_video_files(use_this_directory = MAIN_DIRECTORY) ⇒ Object
#
do_batch_download_all_tales_from_the_crypt_video_files
This method can be used to batch-download all tales from the crypt videos.
To invoke this method, try:
talesfromthecrypt --batch-download
#
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
|
# File 'lib/roebe/classes/tales_from_the_crypt.rb', line 290
def do_batch_download_all_tales_from_the_crypt_video_files(
use_this_directory = MAIN_DIRECTORY
)
array_storing_the_filename = []
opne 'Now batch-downloading all videos from the tales of the crypt'
opne 'series into the directory `'+sdir(use_this_directory)+'`.'
mkdir(use_this_directory)
cd use_this_directory
index = 0
@dataset.each_pair {|which_season, inner_hash_dataset| index += 1
remote_URL = inner_hash_dataset['url']
name_of_the_episode = inner_hash_dataset['name']
opne lightgreen('('+index.to_s.rjust(2)+') ')+
'The episode `'+sfancy(name_of_the_episode)+
'` will be downloaded next. (Season: '+
lightgreen(which_season)+')'
opne 'Using the URL: '+royalblue(remote_URL)
e
download_via_youtube_dl_from_this_url(remote_URL)
considering_purging_all_gmon_out_files
all_files = Dir['*']
unless array_storing_the_filename.empty?
all_files = all_files - array_storing_the_filename
end
first_entry = all_files.first
if first_entry
old_extension_name = File.extname(first_entry).delete('.')
new_name = 'Tales_from_the_crypt_'+which_season+'_'+
name_of_the_episode.tr(' ','_')+'.'+old_extension_name
if new_name.include? '/' new_name.delete!('/')
end
opne 'Now renaming `'+sfile(first_entry)+'` to `'+sfile(new_name)+'`.'
array_storing_the_filename << new_name
rename(first_entry, new_name)
else
e 'No new video could be found. Perhaps the remote '\
'video no longer exists?'
end
}
report_how_many_video_files_are_in_the_main_directory
opne 'Batch-downloading done!'
end
|
#download_via_youtube_dl_from_this_url(remote_URL) ⇒ Object
#
download_via_youtube_dl_from_this_url
This method will attempt to make use of youtube-dl to download a remote tales-from-the-crypt video.
#
374
375
376
377
378
379
380
381
382
383
384
385
386
|
# File 'lib/roebe/classes/tales_from_the_crypt.rb', line 374
def download_via_youtube_dl_from_this_url(
remote_URL
)
_ = "youtube-dl #{remote_URL} 2>&1"
e _
result = `#{_}`
if result and result.include?('ERROR: This video is no longer available')
e crimson('This video is no longer available.')
e crimson('URL is: ')+steelblue(remote_URL)
@array_missing_videos << remote_URL
end
return result
end
|
#generate_html_string ⇒ Object
#
generate_html_string
This method is the default action for the class. It will ultimately yield the HTML string that will be stored.
#
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
|
# File 'lib/roebe/classes/tales_from_the_crypt.rb', line 453
def generate_html_string
_ = "<!DOCTYPE html>\n".dup
_ << "<html lang=\"en\">\n"
_ << "<head>\n"
_ << "<title>Good Tales from the Crypt episodes</title>\n"
_ << "<style>#{return_the_default_CSS_rules_for_the_generated_html_file}</style>\n"
_ << "<script src=\"../../../../cyberweb/lib/cyberweb/javascript_code/html_colours.js\"></script>\n"
_ << '<script>
/*
* change_the_colour_to()
*
* Use this function to change the colour of the text at
* hand.
*/
function change_the_colour_to(work_on_this_id = "our_id")
{
var random_colour = HTML_COLOURS[Math.floor(Math.random()*HTML_COLOURS.length)];
document.getElementById(work_on_this_id).style.color = random_colour;
}
</script>
'+"\n"
_ << "</head>\n" _ << '<body style="padding: 1em; font-size:larger">'
_ << "\n"
_ << "<img src=\"#{REMOTE_LOGO}\" style=\"margin:0.5em; margin-left: 2em;\"><br>\n"
index = 0
@dataset.each_pair {|this_season, inner_hash| index += 1
remote_URL = inner_hash['url']
name_of_the_episode = inner_hash['name'] a_href = HtmlTags.a(
remote_URL,
the_id: 'our_id',
description: '('+index.to_s+') '+
name_of_the_episode+' ('+this_season+')',
onclick: 'change_the_colour_to()'
).dup
Cyberweb.insert_target_blank_onto_this(a_href)
_ << a_href
_ << "<br>\n"
}
_ << '</body></html>'
save_file(_)
end
|
125
126
127
|
# File 'lib/roebe/classes/tales_from_the_crypt.rb', line 125
def input?
@input
end
|
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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
|
# File 'lib/roebe/classes/tales_from_the_crypt.rb', line 197
def (
i = input?
)
case i when /^-?-?directory\??$/i,
/^-?-?location\??$/i
show_where_the_tales_from_the_crypt_videos_are_stored
exit
when /^-?-?generate(-|_)?playlist$/
require 'multimedia_paradise/audio/create_m3u_playlist.rb'
array = YAML.load_file(YAML_FILE).map {|key, inner_array|
inner_array['url']
}
MultimediaParadise.create_m3u_playlist(array)
exit
when /^-?-?open$/
open_yaml_file_in_editor
exit
when /^-?-?(\d{1,4})$/
play_random_tales_from_the_crypt_video($1.to_s.dup)
when /-?-?batch(-|_)?download/,
/-?-?download$/
do_batch_download_all_tales_from_the_crypt_video_files
exit
when /-?-?play$/,
/play(-|_)?random(-|_)?tales(-|_)?from(-|_)?the(-|_)?crypt(-|_)?video$/,
/random$/
play_random_tales_from_the_crypt_video
exit
when /help/
show_help
exit
else
if i.to_s =~ /^(\d+)$/
play_random_tales_from_the_crypt_video($1.to_s.dup)
end
end
end
|
#open_yaml_file_in_editor(i = yaml_file?
) ⇒ Object
#
open_yaml_file_in_editor
#
185
186
187
188
189
190
191
192
|
# File 'lib/roebe/classes/tales_from_the_crypt.rb', line 185
def open_yaml_file_in_editor(
i = yaml_file?
)
unless Object.const_defined? :Open
require 'open'
end
Open.in_editor(i)
end
|
#play_random_tales_from_the_crypt_video(n_times = 1) ⇒ Object
#
play_random_tales_from_the_crypt_video
As argument to this method you can pass in a number, which means how many random tales-from-the-crypt video are to be fetched.
Invoke this method via:
tales --play_random_tales_from_the_crypt_video
#
#report_how_many_video_files_are_in_the_main_directory ⇒ Object
#
report_how_many_video_files_are_in_the_main_directory
#
354
355
356
357
|
# File 'lib/roebe/classes/tales_from_the_crypt.rb', line 354
def report_how_many_video_files_are_in_the_main_directory
opne 'There are '+royalblue(Dir[MAIN_DIRECTORY+'*'].size.to_s)+
' video files in the main directory.'
end
|
#report_missing_videos ⇒ Object
#
report_missing_videos
#
421
422
423
424
425
426
427
428
429
430
|
# File 'lib/roebe/classes/tales_from_the_crypt.rb', line 421
def report_missing_videos
unless @array_missing_videos.empty?
e 'The following URLs were not found:'
e
@array_missing_videos.each {|entry|
e steelblue(" #{entry}")
}
e
end
end
|
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
# File 'lib/roebe/classes/tales_from_the_crypt.rb', line 92
def reset
super()
infer_the_namespace
@array_missing_videos = []
if File.exist? YAML_FILE
@dataset = YAML.load_file(YAML_FILE)
else
opne "No file exists at #{sfile(YAML_FILE)}."
end
@use_this_video_player = 'mplayer'
end
|
#return_the_default_CSS_rules_for_the_generated_html_file ⇒ Object
#
return_the_default_CSS_rules_for_the_generated_html_file
#
435
436
437
438
439
440
441
442
443
444
445
|
# File 'lib/roebe/classes/tales_from_the_crypt.rb', line 435
def return_the_default_CSS_rules_for_the_generated_html_file
'
a,
a:link {
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
'
end
|
525
526
527
528
529
|
# File 'lib/roebe/classes/tales_from_the_crypt.rb', line 525
def run
generate_html_string
report_missing_videos
end
|
#save_file(what = '', into = STORE_IN_THIS_FILE) ⇒ Object
#
save_file
This method will create the new file.
#
134
135
136
137
138
139
140
|
# File 'lib/roebe/classes/tales_from_the_crypt.rb', line 134
def save_file(
what = '',
into = STORE_IN_THIS_FILE
)
opne "#{rev}Now storing into the file `#{sfile(into)}`."
write_what_into(what, into)
end
|
116
117
118
119
120
|
# File 'lib/roebe/classes/tales_from_the_crypt.rb', line 116
def set_input(i = '')
i = i.first if i.is_a? Array
i = i.to_s.dup
@input = i
end
|
#show_help ⇒ Object
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
# File 'lib/roebe/classes/tales_from_the_crypt.rb', line 157
def show_help
result = <<EOF
The following help-options are available:
--batch-download # batch download all the
# remote tales-from-the-crypt videos
--directory # show where the tales from the crypt videos are kept, locally
--open # open the yaml file
--random # play a random tales from the crypt video
--5 # pass in a number to play n random tales from the crypt videos
EOF
if result.include? '#'
result = result.dup.gsub(/^(.+)(#.+)$/,
lightgreen('\1')+slateblue('\2')
)
end
e result
end
|
#show_where_the_tales_from_the_crypt_videos_are_stored ⇒ Object
#
show_where_the_tales_from_the_crypt_videos_are_stored
Invocation example:
tales --directory?
#
271
272
273
274
275
276
277
|
# File 'lib/roebe/classes/tales_from_the_crypt.rb', line 271
def show_where_the_tales_from_the_crypt_videos_are_stored
e 'The directory for storing the tales-from-the-crypt '\
'video files can be found here:'
e
e " #{sdir(MAIN_DIRECTORY)}"
e
end
|
#use_which_video_player?(i = @use_this_video_player) ⇒ Boolean
#
use_which_video_player?
#
513
514
515
516
517
518
519
520
|
# File 'lib/roebe/classes/tales_from_the_crypt.rb', line 513
def use_which_video_player?(
i = @use_this_video_player
)
if ENV.has_key? 'USE_THIS_VIDEO_PLAYER'
i = ENV['USE_THIS_VIDEO_PLAYER']
end
i
end
|
#yaml_file? ⇒ Boolean
145
146
147
|
# File 'lib/roebe/classes/tales_from_the_crypt.rb', line 145
def yaml_file?
YAML_FILE
end
|