Class: SubtitleIt::Subtitle

Inherits:
Object
  • Object
show all
Includes:
Comparable, Formats
Defined in:
lib/subtitle_it/subtitle.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Formats

#parse_ass, #parse_mpl, #parse_rsb, #parse_srt, #parse_sub, #parse_time, #parse_xml, #parse_yml, #ratio, #to_ass, #to_mpl, #to_rsb, #to_srt, #to_sub, #to_xml, #to_yml, #xml_lines

Methods included from PlatformEndLine

#endline, #platform

Constructor Details

#initialize(args = {}) ⇒ Subtitle

Returns a new instance of Subtitle.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/subtitle_it/subtitle.rb', line 22

def initialize(args = {})
  # Looks like opensubtitle is the only provider around..
  # If a second one comes need big refactor...
  if @info = args[:info]
    #@osdb_info         = info
    @osdb_id           = @info['IDSubtitleFile'].to_s
    @original_filename = @info['SubFileName'].to_s
    @format            = @info['SubFormat'].to_s
    @user              = @info['UserNickName'].to_s
    @language          = @info['LanguageName'].to_s
    @release_name      = @info['MovieReleaseName'].to_s
    @download_count    = @info['SubDownloadsCnt'].to_i
    @rating            = @info['SubRating'].to_f
    @uploaded_at       = @info['SubAddDate'].to_s # TODO: convert to time object?
    @download_url      = @info['SubDownloadLink'].to_s
  end
  @fps = args[:fps] || 23.976      
  parse_dump(args[:dump], args[:format]) if args[:dump]
end

Instance Attribute Details

#download_countObject (readonly)

Returns the value of attribute download_count.



19
20
21
# File 'lib/subtitle_it/subtitle.rb', line 19

def download_count
  @download_count
end

#download_urlObject (readonly)

Returns the value of attribute download_url.



19
20
21
# File 'lib/subtitle_it/subtitle.rb', line 19

def download_url
  @download_url
end

#filenameObject (readonly)

Returns the value of attribute filename.



19
20
21
# File 'lib/subtitle_it/subtitle.rb', line 19

def filename
  @filename
end

#formatObject (readonly)

Returns the value of attribute format.



19
20
21
# File 'lib/subtitle_it/subtitle.rb', line 19

def format
  @format
end

#idObject (readonly)

Returns the value of attribute id.



19
20
21
# File 'lib/subtitle_it/subtitle.rb', line 19

def id
  @id
end

#infoObject (readonly)

Returns the value of attribute info.



19
20
21
# File 'lib/subtitle_it/subtitle.rb', line 19

def info
  @info
end

#languageObject (readonly)

Returns the value of attribute language.



19
20
21
# File 'lib/subtitle_it/subtitle.rb', line 19

def language
  @language
end

#linesObject

Returns the value of attribute lines.



19
20
21
# File 'lib/subtitle_it/subtitle.rb', line 19

def lines
  @lines
end

#original_filenameObject (readonly)

Returns the value of attribute original_filename.



19
20
21
# File 'lib/subtitle_it/subtitle.rb', line 19

def original_filename
  @original_filename
end

#osdb_idObject (readonly)

Returns the value of attribute osdb_id.



19
20
21
# File 'lib/subtitle_it/subtitle.rb', line 19

def osdb_id
  @osdb_id
end

#ratingObject (readonly)

Returns the value of attribute rating.



19
20
21
# File 'lib/subtitle_it/subtitle.rb', line 19

def rating
  @rating
end

#rawObject (readonly)

Returns the value of attribute raw.



19
20
21
# File 'lib/subtitle_it/subtitle.rb', line 19

def raw
  @raw
end

#release_nameObject (readonly)

Returns the value of attribute release_name.



19
20
21
# File 'lib/subtitle_it/subtitle.rb', line 19

def release_name
  @release_name
end

#styleObject

Returns the value of attribute style.



19
20
21
# File 'lib/subtitle_it/subtitle.rb', line 19

def style
  @style
end

#userObject (readonly)

Returns the value of attribute user.



19
20
21
# File 'lib/subtitle_it/subtitle.rb', line 19

def user
  @user
end

Instance Method Details

#<=>(other) ⇒ Object



54
55
56
# File 'lib/subtitle_it/subtitle.rb', line 54

def <=>(other)
  self.rating <=> other.rating
end

#data=(data) ⇒ Object



50
51
52
# File 'lib/subtitle_it/subtitle.rb', line 50

def data=(data)
  @raw = data
end

#fps=(fps) ⇒ Object



46
47
48
# File 'lib/subtitle_it/subtitle.rb', line 46

def fps=(fps)
  @fps = fps
end