Class: EhbrsRubyUtils::WebUtils::Videos::FilesList
- Inherits:
-
Object
- Object
- EhbrsRubyUtils::WebUtils::Videos::FilesList
- Defined in:
- lib/ehbrs_ruby_utils/web_utils/videos/files_list.rb
Instance Method Summary collapse
- #data ⇒ Object
- #file_data(path) ⇒ Object
- #file_ffprobe_data(path) ⇒ Object
- #files_data ⇒ Object
- #movies_files_data ⇒ Object
- #series_files_data ⇒ Object
- #write_to(path = nil) ⇒ Object
Instance Method Details
#data ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/ehbrs_ruby_utils/web_utils/videos/files_list.rb', line 27 def data { root_path: root_path.to_path, type: type_class, files: files_data } end |
#file_data(path) ⇒ Object
59 60 61 62 63 |
# File 'lib/ehbrs_ruby_utils/web_utils/videos/files_list.rb', line 59 def file_data(path) r = { original_path: path } r[:ffprobe_data] = file_ffprobe_data(path) if ::File.file?(path) r end |
#file_ffprobe_data(path) ⇒ Object
65 66 67 68 69 70 71 72 |
# File 'lib/ehbrs_ruby_utils/web_utils/videos/files_list.rb', line 65 def file_ffprobe_data(path) return {} unless .fetch(:ffprobe) infom "Probing \"#{path}\"..." ::JSON.parse(::EhbrsRubyUtils::Executables.ffprobe.command( '-hide_banner', '-print_format', 'json', '-show_format', '-show_streams', path ).execute!) end |
#files_data ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/ehbrs_ruby_utils/web_utils/videos/files_list.rb', line 35 def files_data case type_class when 'Videos::MovieFile' then movies_files_data when 'Videos::SeriesDirectory' then series_files_data else raise "Unknown type class: \"#{type_class}\"" end end |
#movies_files_data ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/ehbrs_ruby_utils/web_utils/videos/files_list.rb', line 43 def movies_files_data r = [] Dir["#{root_path}/**/*"].each do |path| r << file_data(path) if ::File.file?(path) end r end |
#series_files_data ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/ehbrs_ruby_utils/web_utils/videos/files_list.rb', line 51 def series_files_data r = [] Dir["#{root_path}/*"].each do |path| r << file_data(path) if ::File.directory?(path) end r end |
#write_to(path = nil) ⇒ Object
21 22 23 24 25 |
# File 'lib/ehbrs_ruby_utils/web_utils/videos/files_list.rb', line 21 def write_to(path = nil) path ||= ::EacRubyUtils::Fs::Temp.file.to_path ::File.write(path, data.to_json) path end |