Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rebuild the plex scanner system & added editions for movies #454

Merged
merged 2 commits into from
Sep 18, 2024
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
114 changes: 46 additions & 68 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,88 +1,57 @@
# This configuration was generated by
# `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 1000`
# on 2024-09-06 22:48:55 UTC using RuboCop version 1.66.1.
# `rubocop --auto-gen-config --exclude-limit 1000`
# on 2024-09-18 02:30:06 UTC using RuboCop version 1.66.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: leading, trailing
Layout/LineContinuationLeadingSpace:
Exclude:
- 'app/clients/the_movie_db/base.rb'

# Offense count: 6
# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: Max, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
# URISchemes: http, https
Layout/LineLength:
Lint/RedundantCopDisableDirective:
Exclude:
- 'app/models/video_blob.rb'
- 'spec/models/video_blob_spec.rb'
- 'config/initializers/simple_form.rb'
- 'config/initializers/simple_form_bootstrap.rb'

# Offense count: 1
Lint/UnreachableCode:
Exclude:
- 'lib/tasks/upload.rake'

# Offense count: 14
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
# Offense count: 18
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
Metrics/AbcSize:
Exclude:
- 'app/components/rip_process_component.rb'
- 'app/components/upload_process_component.rb'
- 'app/listeners/mkv_disk_load_listener.rb'
- 'app/listeners/mkv_progress_listener.rb'
- 'app/models/video_blob.rb'
- 'app/services/create_disks_service.rb'
- 'app/services/create_mkv_service.rb'
- 'app/tool_box/shell.rb'
- 'app/workers/load_disk_worker.rb'
- 'app/workers/scan_plex_worker.rb'
Max: 55

# Offense count: 2
# Configuration parameters: CountComments, Max, CountAsOne.
# Offense count: 3
# Configuration parameters: CountComments, CountAsOne.
Metrics/ClassLength:
Exclude:
- 'app/models/job.rb'
- 'app/models/video_blob.rb'
Max: 207

# Offense count: 3
# Configuration parameters: AllowedMethods, AllowedPatterns, Max.
# Offense count: 4
# Configuration parameters: AllowedMethods, AllowedPatterns.
Metrics/CyclomaticComplexity:
Exclude:
- 'app/controllers/start_controller.rb'
- 'app/models/video_blob.rb'
Max: 20

# Offense count: 10
# Configuration parameters: CountComments, Max, CountAsOne, AllowedMethods, AllowedPatterns.
# Offense count: 15
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
Metrics/MethodLength:
Exclude:
- 'app/components/rip_process_component.rb'
- 'app/listeners/disk_listener.rb'
- 'app/listeners/mkv_disk_load_listener.rb'
- 'app/listeners/mkv_progress_listener.rb'
- 'app/models/video_blob.rb'
- 'app/services/create_disks_service.rb'
- 'app/services/create_mkv_service.rb'
- 'app/tool_box/shell.rb'
- 'app/workers/scan_plex_worker.rb'
Max: 25

# Offense count: 1
# Configuration parameters: CountComments, Max, CountAsOne.
# Configuration parameters: CountComments, CountAsOne.
Metrics/ModuleLength:
Exclude:
- 'app/tool_box/shell.rb'
Max: 107

# Offense count: 3
# Configuration parameters: AllowedMethods, AllowedPatterns, Max.
# Offense count: 1
# Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
Metrics/ParameterLists:
Max: 12

# Offense count: 4
# Configuration parameters: AllowedMethods, AllowedPatterns.
Metrics/PerceivedComplexity:
Exclude:
- 'app/controllers/start_controller.rb'
- 'app/models/video_blob.rb'
Max: 20

# Offense count: 2
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
Expand All @@ -92,18 +61,14 @@ Naming/MethodParameterName:
- 'app/controllers/seasons_controller.rb'
- 'app/listeners/the_movie_db/video_listener.rb'

# Offense count: 1
# Configuration parameters: Max, CountAsOne.
# Offense count: 2
# Configuration parameters: CountAsOne.
RSpec/ExampleLength:
Exclude:
- 'spec/models/video_blob_spec.rb'
Max: 13

# Offense count: 4
# Configuration parameters: Max.
# Offense count: 6
RSpec/MultipleExpectations:
Exclude:
- 'spec/listeners/disk_listener_spec.rb'
- 'spec/requests/movies_request_spec.rb'
Max: 3

# Offense count: 1
# Configuration parameters: AllowSubject, Max.
Expand Down Expand Up @@ -132,3 +97,16 @@ Rails/I18nLocaleTexts:
- 'app/controllers/config/the_movie_dbs_controller.rb'
- 'app/controllers/users_controller.rb'
- 'app/models/config/slack.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Style/IfUnlessModifier:
Exclude:
- 'app/controllers/config/the_movie_dbs_controller.rb'

# Offense count: 9
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
# URISchemes: http, https
Layout/LineLength:
Max: 234
4 changes: 2 additions & 2 deletions app/clients/the_movie_db/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ def connection

def error!(response)
Rails.logger.error(
"#{response.error_type} #{response.message}" \
" #{response.code} #{response.uri} #{response.body.strip}"
"#{response.error_type} #{response.message} " \
"#{response.code} #{response.uri} #{response.body.strip}"
)
response.error!
end
Expand Down
4 changes: 4 additions & 0 deletions app/components/movie_title_table_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<th>Name(video title)</th>
<th>Duration (<%= distance_of_time_in_words @movie.movie_runtime.seconds %>)</th>
<th>Size</th>
<th>Edition</th>
<th><a class='btn btn-info' data-action="click->manage-selections#clearInputs">Select None</a></th>
</tr>
</thead>
Expand Down Expand Up @@ -55,6 +56,9 @@
WARNING: There Might Not enough space available to rip, needs another <%= number_to_human_size(disk_title.size - free_disk_space, precision: 3) %>
<% end %>
</td>
<td>
<%= text_field_tag "movies[][edition]" %>
</td>
<td class="<%= text_class %>">
<%= select_tag "movies[][extra_type]", options_for_select(VideoBlob.extra_types.keys, info.extra_type), prompt: "Don't Rip", data: { manage_selections_target: :input } %>
</td>
Expand Down
15 changes: 8 additions & 7 deletions app/controllers/movies_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ def rip
disk_titles = rip_disk_titles(disk, movie)
job = RipWorker.perform_async(
disk_id: disk.id,
disk_title_ids: disk_titles.map(&:id),
extra_types: movies_params.pluck(:extra_type).compact_blank
disk_titles:
)
redirect_to job_path(job)
end
Expand All @@ -46,16 +45,18 @@ def cancel_auto_start
private

def rip_disk_titles(disk, movie)
movies_params.filter_map do |movie_params|
next if movie_params[:extra_type].blank?

movies_params.map do |movie_params|
disk_title = disk.disk_titles.find(movie_params[:disk_title_id])
disk_title.update!(video: movie)
disk_title
{
id: disk_title.id,
extra_type: movie_params[:extra_type].to_sym,
edition: movie_params[:edition]
}
end
end

def movies_params
params.required(:movies)
@movies_params ||= params.required(:movies).reject { _1[:extra_type].blank? }
end
end
4 changes: 2 additions & 2 deletions app/controllers/seasons_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def rip
season = tv.seasons.find(params[:id])
disk = Disk.find(params[:disk_id])
disk_titles = rip_disk_titles(tv, disk, season)
job = RipWorker.perform_async(disk_id: disk.id, disk_title_ids: disk_titles.map(&:id))
job = RipWorker.perform_async(disk_id: disk.id, disk_titles:)
redirect_to job_path(job)
end

Expand All @@ -25,7 +25,7 @@ def rip_disk_titles(tv, disk, season)
episode = season.episodes.find { _1.id == episode_param[:id].to_i }
disk_title = disk.disk_titles.find { _1.id == episode_param[:disk_title_id].to_i }
disk_title.update!(video: tv, episode:)
disk_title
{ id: disk_title.id }
end
end

Expand Down
2 changes: 2 additions & 0 deletions app/javascript/controllers/manage_selections_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ export default class extends Controller {
}
})
}


}
6 changes: 4 additions & 2 deletions app/listeners/disk_listener.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ def disk_loaded(disk)
info_disk_titles = rip_disk_titles(disk, video)
return reload_page! if info_disk_titles.empty?

disk_titles = info_disk_titles.map do |info|
{ id: info.disk_title.id, extra_type: info.extra_type }
end
job = RipWorker.perform_async(
disk_id: disk.id,
disk_title_ids: info_disk_titles.map { _1.disk_title.id },
extra_types: info_disk_titles.map(&:extra_type)
disk_titles:
)
if job
video.update!(auto_start: false)
Expand Down
Loading
Loading