Class: Show
- Inherits:
-
Object
- Object
- Show
- Defined in:
- lib/deadlist/models/show.rb
Overview
Object to handle Show data and the array of Track objects to be used in downloading.
Constant Summary collapse
- AUDIO_FORMATS =
%w[mp3 flac ogg m4a].freeze
Instance Attribute Summary collapse
-
#available_formats ⇒ Object
readonly
Returns the value of attribute available_formats.
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#tracks ⇒ Object
readonly
Returns the value of attribute tracks.
-
#transferred_by ⇒ Object
readonly
Returns the value of attribute transferred_by.
-
#venue ⇒ Object
readonly
Returns the value of attribute venue.
Instance Method Summary collapse
-
#download_tracks(path) ⇒ Object
Initializes a Downloader and passes track details.
-
#initialize(show_id, format, logger: Logger.new($stdout)) ⇒ Show
constructor
A new instance of Show.
Constructor Details
#initialize(show_id, format, logger: Logger.new($stdout)) ⇒ Show
Returns a new instance of Show.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/deadlist/models/show.rb', line 7 def initialize(show_id, format, logger: Logger.new($stdout)) @logger = logger @show_id = show_id @format = format @name = nil @date = nil @location = nil @venue = nil @duration = nil @transferred_by = nil @url = nil @tracks = nil set_show_info end |
Instance Attribute Details
#available_formats ⇒ Object (readonly)
Returns the value of attribute available_formats.
5 6 7 |
# File 'lib/deadlist/models/show.rb', line 5 def available_formats @available_formats end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
5 6 7 |
# File 'lib/deadlist/models/show.rb', line 5 def date @date end |
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
5 6 7 |
# File 'lib/deadlist/models/show.rb', line 5 def duration @duration end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
5 6 7 |
# File 'lib/deadlist/models/show.rb', line 5 def location @location end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/deadlist/models/show.rb', line 5 def name @name end |
#tracks ⇒ Object (readonly)
Returns the value of attribute tracks.
5 6 7 |
# File 'lib/deadlist/models/show.rb', line 5 def tracks @tracks end |
#transferred_by ⇒ Object (readonly)
Returns the value of attribute transferred_by.
5 6 7 |
# File 'lib/deadlist/models/show.rb', line 5 def transferred_by @transferred_by end |
#venue ⇒ Object (readonly)
Returns the value of attribute venue.
5 6 7 |
# File 'lib/deadlist/models/show.rb', line 5 def venue @venue end |
Instance Method Details
#download_tracks(path) ⇒ Object
Initializes a Downloader and passes track details
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/deadlist/models/show.rb', line 24 def download_tracks(path) dl = Downloader.new(path, @format, logger: @logger) download_url = dl.download_url_for_show(@show_id) succesful_downloads = 0 @tracks.each do |track| @logger.info "⬇️ Downloading #{track.pos} - #{track.title}..." if dl.get(download_url, track) succesful_downloads += 1 end @logger.info "⚡️ #{track.pos} - #{track.title} downloaded successfully" end @logger.info "✅ Downloaded #{succesful_downloads}/#{@tracks.length} tracks successfully!" end |