module Blitzcrank
Constants
- VERSION
Public Class Methods
configure_with(yaml_path)
click to toggle source
# File lib/blitzcrank.rb, line 21 def self.configure_with(yaml_path) begin Blitzcrank.config.update(YAML.load(IO.read(yaml_path))) rescue Errno::ENOENT log(:warning, "YAML configuration file couldn't be found. Using defaults."); return rescue Psych::SyntaxError log(:warning, "YAML configuration file contains invalid syntax. Using defaults."); return end end
remote_video_file_list()
click to toggle source
get a listing of all remote files that would be considered “videos”
# File lib/blitzcrank.rb, line 43 def self.remote_video_file_list %x[ssh -q #{Blitzcrank.config.remote_user}@#{Blitzcrank.config.remote_host} "cd #{Blitzcrank.config.remote_base_dir} && find . -type f \\( -iname \'*.avi\' -or -iname \'*.mkv\' -or -iname \'*.mp4\' -or -iname \'*.m4v\' -or -iname \'*.divx\' \\)"] end
rsync_all_files()
click to toggle source
copies all files if they find a matching local directory
# File lib/blitzcrank.rb, line 77 def self.rsync_all_files puts "Downloading all remote videos\n" fileArray = Blitzcrank.remote_video_file_list.gsub('./','').split("\n") availableFiles = Array.new() fileArray.each do |remoteFile| availableFiles.push({:path => remoteFile, :name => remoteFile.split('/').last()}) end Blitzcrank.transfer_files(availableFiles) end
transfer_file(video)
click to toggle source
# File lib/blitzcrank.rb, line 35 def self.transfer_file(video) puts "Copying #{video.remote_path} to #{video.local_path}" if !Blitzcrank.config.dry_run Rsync.sync(video) end end
transfer_files(filesToTransfer)
click to toggle source
any files (hashes) passed into here will be checked against our local TV folders and IMDB to see if it’s a movie
# File lib/blitzcrank.rb, line 88 def self.transfer_files(filesToTransfer) Dir.chdir(Blitzcrank.config.base_tv_dir) filesToTransfer.each do |dh| video = Video.with_path dh[:path] if video.is_tv_show? FileUtils.mkdir_p video.season_path end Blitzcrank.transfer_file(video) end end
write_sample_config(yaml_path)
click to toggle source
# File lib/blitzcrank.rb, line 31 def self.write_sample_config(yaml_path) IO.write(yaml_path, Blitzcrank.config.to_yaml) end