Class: MyLocalPutio::SubtitlesManager
- Inherits:
-
Object
- Object
- MyLocalPutio::SubtitlesManager
- Defined in:
- lib/my-local-putio/subtitles_manager.rb
Instance Attribute Summary collapse
-
#cli ⇒ Object
readonly
Returns the value of attribute cli.
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
-
#downloader ⇒ Object
readonly
Returns the value of attribute downloader.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
- #fetch(file, path) ⇒ Object
-
#initialize(configuration) ⇒ SubtitlesManager
constructor
A new instance of SubtitlesManager.
Constructor Details
#initialize(configuration) ⇒ SubtitlesManager
Returns a new instance of SubtitlesManager.
5 6 7 8 9 10 |
# File 'lib/my-local-putio/subtitles_manager.rb', line 5 def initialize(configuration) @configuration = configuration @logger = configuration.logger @cli = PutioCli.new(@configuration) @downloader = Downloader.new(@configuration) end |
Instance Attribute Details
#cli ⇒ Object (readonly)
Returns the value of attribute cli.
3 4 5 |
# File 'lib/my-local-putio/subtitles_manager.rb', line 3 def cli @cli end |
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
3 4 5 |
# File 'lib/my-local-putio/subtitles_manager.rb', line 3 def configuration @configuration end |
#downloader ⇒ Object (readonly)
Returns the value of attribute downloader.
3 4 5 |
# File 'lib/my-local-putio/subtitles_manager.rb', line 3 def downloader @downloader end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
3 4 5 |
# File 'lib/my-local-putio/subtitles_manager.rb', line 3 def logger @logger end |
Instance Method Details
#fetch(file, path) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/my-local-putio/subtitles_manager.rb', line 12 def fetch(file, path) return unless configuration.with_subtitles return unless file_is_video?(file) local_subtitle_path = File.join(path, filename(file)) logger.log "Trying to fetch the preferred subtitle for: #{file.name}" subtitles = cli.get_subtitles(file.id)["subtitles"] if subtitles.empty? logger.log ":( Could not find any preferred subtitle for: #{file.name}" return end process_subtitle(subtitles, local_subtitle_path) end |