m3u8 0.8.2 → 1.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/ci.yml +23 -0
  3. data/.gitignore +1 -1
  4. data/.rubocop.yml +31 -0
  5. data/CHANGELOG.md +107 -0
  6. data/Gemfile +7 -0
  7. data/LICENSE.txt +1 -1
  8. data/README.md +524 -40
  9. data/Rakefile +1 -0
  10. data/bin/m3u8 +6 -0
  11. data/lib/m3u8/attribute_formatter.rb +47 -0
  12. data/lib/m3u8/bitrate_item.rb +31 -0
  13. data/lib/m3u8/builder.rb +48 -0
  14. data/lib/m3u8/byte_range.rb +10 -0
  15. data/lib/m3u8/cli/inspect_command.rb +97 -0
  16. data/lib/m3u8/cli/validate_command.rb +24 -0
  17. data/lib/m3u8/cli.rb +116 -0
  18. data/lib/m3u8/codecs.rb +89 -0
  19. data/lib/m3u8/content_steering_item.rb +45 -0
  20. data/lib/m3u8/date_range_item.rb +135 -64
  21. data/lib/m3u8/define_item.rb +54 -0
  22. data/lib/m3u8/discontinuity_item.rb +3 -0
  23. data/lib/m3u8/encryptable.rb +27 -30
  24. data/lib/m3u8/error.rb +1 -0
  25. data/lib/m3u8/gap_item.rb +14 -0
  26. data/lib/m3u8/key_item.rb +7 -0
  27. data/lib/m3u8/map_item.rb +16 -5
  28. data/lib/m3u8/media_item.rb +48 -76
  29. data/lib/m3u8/part_inf_item.rb +35 -0
  30. data/lib/m3u8/part_item.rb +67 -0
  31. data/lib/m3u8/playback_start.rb +19 -12
  32. data/lib/m3u8/playlist.rb +221 -13
  33. data/lib/m3u8/playlist_item.rb +128 -124
  34. data/lib/m3u8/preload_hint_item.rb +54 -0
  35. data/lib/m3u8/reader.rb +86 -28
  36. data/lib/m3u8/rendition_report_item.rb +48 -0
  37. data/lib/m3u8/scte35.rb +130 -0
  38. data/lib/m3u8/scte35_bit_reader.rb +51 -0
  39. data/lib/m3u8/scte35_segmentation_descriptor.rb +54 -0
  40. data/lib/m3u8/scte35_splice_insert.rb +62 -0
  41. data/lib/m3u8/scte35_splice_null.rb +8 -0
  42. data/lib/m3u8/scte35_time_signal.rb +19 -0
  43. data/lib/m3u8/segment_item.rb +37 -3
  44. data/lib/m3u8/server_control_item.rb +69 -0
  45. data/lib/m3u8/session_data_item.rb +17 -28
  46. data/lib/m3u8/session_key_item.rb +8 -1
  47. data/lib/m3u8/skip_item.rb +48 -0
  48. data/lib/m3u8/time_item.rb +10 -0
  49. data/lib/m3u8/version.rb +1 -1
  50. data/lib/m3u8/writer.rb +24 -1
  51. data/lib/m3u8.rb +30 -6
  52. data/m3u8.gemspec +12 -12
  53. data/spec/fixtures/content_steering.m3u8 +10 -0
  54. data/spec/fixtures/daterange_playlist.m3u8 +14 -0
  55. data/spec/fixtures/encrypted_discontinuity.m3u8 +17 -0
  56. data/spec/fixtures/event_playlist.m3u8 +18 -0
  57. data/spec/fixtures/gap_playlist.m3u8 +14 -0
  58. data/spec/fixtures/ll_hls_advanced.m3u8 +18 -0
  59. data/spec/fixtures/ll_hls_playlist.m3u8 +20 -0
  60. data/spec/fixtures/master_full.m3u8 +14 -0
  61. data/spec/fixtures/master_v13.m3u8 +8 -0
  62. data/spec/lib/m3u8/bitrate_item_spec.rb +26 -0
  63. data/spec/lib/m3u8/builder_spec.rb +352 -0
  64. data/spec/lib/m3u8/byte_range_spec.rb +1 -0
  65. data/spec/lib/m3u8/cli/inspect_command_spec.rb +102 -0
  66. data/spec/lib/m3u8/cli/validate_command_spec.rb +39 -0
  67. data/spec/lib/m3u8/cli_spec.rb +104 -0
  68. data/spec/lib/m3u8/content_steering_item_spec.rb +56 -0
  69. data/spec/lib/m3u8/date_range_item_spec.rb +159 -31
  70. data/spec/lib/m3u8/define_item_spec.rb +59 -0
  71. data/spec/lib/m3u8/discontinuity_item_spec.rb +1 -0
  72. data/spec/lib/m3u8/gap_item_spec.rb +12 -0
  73. data/spec/lib/m3u8/key_item_spec.rb +1 -0
  74. data/spec/lib/m3u8/map_item_spec.rb +1 -0
  75. data/spec/lib/m3u8/media_item_spec.rb +34 -0
  76. data/spec/lib/m3u8/part_inf_item_spec.rb +27 -0
  77. data/spec/lib/m3u8/part_item_spec.rb +67 -0
  78. data/spec/lib/m3u8/playback_start_spec.rb +4 -5
  79. data/spec/lib/m3u8/playlist_item_spec.rb +130 -17
  80. data/spec/lib/m3u8/playlist_spec.rb +545 -13
  81. data/spec/lib/m3u8/preload_hint_item_spec.rb +57 -0
  82. data/spec/lib/m3u8/reader_spec.rb +376 -29
  83. data/spec/lib/m3u8/rendition_report_item_spec.rb +56 -0
  84. data/spec/lib/m3u8/round_trip_spec.rb +152 -0
  85. data/spec/lib/m3u8/scte35_bit_reader_spec.rb +106 -0
  86. data/spec/lib/m3u8/scte35_segmentation_descriptor_spec.rb +143 -0
  87. data/spec/lib/m3u8/scte35_spec.rb +94 -0
  88. data/spec/lib/m3u8/scte35_splice_insert_spec.rb +185 -0
  89. data/spec/lib/m3u8/scte35_splice_null_spec.rb +12 -0
  90. data/spec/lib/m3u8/scte35_time_signal_spec.rb +50 -0
  91. data/spec/lib/m3u8/segment_item_spec.rb +47 -0
  92. data/spec/lib/m3u8/server_control_item_spec.rb +64 -0
  93. data/spec/lib/m3u8/session_data_item_spec.rb +1 -0
  94. data/spec/lib/m3u8/session_key_item_spec.rb +1 -0
  95. data/spec/lib/m3u8/skip_item_spec.rb +48 -0
  96. data/spec/lib/m3u8/time_item_spec.rb +1 -0
  97. data/spec/lib/m3u8/writer_spec.rb +69 -30
  98. data/spec/lib/m3u8_spec.rb +1 -0
  99. data/spec/spec_helper.rb +4 -87
  100. metadata +70 -129
  101. data/.hound.yml +0 -3
  102. data/.travis.yml +0 -8
  103. data/Guardfile +0 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 79a1150cd18985b297585a60de9670a486eb1206
4
- data.tar.gz: 723fc2ccb9856cadb5758678861e3e57b853d2c6
2
+ SHA256:
3
+ metadata.gz: 00157be29743342bb6156539b9fca6a1e67ae9ae60e74cab04eebeda10a888ec
4
+ data.tar.gz: f82b069b8fef0ce72694b11640431b25ea04caa7616ee69ab6c56e9f9029fdc3
5
5
  SHA512:
6
- metadata.gz: 1ebb81bf922cee507b51beb8f608d7779a4ff35d64b935760e285675ce8715ae4e036748f622bdb91b762daf291e267fa1374bf6252631743582374be55fc611
7
- data.tar.gz: 4983b2b1cb6826eb5293bf5df6011e203ed9067cac4a4e218a3e2537c9948f0dda8318028156cf3e5a9b392f1aa2a2418d61651223c2a14a59d58b86902d6e19
6
+ metadata.gz: 659a5a703d0a00887b9dc724bb252aeb56fb44010756772f8667b62ebd77b34b6b3a4f647c0c6aaf46cdfbfafbdf5173b59db2f1a84efa34fd4c5b4aafbab732
7
+ data.tar.gz: 07a539694c4231895fd0f7eebfb18f860c0dbbcbdd0f63e31b50ce7485937dc84fcac198ad443f9f6591bed7c17d32839bae7aba3904e452781e98520f21153c
@@ -0,0 +1,23 @@
1
+ name: CI
2
+ on:
3
+ push:
4
+ branches: [master]
5
+ pull_request:
6
+ branches: [master]
7
+ jobs:
8
+ test:
9
+ runs-on: ubuntu-latest
10
+ strategy:
11
+ matrix:
12
+ ruby-version: ['3.1', '3.2', '3.3', '3.4']
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+ - name: Set up Ruby ${{ matrix.ruby-version }}
16
+ uses: ruby/setup-ruby@v1
17
+ with:
18
+ ruby-version: ${{ matrix.ruby-version }}
19
+ bundler-cache: true
20
+ - name: Run tests
21
+ run: bundle exec rspec
22
+ - name: Run linter
23
+ run: bundle exec rubocop
data/.gitignore CHANGED
@@ -2,5 +2,5 @@
2
2
  /coverage
3
3
  /pkg
4
4
  /tmp
5
- .Gemfile.lock
5
+ Gemfile.lock
6
6
  .ruby-version
data/.rubocop.yml CHANGED
@@ -1,9 +1,40 @@
1
1
  AllCops:
2
+ TargetRubyVersion: 3.1
3
+ NewCops: enable
4
+ SuggestExtensions: false
2
5
  Exclude:
3
6
  - 'spec/spec_helper.rb'
4
7
  - 'm3u8.gemspec'
8
+ - 'vendor/**/*'
5
9
  Metrics/BlockLength:
6
10
  Exclude:
7
11
  - 'spec/**/*'
12
+ Metrics/MethodLength:
13
+ Max: 20
14
+ Exclude:
15
+ - 'spec/**/*'
16
+ Metrics/AbcSize:
17
+ Max: 35
18
+ Exclude:
19
+ - 'spec/**/*'
20
+ Metrics/ClassLength:
21
+ Enabled: false
22
+ Metrics/CyclomaticComplexity:
23
+ Enabled: false
24
+ Metrics/PerceivedComplexity:
25
+ Enabled: false
26
+ Layout/LineLength:
27
+ Max: 80
28
+ Exclude:
29
+ - 'spec/**/*'
8
30
  Style/StringLiterals:
9
31
  EnforcedStyle: single_quotes
32
+ Style/StringConcatenation:
33
+ Exclude:
34
+ - 'spec/**/*'
35
+ Lint/FloatComparison:
36
+ Enabled: false
37
+ Lint/DuplicateMethods:
38
+ Enabled: false
39
+ Naming/PredicateMethod:
40
+ Enabled: false
data/CHANGELOG.md CHANGED
@@ -1,3 +1,110 @@
1
+ **1.8.1**
2
+
3
+ * Merged pull request #59 from [marocchino](https://github.com/marocchino).
4
+ Fixes floating-point formatting issue (#58).
5
+
6
+ ***
7
+
8
+ **1.8.0**
9
+
10
+ * Standardized all item classes to use class-level `self.parse` methods,
11
+ converting `PlaybackStart`, `DateRangeItem`, `PlaylistItem`, and
12
+ `SegmentItem` from instance-level parse.
13
+ * Applied `AttributeFormatter` to `MapItem` and `PartItem`, replacing
14
+ manual format helpers with `quoted_format` and `unquoted_format`.
15
+ * Extracted `tag_value` helper in `Reader`, replacing repeated `gsub`
16
+ tag-prefix patterns.
17
+ * Normalized `Reader` lambda syntax, converting `proc` blocks to
18
+ lambdas.
19
+ * Removed `include M3u8` from `Reader` since all parsing now uses
20
+ class-level methods.
21
+ * Added YARD `@param`/`@return` documentation to all public methods
22
+ and attributes across the entire codebase.
23
+
24
+ ***
25
+
26
+ **1.7.0**
27
+
28
+ * Added HLS Interstitials first-class `DateRangeItem` accessors:
29
+ `asset_uri`, `asset_list`, `resume_offset`, `playout_limit`,
30
+ `restrict`, `snap`, `timeline_occupies`, `timeline_style`, and
31
+ `content_may_vary`.
32
+ * Promoted supported interstitial `X-` attributes out of
33
+ `client_attributes` into typed fields during parsing and formatting.
34
+ * Refactored `DateRangeItem` attribute formatting helpers to reduce
35
+ duplication while preserving output behavior.
36
+
37
+ ***
38
+
39
+ **1.6.0**
40
+
41
+ * Added SCTE-35 parsing with `M3u8::Scte35` for `splice_info_section`
42
+ payloads, including `splice_null` (0x00), `splice_insert` (0x05),
43
+ `time_signal` (0x06), and descriptor loop parsing.
44
+ * Added `DateRangeItem` SCTE-35 convenience methods:
45
+ `scte35_cmd_info`, `scte35_out_info`, and `scte35_in_info`.
46
+ * Added parsing support for SCTE-35 segmentation descriptors
47
+ (`segmentation_descriptor`, tag 0x02 with `CUEI` identifier).
48
+ * Added `M3u8::Scte35::ParseError` for malformed SCTE-35 payloads.
49
+ * Documented SCTE-35 usage and parsed fields in README.
50
+
51
+ ***
52
+
53
+ **1.5.0**
54
+
55
+ * Added `Playlist#freeze` for deep-freezing playlists, items, nested objects, and playlist-level objects. `Playlist.build` and `Playlist.read` now return frozen playlists. `Playlist.new` remains mutable until `freeze` is called explicitly.
56
+
57
+ ***
58
+
59
+ **1.4.0**
60
+
61
+ * Added `Playlist#errors` method returning an array of validation error messages. `Playlist#valid?` now delegates to `errors.empty?`. Validates mixed item types, target duration, segment items, playlist items, media items, encryption keys, session keys, session data, and LL-HLS part items.
62
+ * Updated CLI `validate` command to display specific error messages.
63
+ * Updated `Writer` to include specific errors in the exception message.
64
+
65
+ ***
66
+
67
+ **1.3.1**
68
+
69
+ * Excluded CLAUDE.md and AGENTS.md from gem package.
70
+
71
+ ***
72
+
73
+ **1.3.0**
74
+
75
+ * Added CLI tool (`bin/m3u8`) with `inspect` and `validate` subcommands for inspecting playlist metadata and checking validity from the command line. Supports file arguments and stdin piping.
76
+ * Added `session_keys` convenience accessor to `Playlist`.
77
+
78
+ ***
79
+
80
+ **1.2.0**
81
+
82
+ * Added `Playlist.build` with block-based Builder DSL for concise playlist construction. Supports both `instance_eval` (clean DSL) and yielded builder (outer scope access) forms. All 19 item types have corresponding DSL methods.
83
+
84
+ ***
85
+
86
+ **1.1.0**
87
+
88
+ * Added convenience accessor methods to `Playlist` for filtering items by type: `segments`, `playlists`, `media_items`, `keys`, `maps`, `date_ranges`, `parts`, `session_data`.
89
+
90
+ ***
91
+
92
+ **1.0.0**
93
+
94
+ * Full HLS spec compliance with draft-pantos-hls-rfc8216bis-19 (Protocol Version 13).
95
+ * Added Low-Latency HLS support: `EXT-X-PART`, `EXT-X-PART-INF`, `EXT-X-SERVER-CONTROL`, `EXT-X-SKIP`, `EXT-X-PRELOAD-HINT`, `EXT-X-RENDITION-REPORT`.
96
+ * Added HEVC/H.265 and AV1 video codec string generation.
97
+ * Added AC-3, E-AC-3, FLAC, and Opus audio codec string generation.
98
+ * Added new attributes to `PlaylistItem`: `STABLE-VARIANT-ID`, `VIDEO-RANGE`, `ALLOWED-CPC`, `PATHWAY-ID`, `REQ-VIDEO-LAYOUT`, `SUPPLEMENTAL-CODECS`, `SCORE`.
99
+ * Added new attributes to `MediaItem`: `STABLE-RENDITION-ID`, `BIT-DEPTH`, `SAMPLE-RATE`.
100
+ * Added `EXT-X-CONTENT-STEERING` tag support.
101
+ * Added `EXT-X-DEFINE` tag support.
102
+ * Added `EXT-X-GAP` and `EXT-X-BITRATE` tag support.
103
+ * Upgraded CI from Travis CI to GitHub Actions.
104
+ * Requires Ruby 3.0+.
105
+
106
+ ***
107
+
1
108
  **0.8.1**
2
109
  Merged pull request #23 from [ryanische](https:/github.com/ryanische) which fixes issue of CODEC attribute validation not matching the HLS I-D.
3
110
 
data/Gemfile CHANGED
@@ -1,5 +1,12 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  source 'https://rubygems.org'
3
4
 
4
5
  # Specify your gem's dependencies in m3u8.gemspec
5
6
  gemspec
7
+
8
+ gem 'rake'
9
+ gem 'rspec', '>= 3.0'
10
+ gem 'rubocop', require: false
11
+ gem 'rubocop-rake', require: false
12
+ gem 'simplecov', require: false
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2016 Seth Deckard
1
+ Copyright (c) 2014-2026 Seth Deckard
2
2
 
3
3
  MIT License
4
4