Skip to content

Commit

Permalink
remove dead code in track extensions
Browse files Browse the repository at this point in the history
for iOS, it'll autodiscover the captions in the HLS stream when the viewer
is in its standard full-screen mode. the track extensions code that grabs
the HLS stream's WebVTT is thus unnecessary. this commits separates it out
in case it becomes useful in the future.
  • Loading branch information
anarchivist committed Jul 5, 2024
1 parent e147e30 commit 07263a6
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 62 deletions.
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 0 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
29 changes: 1 addition & 28 deletions lib/av_player/track_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

module BerkeleyLibrary
module AV
class Track # rubocop:disable Metrics/ClassLength
class Track
include BerkeleyLibrary::Logging

COLLECTION_RE = %r{(^[^/]+)/}
Expand All @@ -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)

Expand Down Expand Up @@ -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))
Expand Down
5 changes: 0 additions & 5 deletions spec/data/breslin1-playlist.m3u8

This file was deleted.

7 changes: 0 additions & 7 deletions spec/data/subtitlelist_leng_w289808588.m3u8

This file was deleted.

19 changes: 0 additions & 19 deletions spec/lib/av_player/track_extensions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 07263a6

Please sign in to comment.