class OSDb::Sub

Attributes

bad_reports_count[R]
downloads_count[R]
filename[R]
format[R]
language[R]
movie_name[R]
rating[R]
raw_data[R]
url[R]
user_ranks[R]

Public Class Methods

new(data) click to toggle source
# File lib/osdb/sub.rb, line 13
def initialize(data)
  @url = URI.parse(data['SubDownloadLink'])
  @format = data['SubFormat']
  @language = Language.from_iso639_2b(data['SubLanguageID'])
  @rating = data['SubRating'].to_f
  @user_ranks = data['UserRank']
  @movie_name = data['MovieName']
  @filename = data['SubFileName']
  @downloads_count = data['SubDownloadsCnt'].to_i
  @bad_reports_count = data['SubBad'].to_i
  @raw_data = data
end

Public Instance Methods

<=>(other) click to toggle source
# File lib/osdb/sub.rb, line 26
def <=>(other)
  rating <=> other.rating
end
body() click to toggle source
# File lib/osdb/sub.rb, line 41
def body
  @body ||= fetch_body
end
fetch_body() click to toggle source
# File lib/osdb/sub.rb, line 45
def fetch_body
  StringIO.open do |buffer|
    buffer.write(Net::HTTP.get(url))
    buffer.rewind
    return Zlib::GzipReader.new(buffer).read
  end
end
score() click to toggle source

Totaly subjective formula to evaluate subtitle quality Originaly developed by runa (github.com/runa) github.com/byroot/ruby-osdb/commit/9d71775#L0R122

# File lib/osdb/sub.rb, line 33
def score
  uploader_score * downloads_count.next * (rating + 1) - bad_reports_count / downloads_count.next
end
uploader_score() click to toggle source
# File lib/osdb/sub.rb, line 37
def uploader_score
  user_ranks.empty? ? 1 : 2
end