tvgem 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/lib/tvgem.rb +105 -0
  2. metadata +46 -0
data/lib/tvgem.rb ADDED
@@ -0,0 +1,105 @@
1
+
2
+ require 'rubygems'
3
+ require 'hpricot'
4
+ require 'open-uri'
5
+ require 'zip'
6
+
7
+ class Tvgem
8
+ #!$apikey = B7FB16C98BC878DE
9
+
10
+ #puts("Please enter the Series name")
11
+ #series = gets()
12
+
13
+
14
+ class SeriesDesc
15
+ attr_accessor :seriesid, :seriesname, :overview, :banner, :firstaired
16
+ end
17
+
18
+
19
+
20
+ def Tvgem.getSeriesByName(seriesname)
21
+ @doc = Hpricot(open("http://thetvdb.com/api/GetSeries.php?seriesname=#{seriesname}"))
22
+ choices = []
23
+ (@doc/"data//series").each do |temp|
24
+ choice = SeriesDesc.new
25
+ choice.seriesid = (temp/"//seriesid").first.inner_html
26
+ choice.seriesname = (temp/"//seriesname").first.inner_html
27
+ if (!(temp/"//overview").first.blank? )
28
+ choice.overview = (temp/"//overview").first.inner_html end
29
+ if (!(temp/"//banner").first.blank? )
30
+ choice.banner = (temp/"//banner").first.inner_html end
31
+ choice.firstaired = (temp/"//firstaired").first.inner_html
32
+ choices << choice
33
+ end
34
+ if (choices.empty?)
35
+ puts "Its Empty"
36
+ else
37
+ return choices
38
+ end
39
+ end
40
+
41
+ def Tvgem.getdetail(detail)
42
+ item = (@doc/"data/series//#{detail}").first
43
+ return item
44
+ end
45
+
46
+ # def readzip(seriesid)
47
+ # zipfilename = open("http://thetvdb.com/api/B7FB16C98BC878DE/series/#{seriesid}/all/en.zip")
48
+ # Zip::File.open(zipfilename) do |zipfile|
49
+ # zipfile.each do |entry|
50
+ # puts "Reading #{entry.name}"
51
+ # case entry.name
52
+ # when "en.xml"
53
+ # puts "case en"
54
+ # @content = entry.get_input_stream.read
55
+ # when "banners.xml"
56
+ # puts "Case banner"
57
+ # @banners = entry.get_input_stream.read
58
+ # when "actors.xml"
59
+ # puts "case actors"
60
+ # @actors = Hpricot(entry.get_input_stream.read)
61
+ # puts "wjbdwlhg"
62
+ # end
63
+ # end
64
+ # end
65
+ # end
66
+
67
+ def Tvgem.elementtohash(xml,elementname)
68
+ doc = Hpricot(xml)
69
+ coll = []
70
+ (doc/"//#{elementname}").each do |child|
71
+ hash = Hash.new
72
+ (child/"/").each do |gchild|
73
+ unless (gchild.innerHTML).empty?
74
+ hash.store(gchild.name, gchild.innerHTML)
75
+ end
76
+ end
77
+ coll << hash
78
+ end
79
+ return coll
80
+ end
81
+
82
+ def Tvgem.getxml(seriesid,type)
83
+ xml = open("http://thetvdb.com/api/B7FB16C98BC878DE/series/#{seriesid}/all/#{type}.xml")
84
+ return xml
85
+ end
86
+
87
+ def Tvgem.xmlfromzip(seriesid,xmlname)
88
+ zipfilename = open("http://thetvdb.com/api/B7FB16C98BC878DE/series/85111/all/en.zip",&:read)
89
+ Zip::File.open(zipfilename) do |zipfile|
90
+ zipfile.each do |entry|
91
+ if entry.name == "#{xmlname}.xml"
92
+ @content = entry.get_input_stream.read
93
+ end
94
+ end
95
+ end
96
+ return @content
97
+ end
98
+
99
+
100
+
101
+
102
+
103
+
104
+
105
+ end
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tvgem
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Sean Crummy
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-04-01 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: A simple gem
15
+ email: sean.crummy@student.ncirl.ie
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/tvgem.rb
21
+ homepage: http://rubygems.org/gems/tvgem
22
+ licenses:
23
+ - MIT
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ none: false
36
+ requirements:
37
+ - - ! '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ requirements: []
41
+ rubyforge_project:
42
+ rubygems_version: 1.8.28
43
+ signing_key:
44
+ specification_version: 3
45
+ summary: Utilise the tvdb API- School project!
46
+ test_files: []