Class: Bathyscaphe::TVDB
Constant Summary collapse
- TVREGEXP1 =
/(.*)S([0-9]{2})E([0-9]{2}).*/i- TVREGEXP2 =
/(.*).([0-9]{1,2})x([0-9]{1,2}).*/i- TVREGEXP3 =
/(.*)Season\s*([0-9]{1,2})\s*Episode\s*([0-9]{1,2}).*/i- TVREGEXP4 =
/.*\/(.*)\/Season\s*([0-9]{1,2})\/([0-9]{1,2}).*/i- TVREGEXP5 =
/.*\/(.*)\/Season\s*([0-9]{1,2})\/.*S(?:[0-9]{2})E([0-9]{2}).*/i
Instance Attribute Summary collapse
-
#episode ⇒ Object
Returns the value of attribute episode.
-
#name ⇒ Object
Returns the value of attribute name.
-
#season ⇒ Object
Returns the value of attribute season.
Instance Method Summary collapse
- #get_from_md(md) ⇒ Object
-
#initialize(filename, filedir) ⇒ TVDB
constructor
A new instance of TVDB.
Constructor Details
#initialize(filename, filedir) ⇒ TVDB
Returns a new instance of TVDB.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/bathyscaphe/tvdb.rb', line 13 def initialize filename, filedir wholefile = File.join(filedir, filename) @name = @season = @episode = nil if md = filename.match(TVREGEXP1) || md = filename.match(TVREGEXP2) || md = filename.match(TVREGEXP3) @name, @season, @episode = get_from_md(md) end return unless [@name, @season, @episode].collect(&:blank?).any? if md = wholefile.match(TVREGEXP4) || md = wholefile.match(TVREGEXP5) @name, @season, @episode = get_from_md(md) end return unless [@name, @season, @episode].collect(&:blank?).any? if md = filedir.split("/").last.match(/(.*)Season(.*)/i) @name = md[1].gsub(/[-.]+/i, ' ').gsub("'", '').strip @season = md[2].strip.scan(/^(\d+).*/).flatten.last.to_i.to_s if namemd = filename.match(/(\d*).*/) @episode = namemd[1].to_i.to_s end end end |
Instance Attribute Details
#episode ⇒ Object
Returns the value of attribute episode.
11 12 13 |
# File 'lib/bathyscaphe/tvdb.rb', line 11 def episode @episode end |
#name ⇒ Object
Returns the value of attribute name.
11 12 13 |
# File 'lib/bathyscaphe/tvdb.rb', line 11 def name @name end |
#season ⇒ Object
Returns the value of attribute season.
11 12 13 |
# File 'lib/bathyscaphe/tvdb.rb', line 11 def season @season end |
Instance Method Details
#get_from_md(md) ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/bathyscaphe/tvdb.rb', line 38 def get_from_md(md) name = md[1].gsub(/[-.]+/i, " ").strip name = "Castle" if name =~ /Castle 2009/i name = "Missing (2012)" if name =~ /Missing 2012/i name = "Brooklyn Nine-Nine" if name =~ /Brooklyn Nine Nine/i season = md[2].to_i.to_s episode = md[3].to_i.to_s return name, season, episode end |