diff --git a/Gemfile b/Gemfile index e8a8a62..ec1b1af 100644 --- a/Gemfile +++ b/Gemfile @@ -10,7 +10,6 @@ gem 'berkeley_library-docker', '~> 0.2.0' gem 'berkeley_library-logging', '~> 0.2' gem 'browser', '~> 4.2' gem 'jbuilder', '~> 2.7' -gem 'm3u8', '~> 0.8.2' gem 'non-stupid-digest-assets', '~> 1.0' # Allow static pages (e.g. 404.html) to link to compiled assets gem 'omniauth-cas', '~> 2.0' gem 'puma', '~> 5.3', '>= 5.3.1' diff --git a/Gemfile.lock b/Gemfile.lock index 7fce552..f988fd5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -149,7 +149,6 @@ GEM loofah (2.21.4) crass (~> 1.0.2) nokogiri (>= 1.12.0) - m3u8 (0.8.2) mail (2.8.1) mini_mime (>= 0.1.1) net-imap @@ -370,7 +369,6 @@ DEPENDENCIES dotenv-rails jbuilder (~> 2.7) listen (>= 3.0) - m3u8 (~> 0.8.2) non-stupid-digest-assets (~> 1.0) omniauth-cas (~> 2.0) puma (~> 5.3, >= 5.3.1) diff --git a/lib/av_player/track_extensions.rb b/lib/av_player/track_extensions.rb index 459b755..f93c111 100644 --- a/lib/av_player/track_extensions.rb +++ b/lib/av_player/track_extensions.rb @@ -5,7 +5,7 @@ module BerkeleyLibrary module AV - class Track # rubocop:disable Metrics/ClassLength + class Track include BerkeleyLibrary::Logging COLLECTION_RE = %r{(^[^/]+)/} @@ -22,12 +22,6 @@ def hls_uri @hls_uri ||= build_hls_uri end - def hls_vtt_uri - return @hls_vtt_uri if instance_variable_defined?(:@hls_vtt_uri) - - @hls_vtt_uri ||= find_hls_vtt_uri - end - def mpeg_dash_uri return @mpeg_dash_uri if instance_variable_defined?(:@mpeg_dash_uri) @@ -76,27 +70,6 @@ def build_mpeg_dash_uri log_invalid_uri(relative_path, e) end - def find_hls_vtt_uri - return unless hls_uri_exists? - return unless (hls_manifest_uri = hls_uri) - return unless (hls_manifest = do_get(hls_manifest_uri, ignore_errors: true)) - return unless (subtitle_list_uri = find_hls_subtitle_list_uri(hls_manifest)) - return unless (hls_subtitle_list = do_get(subtitle_list_uri, ignore_errors: true)) - - vtt_playlist = M3u8::Playlist.read(hls_subtitle_list) - return unless (hls_vtt_path_relative = vtt_playlist.items.first.segment) - - hls_uri.merge(hls_vtt_path_relative) - end - - def find_hls_subtitle_list_uri(manifest) - return unless (playlist = M3u8::Playlist.read(manifest)) - return unless (subtitle_list = playlist.items.find { |p| p.group_id == 'subs' }) - return unless (subtitle_list_uri = subtitle_list.uri) - - hls_uri.merge(subtitle_list_uri) - end - def find_dash_vtt_uri return unless (dash_uri = mpeg_dash_uri) return unless (dash_manifest = do_get(dash_uri, ignore_errors: true)) diff --git a/spec/data/breslin1-playlist.m3u8 b/spec/data/breslin1-playlist.m3u8 deleted file mode 100644 index 1508454..0000000 --- a/spec/data/breslin1-playlist.m3u8 +++ /dev/null @@ -1,5 +0,0 @@ -#EXTM3U -#EXT-X-VERSION:3 -#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="English",FORCED=NO,AUTOSELECT=YES,URI="subtitlelist_leng_w289808588.m3u8",LANGUAGE="eng" -#EXT-X-STREAM-INF:BANDWIDTH=294961,CODECS="avc1.4d4028,mp4a.40.2",RESOLUTION=320x212,SUBTITLES="subs" -chunklist_w289808588.m3u8 diff --git a/spec/data/subtitlelist_leng_w289808588.m3u8 b/spec/data/subtitlelist_leng_w289808588.m3u8 deleted file mode 100644 index db79b18..0000000 --- a/spec/data/subtitlelist_leng_w289808588.m3u8 +++ /dev/null @@ -1,7 +0,0 @@ -#EXTM3U -#EXT-X-VERSION:3 -#EXT-X-TARGETDURATION:250 -#EXT-X-MEDIA-SEQUENCE:0 -#EXTINF:140.165, -subtitlechunk_leng_w289808588_0.webvtt -#EXT-X-ENDLIST diff --git a/spec/lib/av_player/track_extensions_spec.rb b/spec/lib/av_player/track_extensions_spec.rb index 37e36c9..81db239 100644 --- a/spec/lib/av_player/track_extensions_spec.rb +++ b/spec/lib/av_player/track_extensions_spec.rb @@ -140,25 +140,6 @@ module AV expected_uri = URI.join(AV::Config.wowza_base_uri, expected_vtt_path) expect(track.dash_vtt_uri).to eq(expected_uri) end - - describe :hls_vtt_uri do - it 'returns the HLS VTT URI' do - track = Track.new(sort_order: 0, path: 'ROHOVideo/breslin1.mp4') - hls_uri = track.hls_uri - - expected_manifest_path = '/ROHOVideo/mp4:breslin1.mp4/playlist.m3u8' - expect(hls_uri.path).to eq(expected_manifest_path) # just to be sure - - stub_request(:head, hls_uri).to_return(status: 200) - stub_request(:get, hls_uri).to_return(body: File.read('spec/data/breslin1-playlist.m3u8')) - subtitle_list_uri = hls_uri.merge('subtitlelist_leng_w289808588.m3u8') - stub_request(:get, subtitle_list_uri).to_return(body: File.read('spec/data/subtitlelist_leng_w289808588.m3u8')) - - expected_vtt_path = expected_manifest_path.sub(%r{[^/]+$}, 'subtitlechunk_leng_w289808588_0.webvtt') - expected_uri = URI.join(AV::Config.wowza_base_uri, expected_vtt_path) - expect(track.hls_vtt_uri).to eq(expected_uri) - end - end end end end