Sha256: ccdbabd788ed2751dff36854f6693dfdffa9b4680c2931e516f6912bae59c76f

Contents?: true

Size: 866 Bytes

Versions: 6

Compression:

Stored size: 866 Bytes

Contents

require 'open-uri'

module Nzbs
  class Nfo
  
    attr_accessor :srt, :imdb_link
  
    def initialize(agent, url)
      @page = agent.get(url.gsub(/\/$/,''))
      @srt = []
    
      parse_nfo
      @srt.uniq!
    end
  
  private
  
    # searching for subtitles languages info & imdb link
    def parse_nfo
      pre = @page.search('pre.nfo')
      pre.to_s.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
end

Version data entries

6 entries across 6 versions & 3 rubygems

Version Path
pirate-autonzb-0.5.0 lib/sites/nzbs/nfo.rb
pirate-autonzb-0.5.1 lib/sites/nzbs/nfo.rb
pirate-autonzb-0.5.2 lib/sites/nzbs/nfo.rb
autonzb-0.5.5 lib/sites/nzbs/nfo.rb
autonzb-0.5.4 lib/sites/nzbs/nfo.rb
AutoNZB-0.5.4 lib/sites/nzbs/nfo.rb