Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Metrics/CyclomaticComplexity:
Metrics/PerceivedComplexity:
Enabled: false
Layout/LineLength:
Max: 120
Max: 80
Exclude:
- 'spec/**/*'
Style/StringLiterals:
Expand Down
18 changes: 14 additions & 4 deletions lib/m3u8/playlist.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,21 +183,29 @@ def validate_key_items(errors)
keys.each do |item|
next if item.method == 'NONE'

errors << 'Key item requires a URI when method is not NONE' if item.uri.nil?
next unless item.uri.nil?

errors << 'Key item requires a URI ' \
'when method is not NONE'
end
end

def validate_session_key_items(errors)
session_keys.each do |item|
next if item.method == 'NONE'

errors << 'Session key item requires a URI when method is not NONE' if item.uri.nil?
next unless item.uri.nil?

errors << 'Session key item requires a URI ' \
'when method is not NONE'
end
end

def validate_playlist_items(errors)
playlists.each do |item|
errors << 'Playlist item requires a bandwidth' unless item.bandwidth&.positive?
unless item.bandwidth&.positive?
errors << 'Playlist item requires a bandwidth'
end
errors << 'Playlist item requires a URI' if item.uri.nil?
end
end
Expand All @@ -213,7 +221,9 @@ def validate_media_items(errors)
def validate_segment_items(errors)
segments.each do |segment|
errors << 'Segment item requires a segment URI' if segment.segment.nil?
errors << 'Segment item has negative duration' if segment.duration&.negative?
if segment.duration&.negative?
errors << 'Segment item has negative duration'
end
end
end

Expand Down
8 changes: 6 additions & 2 deletions lib/m3u8/playlist_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,9 @@ def audio_codec_code
return 'mp4a.40.5' if @audio_codec.casecmp('he-aac').zero?
return 'mp4a.40.34' if @audio_codec.casecmp('mp3').zero?
return 'ac-3' if @audio_codec.casecmp('ac-3').zero?
return 'ec-3' if %w[ec-3 e-ac-3].any? { |c| @audio_codec.casecmp(c).zero? }
if %w[ec-3 e-ac-3].any? { |c| @audio_codec.casecmp(c).zero? }
return 'ec-3'
end
return 'fLaC' if @audio_codec.casecmp('flac').zero?

'Opus' if @audio_codec.casecmp('opus').zero?
Expand Down Expand Up @@ -294,7 +296,9 @@ def main_codec_string(level)
end

def high_codec_string(level)
return nil unless [3.0, 3.1, 3.2, 4.0, 4.1, 4.2, 5.0, 5.1, 5.2].include?(level)
levels = [3.0, 3.1, 3.2, 4.0, 4.1, 4.2,
5.0, 5.1, 5.2]
return nil unless levels.include?(level)

level_hex_string = level.to_s.sub('.', '').to_i.to_s(16)
"avc1.6400#{level_hex_string}"
Expand Down
3 changes: 2 additions & 1 deletion lib/m3u8/scte35.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ def self.parse_single_descriptor(reader, tag, length)
end

def self.command_data_length(reader, header)
return header[:splice_command_length] unless header[:splice_command_length] == 0xFFF
length = header[:splice_command_length]
return length unless length == 0xFFF

if unknown_command_with_unspecified_length?(header)
# Unknown command: consume everything up to CRC
Expand Down
4 changes: 3 additions & 1 deletion lib/m3u8/scte35_segmentation_descriptor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ def self.parse_upid(reader, attrs)
upid_length = reader.read_bits(8)
return if upid_length.zero?

attrs[:segmentation_upid] = reader.read_bytes(upid_length).force_encoding('UTF-8')
attrs[:segmentation_upid] =
reader.read_bytes(upid_length)
.force_encoding('UTF-8')
end

private_class_method :parse_segmentation_detail, :parse_upid
Expand Down
6 changes: 6 additions & 0 deletions m3u8.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ Gem::Specification.new do |spec|
spec.license = 'MIT'
spec.required_ruby_version = '>= 3.1'

spec.metadata = {
'source_code_uri' => 'https://github.com/sethdeckard/m3u8',
'changelog_uri' => 'https://github.com/sethdeckard/m3u8/blob/master/CHANGELOG.md',
'bug_tracker_uri' => 'https://github.com/sethdeckard/m3u8/issues'
}

spec.files = `git ls-files -z`.split("\x0")
.grep_v(/\A(CLAUDE|AGENTS)\.md\z/)
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
Expand Down