Class: Client

Inherits:
Object
  • Object
show all
Defined in:
lib/deadlist/cli/client.rb

Overview

The Client class manages HTML scraping and parsing for the CLI and other classes above it. Any HTML work should be handled here.

Instance Method Summary collapse

Instance Method Details

#scrape_show_info(show_link) ⇒ Object

Returns a show_data object for helping in the creation of a new Show



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/deadlist/cli/client.rb', line 4

def scrape_show_info(show_link)
    doc = get_page_source(show_link)
    track_divs = doc.css('div[itemprop="track"]')

    show_data = {
        date: (doc, itemprop: 'datePublished'),
        location: (doc, label: 'Location'),
        venue: (doc, label: 'Venue'),
        transferred_by: (doc, label: 'Transferred by'),
        duration: (doc, label: 'Run time'),
        tracks: extract_track_data(track_divs)
    }

    return show_data
rescue => e
    puts "\n❌ Data extraction failed: #{e.message}"
end