Class: FFSplitter::MetadataParser

Inherits:
Object
  • Object
show all
Defined in:
lib/ffsplitter/metadata_parser.rb

Class Method Summary collapse

Class Method Details

.parse(metadata) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/ffsplitter/metadata_parser.rb', line 3

def self.parse()
  chapter_list = ChapterList.new
  chapter = nil

  .split("\n").each do |line|
    if line =~ /CHAPTER/
      chapter = Chapter.new
    end

    if line =~ /TIMEBASE=(\d+)\/(\d+)/
      chapter.timebase = $1.to_f / $2.to_f
    end

    if line =~ /START=(\d+)/
      chapter.start_frames = $1
    end

    if line =~ /END=(\d+)/
      chapter.end_frames = $1
    end

    if chapter && line =~ /title=(.*)/
      chapter.title = $1
      chapter_list.add(chapter)
    end
  end

  chapter_list
end