module P3::TV
Public Class Methods
add_series!( title )
click to toggle source
# File lib/p3-tv.rb, line 605 def self.add_series!( title ) settings = Settings.new search = Search.new( settings ) results = search.find_series( title ) settings.add_series!( results[0] ) settings.save! end
catalog_downloads!( settings = Settings.new, downloads = Downloads.new( settings ) )
click to toggle source
# File lib/p3-tv.rb, line 646 def self.catalog_downloads!( settings = Settings.new, downloads = Downloads.new( settings ) ) library = Library.new( settings ) downloads.each_episode_file do | episode_file | library.catalog!( episode_file ) end return nil end
catalog_downloads_series!( seriesid, settings = Settings.new )
click to toggle source
# File lib/p3-tv.rb, line 635 def self.catalog_downloads_series!( seriesid, settings = Settings.new ) downloads = Downloads.new( settings ) downloads.remove_completed_torrents! library = Library.new( settings ) downloads.each_episode_file_in_series( seriesid ) do | episode_file | library.catalog!( episode_file ) end return nil end
catalog_file!( path, settings = Settings.new )
click to toggle source
# File lib/p3-tv.rb, line 626 def self.catalog_file!( path, settings = Settings.new ) downloads = Downloads.new( settings ) return if settings.allowed_type?( path ) library = Library.new( settings ) episode = downloads.create_episode_from_filename( path ) library.catalog!( episode ) if episode return nil end
download_missing!( settings = Settings.new )
click to toggle source
# File lib/p3-tv.rb, line 664 def self.download_missing!( settings = Settings.new ) search = Search.new( settings ) library = Library.new( settings ) downloads = Downloads.new( settings ) settings[:series].each do | series | settings.each_series_episode_file_status( series[:id], search, downloads, library ) do | episode_file | downloads.download_episode_file!( episode_file ) end end end
download_missing_series!( seriesid, settings = Settings.new )
click to toggle source
# File lib/p3-tv.rb, line 654 def self.download_missing_series!( seriesid, settings = Settings.new ) search = Search.new( settings ) library = Library.new( settings ) downloads = Downloads.new( settings ) settings.each_series_episode_file_status( seriesid, search, downloads, library ) do | episode_file | downloads.download_episode_file!( episode_file ) end end
enable_test_mode!( enable )
click to toggle source
# File lib/p3-tv.rb, line 620 def self.enable_test_mode!( enable ) Settings::set!( :dry_run, enable ) Settings::set!( :verbose, enable ) end
format_title( title )
click to toggle source
# File lib/p3-tv.rb, line 528 def self.format_title( title ) #strip non alphanumeric characters and extra whitespace rval = title.gsub(/[^0-9a-z ]/i, '').gsub(/[ ]+/,' ').strip return rval end
path_contains_series?( path, title )
click to toggle source
# File lib/p3-tv.rb, line 534 def self.path_contains_series?( path, title ) formatted_title = P3::TV::format_title( title ) if path.scan( /#{formatted_title}/i ).empty? #case insensative if path.scan( /#{formatted_title.gsub(' ','.')}/i ).empty? # Titles.With.Periods.Instead.Of.Spaces return false end end return true end
test_mode_enabled?()
click to toggle source
# File lib/p3-tv.rb, line 615 def self.test_mode_enabled? settings = Settings.new return ( settings[:verbose] and settings[:dry_run] ) end