Skip to content

Commit

Permalink
No longer fail on invalid audio and subtitle track information.
Browse files Browse the repository at this point in the history
  • Loading branch information
lisamelton committed May 13, 2015
1 parent 7b910c7 commit b45afe2
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions lib/video_transcoding/media.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def info
@scan = Media.scan(@path, @title, @previews)
end

if @scan =~ / libhb: scan thread found ([0-9.]+) valid title/
if @scan =~ / libhb: scan thread found ([0-9]+) valid title/
fail 'multiple titles found' if $1.to_i > 1
end

Expand Down Expand Up @@ -92,7 +92,7 @@ def info

return @info unless @extended

unless @scan =~ / \+ audio tracks:\r?\n(.*) \+ subtitle tracks:\r?\n(.*)(?:\r?\n)?HandBrake has exited./m
unless @scan =~ / \+ audio tracks:\r?\n(.*) \+ subtitle tracks:\r?\n(.*)HandBrake has exited./m
fail 'audio and subtitle information not found'
end

Expand All @@ -102,7 +102,7 @@ def info
@info[:subtitle] = {}

audio.gsub(/\r/, '').each_line do |line|
if line =~ /^ \+ ([0-9.]+), [^(]+\(([^)]+)\) .*\(([0-9.]+) ch\) .*\(iso639-2: ([a-z]{3})\)/
if line =~ /^ \+ ([0-9]+), [^(]+\(([^)]+)\) .*\(([0-9.]+) ch\) .*\(iso639-2: ([a-z]{3})\)/
track = $1.to_i
track_info = {}
track_info[:format] = $2
Expand All @@ -116,20 +116,16 @@ def info
end

@info[:audio][track] = track_info
else
fail "invalid audio track information: #{line}"
end
end

subtitle.gsub(/\r/, '').each_line do |line|
if line =~ /^ \+ ([0-9.]+), .*\(iso639-2: ([a-z]{3})\) \((?:Text|Bitmap)\)\(([^)]+)\)/
if line =~ /^ \+ ([0-9]+), .*\(iso639-2: ([a-z]{3})\) \((?:Text|Bitmap)\)\(([^)]+)\)/
track = $1.to_i
track_info = {}
track_info[:language] = $2
track_info[:format] = $3
@info[:subtitle][track] = track_info
else
fail "invalid subtitle track information: #{line}"
end
end

Expand Down

0 comments on commit b45afe2

Please sign in to comment.