Class: Ehbrs::Tools::Runner::WebUtils::Videos::Upload
- Inherits:
-
Object
- Object
- Ehbrs::Tools::Runner::WebUtils::Videos::Upload
- Defined in:
- lib/ehbrs/tools/runner/web_utils/videos/upload.rb
Instance Method Summary collapse
- #movies_files_list_uncached ⇒ Object
- #process_response(files_list_path) ⇒ Object
- #run ⇒ Object
- #series_files_list_uncached ⇒ Object
- #upload_files_list(type) ⇒ Object
- #upload_request(files_list_path) ⇒ Object
- #write_files_list(file_class, read_entry) ⇒ Object
Instance Method Details
#movies_files_list_uncached ⇒ Object
54 55 56 |
# File 'lib/ehbrs/tools/runner/web_utils/videos/upload.rb', line 54 def movies_files_list_uncached write_files_list('Videos::MovieFile', :movies_directory) end |
#process_response(files_list_path) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/ehbrs/tools/runner/web_utils/videos/upload.rb', line 43 def process_response(files_list_path) upload_request(files_list_path).body rescue ::EhbrsRubyUtils::WebUtils::RequestError => e system('firefox', e.body_file_path.to_path) fatal_error("Retornou com erro: #{e.}") end |
#run ⇒ Object
19 20 21 |
# File 'lib/ehbrs/tools/runner/web_utils/videos/upload.rb', line 19 def run %w[movies series].each { |type| upload_files_list(type) } end |
#series_files_list_uncached ⇒ Object
50 51 52 |
# File 'lib/ehbrs/tools/runner/web_utils/videos/upload.rb', line 50 def series_files_list_uncached write_files_list('Videos::SeriesDirectory', :series_directory) end |
#upload_files_list(type) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/ehbrs/tools/runner/web_utils/videos/upload.rb', line 23 def upload_files_list(type) infom "Uploading \"#{type}\" files list..." files_list_path = send("#{type}_files_list") infov 'Path', files_list_path process_response(files_list_path) end |
#upload_request(files_list_path) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/ehbrs/tools/runner/web_utils/videos/upload.rb', line 30 def upload_request(files_list_path) runner_context.call(:instance).http_request( '/videos/files/import', method: :put, body: { 'videos_local_files_import_list[list_file]' => ::File.new(files_list_path) }, header: { 'Accept' => 'application/json' } ) end |
#write_files_list(file_class, read_entry) ⇒ Object
58 59 60 61 62 63 64 65 66 |
# File 'lib/ehbrs/tools/runner/web_utils/videos/upload.rb', line 58 def write_files_list(file_class, read_entry) files_list = ::EhbrsRubyUtils::WebUtils::Videos::FilesList.new( file_class, runner_context.call(:instance).read_entry(read_entry), ffprobe: !parsed.no_ffprobe? ) infov 'Files found', files_list.data.fetch(:files).count files_list.write_to end |