Class: SimplePvr::RecordingManager
- Inherits:
-
Object
- Object
- SimplePvr::RecordingManager
- Defined in:
- lib/simple_pvr/recording_manager.rb
Instance Method Summary collapse
- #create_directory_for_recording(recording) ⇒ Object
- #delete_show(show_name) ⇒ Object
- #delete_show_recording(show_name, recording_id) ⇒ Object
- #directory_for_show_and_recording(show_name, recording_id) ⇒ Object
-
#initialize(recordings_directory) ⇒ RecordingManager
constructor
A new instance of RecordingManager.
- #metadata_for(show_name, recording_id) ⇒ Object
- #recordings_of(show_name) ⇒ Object
- #shows ⇒ Object
Constructor Details
#initialize(recordings_directory) ⇒ RecordingManager
Returns a new instance of RecordingManager.
5 6 7 |
# File 'lib/simple_pvr/recording_manager.rb', line 5 def initialize(recordings_directory) @recordings_directory = recordings_directory end |
Instance Method Details
#create_directory_for_recording(recording) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/simple_pvr/recording_manager.rb', line 58 def create_directory_for_recording(recording) show_directory = directory_for_show(recording.show_name) ensure_directory_exists(show_directory) recording_subdirectory = subdirectory_for_recording(recording, show_directory) recording_directory = "#{show_directory}/#{recording_subdirectory}" ensure_directory_exists(recording_directory) (recording_directory, recording) recording_directory end |
#delete_show(show_name) ⇒ Object
13 14 15 |
# File 'lib/simple_pvr/recording_manager.rb', line 13 def delete_show(show_name) FileUtils.rm_rf(directory_for_show(show_name)) end |
#delete_show_recording(show_name, recording_id) ⇒ Object
54 55 56 |
# File 'lib/simple_pvr/recording_manager.rb', line 54 def delete_show_recording(show_name, recording_id) FileUtils.rm_rf(@recordings_directory + '/' + show_name + '/' + recording_id) end |
#directory_for_show_and_recording(show_name, recording_id) ⇒ Object
71 72 73 |
# File 'lib/simple_pvr/recording_manager.rb', line 71 def directory_for_show_and_recording(show_name, recording_id) directory_for_show(show_name) + '/' + recording_id end |
#metadata_for(show_name, recording_id) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/simple_pvr/recording_manager.rb', line 24 def (show_name, recording_id) = directory_for_show_and_recording(show_name, recording_id) + '/metadata.yml' = File.exists?() ? YAML.load_file() : {} icon_file_name = directory_for_show_and_recording(show_name, recording_id) + '/icon' has_icon = File.exists?(icon_file_name) thumbnail_file_name = directory_for_show_and_recording(show_name, recording_id) + '/thumbnail.png' has_thumbnail = File.exists?(thumbnail_file_name) webm_file_name = directory_for_show_and_recording(show_name, recording_id) + '/stream.webm' has_webm = File.exists?(webm_file_name) RecordingMetadata.new( recording_id, has_icon, has_thumbnail, has_webm, show_name, [:channel], [:subtitle], [:description], [:categories] || [], [:directors] || [], [:presenters] || [], [:actors] || [], [:start_time], [:duration]) end |
#recordings_of(show_name) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/simple_pvr/recording_manager.rb', line 17 def recordings_of(show_name) recordings = Dir.new(directory_for_show(show_name)).entries - ['.', '..'] recordings.sort.map do |recording_id| (show_name, recording_id) end end |
#shows ⇒ Object
9 10 11 |
# File 'lib/simple_pvr/recording_manager.rb', line 9 def shows Dir.new(@recordings_directory).entries - ['.', '..'] end |