Sha256: 54cd6bb03b43dd457bc41852b9061b95189587c04959ed39525e49338d5ae2b1

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

#!/usr/bin/env ruby
require 'optparse'

begin
  require 'hlspider'
rescue LoadError
  require 'rubygems'
  require 'hlspider'
end

options = {}

opts_parser = OptionParser.new do |opts|
  opts.banner  = 'Downloads m3u8 playlists and confirms their segments are aligned.'
  opts.banner += ''

  opts.on('-p', '--playlists PLAYLISTS', Array, 'URL(s) to playlist(s)') do |playlists|
    options[:playlists] = playlists
  end
  
  options[:loop] = 1
  opts.on('-l', '--loop TIMES', Integer) do |l|
    options[:loop] = l || 5
  end 
  
  options[:sleep] = 3
  opts.on('-s', '--sleep SECONDS', Integer) do |s|
    options[:sleep] = s
  end   
  
  opts.on( '-h', '--help', 'Display this screen' ) do
    puts opts
    exit
  end
end
opts_parser.parse!

spider = HLSpider::Spider.new(options[:playlists])

x = 1
while x <= options[:loop] do
  if spider.crawl
    if spider.aligned?
      puts "--- Aligned at segment : #{spider.last_segments[0]} ---"
    else
      puts "--- Unaligned with segments : #{spider.last_segments.join(', ')} ---"
    end
  else
    @errors.each do |err|
      puts "--- #{err} ---"
    end  
  end    
  
  break if @errors
  
  x += 1 unless options[:loop] == 0
  
  sleep(options[:sleep])
end  

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hlspider-0.3.0 bin/hlspider