Sha256: 052703d9364442b9eb0a9b840f0b8da806b1a090d9f5e9f3f11e78ed4ea0adcc

Contents?: true

Size: 753 Bytes

Versions: 1

Compression:

Stored size: 753 Bytes

Contents

require 'open-uri'

class NFO
  
  attr_accessor :srt, :imdb_link
  
  def initialize(url)
    @nfo = open(url.gsub(/\/$/,'')).read
    @srt = []
    
    parse_nfo
    @srt.uniq!
  end
  
private
  
  # searching for subtitles languages info & imdb link
  def parse_nfo
    @nfo.split(/\n/).each do |line|
      case line
      when /subtitle|sub/i
        @srt << 'fr' if line =~ /fr|fre|french/i
        @srt << 'en' if line =~ /en|eng|english/i
        # TODO add more language parsing here
        @srt << 'none' if line =~ /none/i
      when /imdb\.com\/title\//
        @imdb_link = (matched = line.match(/imdb.com\/title\/(tt[0-9]+)/)) && "http://imdb.com/title/#{matched[1]}"
      end
    end
    @srt << 'unknown' if @srt.empty?
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pirate-autonzb-0.4.5 lib/nfo.rb