tvdb_ruby 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/tvdb_ruby.rb +59 -0
- metadata +45 -0
data/lib/tvdb_ruby.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
|
3
|
+
API_KEY = 'BA027FC13CC4F4A9'
|
4
|
+
BASE_URL = 'http://www.thetvdb.com/api/'
|
5
|
+
|
6
|
+
class TVDB_Ruby
|
7
|
+
|
8
|
+
### Beginning of generic methods ###
|
9
|
+
|
10
|
+
# Search series in the database
|
11
|
+
def self.search_series(search)
|
12
|
+
terms = search.split(' ').join("%20")
|
13
|
+
xml = HTTParty.get("http://www.thetvdb.com/api/GetSeries.php?seriesname=" + terms)
|
14
|
+
|
15
|
+
if xml["Data"].nil?
|
16
|
+
puts "no show found"
|
17
|
+
else
|
18
|
+
result = xml["Data"]["Series"]
|
19
|
+
end
|
20
|
+
|
21
|
+
if result.class == Hash
|
22
|
+
@shows = []
|
23
|
+
@shows << result
|
24
|
+
else
|
25
|
+
@shows = result
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# Get series from IMDB ID
|
30
|
+
def self.search_imdb(imdb_id)
|
31
|
+
xml = HTTParty.get("http://www.thetvdb.com/api/GetSeriesByRemoteID.php?imdbid=" + imdb_id.to_s)
|
32
|
+
|
33
|
+
if xml["Data"].nil?
|
34
|
+
puts "no show found"
|
35
|
+
else
|
36
|
+
result = xml["Data"]["Series"]
|
37
|
+
end
|
38
|
+
|
39
|
+
if result.class == Hash
|
40
|
+
@shows = []
|
41
|
+
@shows << result
|
42
|
+
else
|
43
|
+
@shows = result
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# Get episode by air date
|
48
|
+
def self.search_by_airdate(series_id, date)
|
49
|
+
xml = HTTParty.get("http://www.thetvdb.com/api/GetEpisodeByAirDate.php?apikey=BA027FC13CC4F4A9&seriesid=#{series_id.to_s}&airdate=#{date.to_s}")
|
50
|
+
|
51
|
+
xml["Data"]
|
52
|
+
end
|
53
|
+
|
54
|
+
# Get serie by serie id
|
55
|
+
def self.search_by_id(series_id)
|
56
|
+
xml = HTTParty.get("http://www.thetvdb.com/api/BA027FC13CC4F4A9/series/" + series_id.to_s + "/all/en.xml")
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tvdb_ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jonathan Pepin
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-12-02 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Gem to easily use theTVDB.com open source database in Ruby
|
15
|
+
email: jypepin@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/tvdb_ruby.rb
|
21
|
+
homepage: http://rubygems.org/gems/tvdb_ruby
|
22
|
+
licenses: []
|
23
|
+
post_install_message:
|
24
|
+
rdoc_options: []
|
25
|
+
require_paths:
|
26
|
+
- lib
|
27
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
requirements: []
|
40
|
+
rubyforge_project:
|
41
|
+
rubygems_version: 1.8.24
|
42
|
+
signing_key:
|
43
|
+
specification_version: 3
|
44
|
+
summary: The TVDB Ruby Gem
|
45
|
+
test_files: []
|