class MultimediaParadise::Audio::StreamripperWrapper

Constants

BOOTLIQUOR_URL
#

BOOTLIQUOR_URL

#
DENVER_URL
#

DENVER_URL

#
HASH_AVAILABLE_URLS
#

ARRAY_AVAILABLE_URLS

Gather some URLs here.

#
HOUSE_MUSIC
#

Audio::StreamripperWrapper::HOUSE_MUSIC

#
URL_1
#

URL_1

#
URL_2
#

URL_2

#
URL_SHOUTCAST
#

URL_SHOUTCAST

#

Public Class Methods

new( play_from_where = denver?, run_already = false ) click to toggle source
#

initialize

#
# File lib/multimedia_paradise/audio/streamripper/streamripper_wrapper.rb, line 24
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

Public Instance Methods

append(i) click to toggle source
#

append

#
# File lib/multimedia_paradise/audio/streamripper/streamripper_wrapper.rb, line 224
def append(i)
  @string << i
end
append_where_we_store() click to toggle source
#

append_where_we_store

#
# File lib/multimedia_paradise/audio/streamripper/streamripper_wrapper.rb, line 238
def append_where_we_store
  append ' -d /Depot/Temp/Audio/'
end
bootliquor?() click to toggle source
#

bootliquor?

#
# File lib/multimedia_paradise/audio/streamripper/streamripper_wrapper.rb, line 61
def bootliquor?
  HASH_AVAILABLE_URLS['Bootliquor']
end
Also aliased as: default_url?
build_command() click to toggle source
#

build_command

#
# File lib/multimedia_paradise/audio/streamripper/streamripper_wrapper.rb, line 245
def build_command
  append @url
  append_where_we_store
  sanitize_command
end
check_whether_streamripper_is_available() click to toggle source
#

check_whether_streamripper_is_available

#
# File lib/multimedia_paradise/audio/streamripper/streamripper_wrapper.rb, line 106
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
default_url?()
Alias for: bootliquor?
denver?() click to toggle source
#

denver?

#
# File lib/multimedia_paradise/audio/streamripper/streamripper_wrapper.rb, line 54
def denver?
  HASH_AVAILABLE_URLS['Denver area radio']
end
dir?() click to toggle source
#

dir?

Provide to us a colourized variant.

#
# File lib/multimedia_paradise/audio/streamripper/streamripper_wrapper.rb, line 193
def dir?
  sdir((Dir.pwd+'/').squeeze('/'))
end
do_not_exit() click to toggle source
#

do_not_exit

#
# File lib/multimedia_paradise/audio/streamripper/streamripper_wrapper.rb, line 99
def do_not_exit
  @can_we_exit = false
end
dont_write_individual_files() click to toggle source
#

dont_write_individual_files

With this we deny streamripper writing individual files.

#
# File lib/multimedia_paradise/audio/streamripper/streamripper_wrapper.rb, line 155
def dont_write_individual_files
  @string << ' -A'
end
reset() click to toggle source
#

reset

#
Calls superclass method MultimediaParadise::Base#reset
# File lib/multimedia_paradise/audio/streamripper/streamripper_wrapper.rb, line 39
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) click to toggle source
#

rip_to_single_file

Rip to single file, default name is timestamped

#
# File lib/multimedia_paradise/audio/streamripper/streamripper_wrapper.rb, line 145
def rip_to_single_file(this_file = nil)
  @string << ' -a '
  @string << this_file unless this_file.nil?
end
run() click to toggle source
#

run

Do the actual invocation part here.

#
# File lib/multimedia_paradise/audio/streamripper/streamripper_wrapper.rb, line 256
def run
  check_whether_streamripper_is_available
  set_base_command
  set_url # mandatory
  build_command
  start_streamripper_server
end
run_in_simulation_mode?() click to toggle source
#

run_in_simulation_mode?

#
# File lib/multimedia_paradise/audio/streamripper/streamripper_wrapper.rb, line 92
def run_in_simulation_mode?
  @run_in_simulation_mode
end
sanitize_command() click to toggle source
#

sanitize_command

#
# File lib/multimedia_paradise/audio/streamripper/streamripper_wrapper.rb, line 231
def sanitize_command
  @string.squeeze! ' '
end
set_base_command() click to toggle source
#

set_base_command

#
# File lib/multimedia_paradise/audio/streamripper/streamripper_wrapper.rb, line 120
def set_base_command
  @string << 'streamripper '
end
set_destination_directory(this_dir) click to toggle source
#

set_destination_directory

This sets our destination directory

#
# File lib/multimedia_paradise/audio/streamripper/streamripper_wrapper.rb, line 164
def set_destination_directory(this_dir)
  @string << ' -d '+this_dir
end
set_pattern(this_pattern) click to toggle source
#

set_pattern

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

#
# File lib/multimedia_paradise/audio/streamripper/streamripper_wrapper.rb, line 173
def set_pattern(this_pattern)
  @string << ' -D '+this_pattern
end
set_url(this_url = @use_this_url) click to toggle source
#

set_url

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

#
# File lib/multimedia_paradise/audio/streamripper/streamripper_wrapper.rb, line 203
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) click to toggle source
#

set_use_this_url

#
# File lib/multimedia_paradise/audio/streamripper/streamripper_wrapper.rb, line 68
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_help() click to toggle source
#

show_help

#
# File lib/multimedia_paradise/audio/streamripper/streamripper_wrapper.rb, line 83
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_server() click to toggle source
#

start_streamripper_server

#
# File lib/multimedia_paradise/audio/streamripper/streamripper_wrapper.rb, line 180
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?() click to toggle source
#

url?

Feedback the project url here.

#
# File lib/multimedia_paradise/audio/streamripper/streamripper_wrapper.rb, line 136
def url?
  e 'http://sourceforge.net/project/showfiles.php?group_id=6172'
end
use_this_directory_as_base=(i) click to toggle source
#

use_this_directory_as_base=

#
# File lib/multimedia_paradise/audio/streamripper/streamripper_wrapper.rb, line 127
def use_this_directory_as_base=(i)
  Dir.chdir(i) if Dir.exist? i
end
warn_and_exit(i) click to toggle source
#

warn_and_exit

#
# File lib/multimedia_paradise/audio/streamripper/streamripper_wrapper.rb, line 216
def warn_and_exit(i)
  e i
  exit if @can_we_exit
end