Sha256: 0be835ba8f9a3b38dbb57862c9b052f76d0a96d093cb6103cc4858b4e6ba9d63
Contents?: true
Size: 1.84 KB
Versions: 2
Compression:
Stored size: 1.84 KB
Contents
#!/usr/bin/env ruby $LOAD_PATH.unshift File.join(File.dirname(__FILE__), *%w( .. lib )) require 'addic7ed' require 'optparse' require 'peerflixrb' options = {} OptionParser.new do |opts| opts.banner = 'Usage: peerflixrb [options] <search>' # TODO: maybe create option for letting load a specific local file too opts.on('-s', '--with-subtitles', 'Play with subtitles') do |s| options[:subtitles] = s end opts.on('-l LANGUAGE', '--language LANGUAGE', 'Language code to look subtitles for (default: English)') do |l| options[:language] = l end opts.on_tail('-h', '--help', 'Show this message') do puts opts exit end end.parse! # Default language: English options[:language] ||= 'en' # Join arguments to create the search term options[:search] = ARGV.join ' ' exit if options[:search].empty? # main # TODO: handle failing and invalid searches kat = Peerflixrb::KAT.new(options[:search]) # Subtitle search if options[:subtitles] begin ep = Addic7ed::Episode.new(kat.filename) sub_file = File.basename(ep.download_best_subtitle!(options[:language])) rescue Addic7ed::EpisodeNotFound puts "Episode not found on Addic7ed : #{ep.video_file.filename}." rescue Addic7ed::ShowNotFound puts "Show not found on Addic7ed : #{ep.video_file.filename}." rescue Addic7ed::NoSubtitleFound puts "No (acceptable) subtitle has been found on Addic7ed for #{ep.video_file.filename}." rescue Addic7ed::InvalidFilename puts "Addic7ed gem doesn't like the format passed. Skipping subtitles." end end # Peerflix command build command = "peerflix '#{kat.magnet}'" command << " --subtitles '#{sub_file}'" unless sub_file.nil? # TODO: choose video player (default: VLC) command << ' --vlc' # TODO: pipe options and leave these as default command << ' -- --fullscreen' system command # Cleaning up FileUtils.rm sub_file unless sub_file.nil?
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
peerflixrb-0.0.2 | bin/peerflixrb |
peerflixrb-0.0.1 | bin/peerflixrb |