Class: MultimediaParadise::ImdbRating

Inherits:
Base
  • Object
show all
Defined in:
lib/multimedia_paradise/video/imdb_rating/imdb_rating.rb

Overview

MultimediaParadise::ImdbRating

Constant Summary collapse

USE_THIS_REGEX =
#

USE_THIS_REGEX

The Rating-specific String may look like this:

Rating: 7,6/10 · ‎160,162 votes
#

See: rubular.com/r/wO46isDDw1R3NM

#
/Rating\s+(\d{1,1}\.\d{1,1})\/\d{1,2}/

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, #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

Methods included from CommandlineArgumentsModule

#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(commandline_arguments = nil, run_already = true) ⇒ ImdbRating

#

initialize

#


54
55
56
57
58
59
60
61
62
63
# File 'lib/multimedia_paradise/video/imdb_rating/imdb_rating.rb', line 54

def initialize(
    commandline_arguments = nil,
    run_already           = true
  )
  reset
  set_commandline_arguments(
    commandline_arguments
  )
  run if run_already
end

Class Method Details

.[](i = '') ⇒ Object

#

MultimediaParadise::ImdbRating[]

#


124
125
126
# File 'lib/multimedia_paradise/video/imdb_rating/imdb_rating.rb', line 124

def self.[](i = '')
  new(i)
end

Instance Method Details

#obtain_google_search_resultObject

#

obtain_google_search_result

This method will obtain the google page.

#


91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/multimedia_paradise/video/imdb_rating/imdb_rating.rb', line 91

def obtain_google_search_result
  # modified_input = '%22'+original_input.map {|entry|
  #   entry.capitalize
  # }.join('+')+'%22'
  simple_input = commandline_arguments?.map {|entry| entry.capitalize }
  _ = return_google_string_for_this_URL(simple_input)
  #'https://www.google.com/search?client=firefox-b-e&q='+
  #    'https://www.google.com/search?as_q='+
  #    modified_input+
  #    '&as_epq=&as_oq=&as_eq=&as_nlo=&as_nhi=&lr=&cr=&as_qdr=all&as_sitesearch=&as_occt=any&safe=active&as_filetype=&tbs='
  #_ = _.dup
  e
  e sfancy(_)
  e
  dataset = URI.open(_).read # Encoding is now ISO-8859-1.
  dataset = dataset.encode('UTF-8')
  # dataset = dataset.force_encoding('UTF-8')
  scanned_results = ::Cyberweb.remove_html(dataset).scan(USE_THIS_REGEX)
  e 'The rating for `'+steelblue(commandline_arguments?.join(' ').to_s)+
    '` is: '+
    steelblue(scanned_results.flatten.first.to_f.to_s)
end

#resetObject

#

reset (reset tag)

#


68
69
70
71
# File 'lib/multimedia_paradise/video/imdb_rating/imdb_rating.rb', line 68

def reset
  super()
  infer_the_namespace
end

#return_google_string_for_this_URL(this_URL) ⇒ Object

#

return_google_string_for_this_URL

The task for this method is to return the String that can be used for a google-search.

#


79
80
81
82
83
84
# File 'lib/multimedia_paradise/video/imdb_rating/imdb_rating.rb', line 79

def return_google_string_for_this_URL(this_URL)
  this_URL = this_URL.join(' ') if this_URL.is_a? Array
  this_URL = this_URL.to_s.tr(' ','+')
  result = 'https://www.google.com/search?q='+this_URL.to_s+'&pws=0&gl=us&source=hp&ei=rBemYaygJd6HjLsPgqC4uAg&iflsig=ALs-wAMAAAAAYaYlvDplQlqKL-PSwzmrsOGF0IaDWwHi&ved=0ahUKEwispvb1icD0AhXeA2MBHQIQDocQ4dUDCAk&uact=5&oq=imdb+naked+gun&gs_lcp=Cgdnd3Mtd2l6EAMyBQgAEIAEOgsILhCABBDHARDRAzoLCC4QgAQQxwEQowI6BQguEIAEOgsILhCABBDHARCvAVCUBliFHmD5H2gBcAB4AYABsAKIAYgSkgEIMTYuMS4yLjGYAQCgAQGwAQA&sclient=gws-wiz'
  return result.dup
end

#runObject

#

run (run tag)

#


117
118
119
# File 'lib/multimedia_paradise/video/imdb_rating/imdb_rating.rb', line 117

def run
  obtain_google_search_result
end