Class: Show

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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_formatsObject (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

#dateObject (readonly)

Returns the value of attribute date.



5
6
7
# File 'lib/deadlist/models/show.rb', line 5

def date
  @date
end

#durationObject (readonly)

Returns the value of attribute duration.



5
6
7
# File 'lib/deadlist/models/show.rb', line 5

def duration
  @duration
end

#locationObject (readonly)

Returns the value of attribute location.



5
6
7
# File 'lib/deadlist/models/show.rb', line 5

def location
  @location
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/deadlist/models/show.rb', line 5

def name
  @name
end

#tracksObject (readonly)

Returns the value of attribute tracks.



5
6
7
# File 'lib/deadlist/models/show.rb', line 5

def tracks
  @tracks
end

#transferred_byObject (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

#venueObject (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