17
18
19
20
21
22
23
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
|
# File 'lib/tvdb/ruby.rb', line 17
def harvest(apiKey, seriesId)
url = "http://thetvdb.com/api/#{apiKey}/series/#{seriesId}/all/en.xml"
doc = Nokogiri::HTML(open(url))
show = Show.new(
id: doc.css("id").text,
name: doc.css("seriesname").text,
airsDayOfWeek: doc.css("airs_dayofweek").text,
airsTime: doc.css("airs_time").text,
firstAired: doc.css("firstaired").text,
genre: doc.css("genre").text,
network: doc.css("network").text,
overview: doc.css("overview").text,
rating: doc.css("rating").text,
ratingCount: doc.css("ratingcount").text,
runtime: doc.css("runtime").text,
status: doc.css("status").text,
poster: doc.css("poster").text
)
doc.css("episode").each do |episode|
show.epidosodes.new(
seasonNumber: episode.css("seasonnumber").text,
id: episode.css("episodenumber").text,
name: episode.css("episodename").text,
firstAired: episode.css("firstaired").text,
overview: episode.css("overview").text
)
end
end
|