diff --git a/app/components/movie_title_table_component.html.erb b/app/components/movie_title_table_component.html.erb index 03399f7a..62dcac90 100644 --- a/app/components/movie_title_table_component.html.erb +++ b/app/components/movie_title_table_component.html.erb @@ -1,34 +1,40 @@ - - - - - - - - - - - - <% disks.each do |disk| %> - <% disk.disk_titles.sort_by { |d| movie.runtime_range.include?(d.duration) ? 0 : 1 }.each do |disk_title| %> - <% text_class = 'text-primary-emphasis' if movie.runtime_range.include?(disk_title.duration) %> - - - - - - - +<% if disks.any? %> +
#NameDurationSize
<%= disk_title.id %><%= disk_title.name %><%= distance_of_time_in_words(disk_title.duration.seconds) %> - <%= number_to_human_size(disk_title.size, precision: 3) %> - <% if disk_title.size >= free_disk_space %> - WARNING: Not enough space available to rip need another <%= number_to_human_size(disk_title.size - free_disk_space, precision: 3) %> - <% end %> - - <%= link_to 'Rip', video_disk_title_path(movie, disk_title), data: { turbo_method: :patch } %> -
+ + + + + + + + + + + <% disks.each do |disk| %> + <% disk.disk_titles.sort_by { |d| movie.runtime_range.include?(d.duration) ? 0 : 1 }.each do |disk_title| %> + <% text_class = 'text-primary-emphasis' if movie.runtime_range.include?(disk_title.duration) %> + <% text_class = 'text-success-emphasis' if movie.disk_title&.name == disk_title.name %> + + + + + + + + <% end %> <% end %> - - <% end %> - -
#NameDuration (<%= distance_of_time_in_words @movie.movie_runtime.seconds %>)Size
<%= disk_title.id %><%= disk_title.name %><%= distance_of_time_in_words(disk_title.duration.seconds) %> + <%= number_to_human_size(disk_title.size, precision: 3) %> + <% if disk_title.size >= free_disk_space %> + WARNING: Not enough space available to rip need another <%= number_to_human_size(disk_title.size - free_disk_space, precision: 3) %> + <% end %> + + <%= link_to 'Rip', video_disk_title_path(movie, disk_title), data: { turbo_method: :patch } %> +
+ + +<% elsif LoadDiskWorker.job.pending? %> +

Loading Disk this might takes a while. Page will reload once ready. Fell free to refresh the page.

+<% else %> +

Sorry no Disk is currently loaded or could be detected. Refresh page if your seeing this warning but know a disk is present.

+<% end %> diff --git a/app/components/movie_title_table_component.rb b/app/components/movie_title_table_component.rb index 71390aee..7cb901ff 100644 --- a/app/components/movie_title_table_component.rb +++ b/app/components/movie_title_table_component.rb @@ -3,7 +3,7 @@ class MovieTitleTableComponent < ViewComponent::Base extend Dry::Initializer - option :disks, Types::Array.of(Types.Instance(Disk)) + option :disks, Types::Coercible::Array.of(Types.Instance(Disk)) option :movie, Types.Instance(Movie) def dom_id diff --git a/app/services/list_drives_service.rb b/app/services/list_drives_service.rb index f3a69a63..41a3dd54 100644 --- a/app/services/list_drives_service.rb +++ b/app/services/list_drives_service.rb @@ -2,14 +2,12 @@ class ListDrivesService extend Dry::Initializer - include Shell - include MkvParser option :noscan, Types::Bool, default: -> { false } class << self - def results(*) - new(*).results + def results(...) + new(...).results end end @@ -32,7 +30,7 @@ def info end def drives - @drives ||= parse_mkv_string(info.stdout_str).select do |i| + @drives ||= info.parsed_mkv.select do |i| i.is_a?(MkvParser::DRV) && i.enabled.to_i.positive? end end diff --git a/app/views/movies/show.html.erb b/app/views/movies/show.html.erb index 0ea4eb60..fb756d25 100644 --- a/app/views/movies/show.html.erb +++ b/app/views/movies/show.html.erb @@ -17,6 +17,9 @@ <%= link_to_movie_db_movie @movie.the_movie_db_id %>

+

Blue Means the disk title is within the runtime range of the movie.

+

Gream Means the disk has been ripped before.

+
<%= render MovieTitleTableComponent.new(disks: @disks, movie: @movie) %>
diff --git a/app/workers/rip_worker.rb b/app/workers/rip_worker.rb index d05fdf7c..a79c4342 100644 --- a/app/workers/rip_worker.rb +++ b/app/workers/rip_worker.rb @@ -23,7 +23,7 @@ def create_mkv(disk_title) def upload_mkv(disk_title) sleep 1 while UploadWorker.job.pending? - UploadWorker.perform_async(disk_title) + UploadWorker.perform_async(disk_title:) end def disk_titles