Sha256: 95daa65bae3afb6944810d8a7339562a4d682632cfd5a81def8e1a94a9c722bc

Contents?: true

Size: 1.03 KB

Versions: 3

Compression:

Stored size: 1.03 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  
  
  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
end  

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hlspider-0.2.2 bin/hlspider
hlspider-0.2.1 bin/hlspider
hlspider-0.2.0 bin/hlspider