Last active
September 22, 2015 22:04
-
-
Save theareba/6814b48e47f2b60734c8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Thetvdb | |
class Client | |
attr_reader :token, :seriesName | |
def initialize(seriesName) | |
@token = API_KEY | |
@seriesName = seriesName | |
if @seriesName.empty? || @token.empty? | |
raise ArgumentError, 'Series Name and token are required' | |
end | |
end | |
def get_show | |
result = RestClient.get 'http://thetvdb.com/api/GetSeries.php?seriesname=' + @seriesName | |
doc = Nokogiri::XML(result) | |
seriesId = doc.at('seriesid').text | |
series_data = RestClient.get 'http://thetvdb.com/api/' + @token + '/series/' + seriesId + '/all/en.xml' | |
return series_data | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://rubygems.org' | |
# Specify your gem's dependencies in thetvdb.gemspec | |
gemspec | |
gem 'nokogiri' | |
gem 'rest-client' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem 'thetvdb-ruby', '~> 0.1.0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.. | |
def index | |
show = Thetvdb::Client.new("Amazing race").get_show | |
render json: Hash.from_xml(show) | |
end | |
.. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'thetvdb' | |
API_KEY = "9EF1D1E7D28FDA0B" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
lib = File.expand_path('../lib', __FILE__) | |
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) | |
require 'thetvdb/version' | |
Gem::Specification.new do |spec| | |
spec.name = "thetvdb-ruby" | |
spec.version = Thetvdb::VERSION | |
spec.authors = ["Victor Areba"] | |
spec.email = ["vicgoburg@gmail.com"] | |
spec.summary = %q{Ruby wrapper for TVDB API} | |
spec.description = %q{Get access to your favorite tv shows and it's episodes details} | |
spec.homepage = "https://github.com/theareba/thetvdb-ruby" | |
spec.license = "MIT" | |
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } | |
spec.bindir = "exe" | |
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } | |
spec.require_paths = ["lib"] | |
spec.add_development_dependency "bundler", "~> 1.9" | |
spec.add_development_dependency "rake", "~> 10.0" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "thetvdb/version" | |
require 'rest-client' | |
require 'nokogiri' | |
require 'thetvdb/client' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "thetvdb/version" | |
require 'rest-client' | |
require 'nokogiri' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ThetvdbGenerator < Rails::Generators::Base | |
source_root File.expand_path("../templates", __FILE__) | |
def create_initializer_file | |
#create_file "config/initializers/thetvdb.rb" | |
copy_file "thetvdb.rb", "config/initializers/thetvdb.rb" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'thetvdb' | |
API_KEY = "Your API Key" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Thetvdb | |
VERSION = "0.1.0" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment