Class: ShowRobot::TVRage

Inherits:
Datasource show all
Defined in:
lib/showrobot/db/tvrage.rb

Constant Summary collapse

DB_NAME =
'TVRage'

Instance Attribute Summary

Attributes inherited from Datasource

#mediaFile, #series

Instance Method Summary collapse

Methods inherited from Datasource

#episode_list, #initialize, #series_list

Constructor Details

This class inherits a constructor from ShowRobot::Datasource

Instance Method Details

#episodeObject



27
28
29
30
31
# File 'lib/showrobot/db/tvrage.rb', line 27

def episode
	puts "  Fetching episode list for #{show_name}@#{show_id} (#{episode_query})" if ShowRobot::VERBOSE

	puts fetch(:xml, episode_query).find("//episode[seasonnum/.=#{@mediaFile.season} and epnum/.=#{@mediaFile.episode}]")
end

#episode_queryObject



10
11
12
# File 'lib/showrobot/db/tvrage.rb', line 10

def episode_query
	"http://services.tvrage.com/feeds/full_show_info.php?sid=#{show_id}"
end

#fetchObject



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/showrobot/db/tvrage.rb', line 14

def fetch
	puts "  Fetching #{@mediaFile.name_guess} from #{DB_NAME} (#{match_query})" if ShowRobot::VERBOSE

	doc = XML::Parser.string(open(match_query).read).parse

	# TODO - make sure this matches
	bestMatch = doc.find('//show').first
	@showName = bestMatch.find('name').first.content
	@showId = bestMatch.find('showid').first.content

	puts "    --> Query: [ #{@mediaFile.name_guess} ] Match: [ #{@showName} ]@#{@showId}" if ShowRobot::VERBOSE
end

#match_queryObject



6
7
8
# File 'lib/showrobot/db/tvrage.rb', line 6

def match_query
	"http://services.tvrage.com/feeds/full_search.php?show=#{ShowRobot.url_encode @mediaFile.name_guess}"
end

#show_idObject



40
41
42
43
44
45
# File 'lib/showrobot/db/tvrage.rb', line 40

def show_id
	if @showId.nil?
		fetch
	end
	@showId
end

#show_nameObject



33
34
35
36
37
38
# File 'lib/showrobot/db/tvrage.rb', line 33

def show_name
	if @showName.nil?
		fetch
	end
	@showName
end