Class: MultimediaParadise::Audio::StreamripperWrapper

Inherits:
Base
  • Object
show all
Defined in:
lib/multimedia_paradise/audio/streamripper/constants.rb,
lib/multimedia_paradise/audio/streamripper/streamripper_wrapper.rb

Constant Summary collapse

URL_SHOUTCAST =
#

URL_SHOUTCAST

#
'http://www.shoutcast.com/'
URL_1 =
#

URL_1

#
'http://yp.shoutcast.com/sbin/tunein-station.pls?id=128607'
URL_2 =
#

URL_2

#
'http://yp.shoutcast.com/sbin/tunein-station.pls?id=128607'
HOUSE_MUSIC =
#

Audio::StreamripperWrapper::HOUSE_MUSIC

#
'  http://yp.shoutcast.com/sbin/tunein-station.pls?id=57352'
DENVER_URL =
#

DENVER_URL

#
'http://4533.live.streamtheworld.com:80/KKFNFMAAC_SC'
BOOTLIQUOR_URL =
#

BOOTLIQUOR_URL

#
'http://somafm.com/bootliquor.pls'
HASH_AVAILABLE_URLS =
#

ARRAY_AVAILABLE_URLS

Gather some URLs here.

#
{
  'Denver area radio' => DENVER_URL,
  'Bootliquor'        => BOOTLIQUOR_URL
}

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

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(play_from_where = denver?, , run_already = false) ⇒ StreamripperWrapper

#

initialize

#


26
27
28
29
30
31
32
33
34
35
36
# File 'lib/multimedia_paradise/audio/streamripper/streamripper_wrapper.rb', line 26

def initialize(
    play_from_where = denver?, # Denver is the default for now.
    run_already     = false
  )
  register_sigint
  reset
  if play_from_where
    set_use_this_url(play_from_where)
  end 
  run if run_already
end

Instance Method Details

#append(i) ⇒ Object

#

append

#


226
227
228
# File 'lib/multimedia_paradise/audio/streamripper/streamripper_wrapper.rb', line 226

def append(i)
  @string << i
end

#append_where_we_storeObject

#

append_where_we_store

#


240
241
242
# File 'lib/multimedia_paradise/audio/streamripper/streamripper_wrapper.rb', line 240

def append_where_we_store
  append ' -d /Depot/Temp/Audio/'
end

#bootliquor?Boolean Also known as: default_url?

#

bootliquor?

#

Returns:

  • (Boolean)


63
64
65
# File 'lib/multimedia_paradise/audio/streamripper/streamripper_wrapper.rb', line 63

def bootliquor?
  HASH_AVAILABLE_URLS['Bootliquor']
end

#build_commandObject

#

build_command

#


247
248
249
250
251
# File 'lib/multimedia_paradise/audio/streamripper/streamripper_wrapper.rb', line 247

def build_command
  append @url
  append_where_we_store
  sanitize_command
end

#check_whether_streamripper_is_availableObject

#

check_whether_streamripper_is_available

#


108
109
110
111
112
113
114
115
116
117
# File 'lib/multimedia_paradise/audio/streamripper/streamripper_wrapper.rb', line 108

def check_whether_streamripper_is_available
  result = `streamripper 2>&1`
  if result.include? 'command not found'
    warn_and_exit 'streamripper is not installer. Please install it first.'
  else
    if be_verbose?
      efancy 'Streamripper is available. We can thus continue.'
    end
  end
end

#denver?Boolean

#

denver?

#

Returns:

  • (Boolean)


56
57
58
# File 'lib/multimedia_paradise/audio/streamripper/streamripper_wrapper.rb', line 56

def denver?
  HASH_AVAILABLE_URLS['Denver area radio']
end

#dir?Boolean

#

dir?

Provide to us a colourized variant.

#

Returns:

  • (Boolean)


195
196
197
# File 'lib/multimedia_paradise/audio/streamripper/streamripper_wrapper.rb', line 195

def dir?
  sdir(return_pwd)
end

#do_not_exitObject

#

do_not_exit

#


101
102
103
# File 'lib/multimedia_paradise/audio/streamripper/streamripper_wrapper.rb', line 101

def do_not_exit
  @can_we_exit = false
end

#dont_write_individual_filesObject

#

dont_write_individual_files

With this we deny streamripper writing individual files.

#


157
158
159
# File 'lib/multimedia_paradise/audio/streamripper/streamripper_wrapper.rb', line 157

def dont_write_individual_files
  @string << ' -A'
end

#resetObject

#

reset

#


41
42
43
44
45
46
47
48
49
50
51
# File 'lib/multimedia_paradise/audio/streamripper/streamripper_wrapper.rb', line 41

def reset
  super()
  # ======================================================================= #
  # === @string
  # ======================================================================= #
  @string = ''.dup
  @can_we_exit = true
  @use_this_url = HOUSE_MUSIC # URL_2 # This is the default.
  @run_in_simulation_mode = false # If true then we just simulate what we would do.
  @be_verbose = false
end

#rip_to_single_file(this_file = nil) ⇒ Object

#

rip_to_single_file

Rip to single file, default name is timestamped

#


147
148
149
150
# File 'lib/multimedia_paradise/audio/streamripper/streamripper_wrapper.rb', line 147

def rip_to_single_file(this_file = nil)
  @string << ' -a '
  @string << this_file unless this_file.nil?
end

#runObject

#

run

Do the actual invocation part here.

#


258
259
260
261
262
263
264
# File 'lib/multimedia_paradise/audio/streamripper/streamripper_wrapper.rb', line 258

def run
  check_whether_streamripper_is_available
  set_base_command
  set_url # mandatory
  build_command
  start_streamripper_server
end

#run_in_simulation_mode?Boolean

#

run_in_simulation_mode?

#

Returns:

  • (Boolean)


94
95
96
# File 'lib/multimedia_paradise/audio/streamripper/streamripper_wrapper.rb', line 94

def run_in_simulation_mode?
  @run_in_simulation_mode
end

#sanitize_commandObject

#

sanitize_command

#


233
234
235
# File 'lib/multimedia_paradise/audio/streamripper/streamripper_wrapper.rb', line 233

def sanitize_command
  @string.squeeze! ' '
end

#set_base_commandObject

#

set_base_command

#


122
123
124
# File 'lib/multimedia_paradise/audio/streamripper/streamripper_wrapper.rb', line 122

def set_base_command
  @string << 'streamripper '
end

#set_destination_directory(this_dir) ⇒ Object

#

set_destination_directory

This sets our destination directory

#


166
167
168
# File 'lib/multimedia_paradise/audio/streamripper/streamripper_wrapper.rb', line 166

def set_destination_directory(this_dir)
  @string << ' -d '+this_dir
end

#set_pattern(this_pattern) ⇒ Object

#

set_pattern

Write files using specified pattern. Dunno yet what this means.

#


175
176
177
# File 'lib/multimedia_paradise/audio/streamripper/streamripper_wrapper.rb', line 175

def set_pattern(this_pattern)
  @string << ' -D '+this_pattern
end

#set_url(this_url = @use_this_url) ⇒ Object

#

set_url

Set the URL we want to use. This should point to something that can serve a .pls file.

#


205
206
207
208
209
210
211
212
213
# File 'lib/multimedia_paradise/audio/streamripper/streamripper_wrapper.rb', line 205

def set_url(this_url = @use_this_url)
  if this_url.is_a? Array
    this_url = this_url.first
  end
  if this_url.nil?
    this_url = default_url?
  end
  @url = " #{this_url.strip}"
end

#set_use_this_url(i = nil) ⇒ Object

#

set_use_this_url

#


70
71
72
73
74
75
76
77
78
79
80
# File 'lib/multimedia_paradise/audio/streamripper/streamripper_wrapper.rb', line 70

def set_use_this_url(i = nil)
  i = i.first if i.is_a? Array
  i = denver? if i.nil?
  if i.include? '--'
    case i
    when /-?-?help/
      show_help; exit
    end
  end
  @use_this_url = i
end

#show_helpObject

#

show_help

#


85
86
87
88
89
# File 'lib/multimedia_paradise/audio/streamripper/streamripper_wrapper.rb', line 85

def show_help
  e 'Presently, this class does not allow any option.'
  e 'Perhaps in the future you may be able to set another URL '\
    'than the default one.'
end

#start_streamripper_serverObject

#

start_streamripper_server

#


182
183
184
185
186
187
188
# File 'lib/multimedia_paradise/audio/streamripper/streamripper_wrapper.rb', line 182

def start_streamripper_server
  unless @can_we_exit
    e 'Starting the streamripper-server now from dir '+dir?+':'
    e simp('  '+@string)
    system @string unless run_in_simulation_mode?
  end
end

#url?Boolean

#

url?

Feedback the project url here.

#

Returns:

  • (Boolean)


138
139
140
# File 'lib/multimedia_paradise/audio/streamripper/streamripper_wrapper.rb', line 138

def url?
  e 'https://sourceforge.net/project/showfiles.php?group_id=6172'
end

#use_this_directory_as_base=(i) ⇒ Object

#

use_this_directory_as_base=

#


129
130
131
# File 'lib/multimedia_paradise/audio/streamripper/streamripper_wrapper.rb', line 129

def use_this_directory_as_base=(i)
  Dir.chdir(i) if Dir.exist? i
end

#warn_and_exit(i) ⇒ Object

#

warn_and_exit

#


218
219
220
221
# File 'lib/multimedia_paradise/audio/streamripper/streamripper_wrapper.rb', line 218

def warn_and_exit(i)
  e i
  exit if @can_we_exit
end