Class: TheTvDb::Api::Show
Instance Attribute Summary
#xml_doc
Class Method Summary
collapse
Instance Method Summary
collapse
#==, #aliases, #attributes, #classification, #country, find, #initialize, #name, search_xml_document, search_xml_string, #to_s, xml_document, xml_string
Methods included from Helpers
#get_remote_file_as_string, #parsable_date?, #safely_parse_date
Class Method Details
.banner_list_url_for(series_id) ⇒ Object
104
105
106
|
# File 'lib/the_tv_db/api/show.rb', line 104
def banner_list_url_for(series_id)
"#{Mirrors.all.first}/api/#{TheTvDb.configuration.api_key}/series/#{series_id}/banners.xml"
end
|
.banner_list_xml_string(series_id) ⇒ Object
111
112
113
|
# File 'lib/the_tv_db/api/show.rb', line 111
def banner_list_xml_string(series_id)
get_remote_file_as_string(banner_list_url_for(series_id))
end
|
.find_by_id(series_id) ⇒ Object
88
89
90
91
92
|
# File 'lib/the_tv_db/api/show.rb', line 88
def find_by_id(series_id)
if doc = xml_document(series_id)
return Show.new(doc)
end
end
|
.find_by_name(series_name) ⇒ Object
79
80
81
82
83
84
85
86
|
# File 'lib/the_tv_db/api/show.rb', line 79
def find_by_name(series_name)
if doc = search_xml_document(series_name)
if doc.xpath('//SeriesName').try(:first).try(:content).try(:downcase) == series_name.downcase
show = find_by_id(doc.xpath('//seriesid').first.content.to_i)
return show
end
end
end
|
.search_url_for(series_name) ⇒ Object
Escapes the series name, and does the lookup
97
98
99
|
# File 'lib/the_tv_db/api/show.rb', line 97
def search_url_for(series_name)
"#{Mirrors.all.first}/api/GetSeries.php?seriesname=#{CGI.escape(series_name)}"
end
|
.url_for(series_id) ⇒ Object
118
119
120
|
# File 'lib/the_tv_db/api/show.rb', line 118
def url_for(series_id)
"#{Mirrors.all.first}/api/#{TheTvDb.configuration.api_key}/series/#{series_id}/en.xml"
end
|
Instance Method Details
35
36
37
|
# File 'lib/the_tv_db/api/show.rb', line 35
def actors
(xpath('/Data/Series/Actors').try(:split, '|') || []).reject { |a| a.blank? }
end
|
#air_dates ⇒ Object
19
20
21
22
23
24
25
|
# File 'lib/the_tv_db/api/show.rb', line 19
def air_dates
if air_date = xpath('/Data/Series/FirstAired')
[safely_parse_date(air_date)]
else
[]
end
end
|
31
32
33
|
# File 'lib/the_tv_db/api/show.rb', line 31
def genres
(xpath('/Data/Series/Genre').try(:split, '|') || []).reject { |g| g.blank? }
end
|
15
16
17
|
# File 'lib/the_tv_db/api/show.rb', line 15
def language
xpath('/Data/Series/Language').try(:downcase)
end
|
51
52
53
|
# File 'lib/the_tv_db/api/show.rb', line 51
def network
xpath('/Data/Series/Network')
end
|
#network_id ⇒ Object
7
8
9
|
# File 'lib/the_tv_db/api/show.rb', line 7
def network_id
xpath('/Data/Series/id').to_i
end
|
#number_of_ratings ⇒ Object
73
74
75
|
# File 'lib/the_tv_db/api/show.rb', line 73
def number_of_ratings
xpath('/Data/Series/RatingCount').try(:to_i)
end
|
#original_name ⇒ Object
11
12
13
|
# File 'lib/the_tv_db/api/show.rb', line 11
def original_name
xpath('/Data/Series/SeriesName')
end
|
47
48
49
|
# File 'lib/the_tv_db/api/show.rb', line 47
def overview
xpath('/Data/Series/Overview')
end
|
66
67
68
69
70
71
|
# File 'lib/the_tv_db/api/show.rb', line 66
def rating
r = xpath('/Data/Series/Rating')
if r.to_f > 0
return (r.to_f * 10).to_i
end
end
|
#remote_ids ⇒ Object
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/the_tv_db/api/show.rb', line 55
def remote_ids
remote_ids = []
if imdb_id = xpath('/Data/Series/IMDB_ID')
remote_ids.push [:imdb, imdb_id]
end
if zap2it_id = xpath('/Data/Series/zap2it_id')
remote_ids.push [:zap2it, zap2it_id]
end
remote_ids
end
|
43
44
45
|
# File 'lib/the_tv_db/api/show.rb', line 43
def runtime
xpath('/Data/Series/Runtime').try(:downcase).try(:to_i).try(:*, 60)
end
|
27
28
29
|
# File 'lib/the_tv_db/api/show.rb', line 27
def started
air_dates.try(:first).try(:year)
end
|
39
40
41
|
# File 'lib/the_tv_db/api/show.rb', line 39
def status
xpath('/Data/Series/Status').try(:downcase).try(:to_sym)
end
|