strepi 0.0.2

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 10dd8046f7e894886515294f5820060ed23c3113
4
+ data.tar.gz: 92637f9e8ad4c8c2ad6a49d0a74fd44aecdc2601
5
+ SHA512:
6
+ metadata.gz: fbfe876b61a89c2b2726208aa3a538088c0fd53d88e8e556bee0d9960ffc051ead18749c9008d50ad9001544765a7cf66a5d8639890bf5460fbf77c1af0bb80f
7
+ data.tar.gz: 0fe425aec52a90c2a0e67087add528d238ce72f6b5890c4edbc988beb5b17a9865fae51a51ed88388cfd970bc13b909e3e12acc6ec34108fee687d2b8f4a4656
@@ -0,0 +1,20 @@
1
+ Copyright 2015 Bryan Gross
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,59 @@
1
+ = Strepi
2
+
3
+ An updated gem based on Mwhich
4
+
5
+ == INSTALLING STREPI
6
+
7
+ Strepi can be downloaded with
8
+
9
+ gem install 'strepi'
10
+
11
+ == DESCRIPTION
12
+
13
+ Strepi was made as an update to the now defunct MWhich[https://github.com/dacort/mwhich], which was no longer maintained because of the lack of a Netflix API. I was able to restore Netflix functionality to Strepi and add Crunchyroll[crunchyroll.com](Anime streaming website) service. Strepi checks to see if a movie/TV show is available on ITunes, Amazon, Crunchyroll, Netflix, or Amazon.
14
+
15
+ == HOW IT WAS DONE
16
+
17
+ This is how the data for each service was acessed
18
+
19
+ * Netflix: The Netflix Roulette gem and api. (http://netflixroulette.net/api/)
20
+ * Amazon: Official Amazon ECS (Required credentials)
21
+ * Hulu: Hacks publisher tool endpoint
22
+ * iTunes: Their Store Web Service Search API via AffiliatesSearch2.1.pdf[http://www.apple.com/itunesaffiliates/API/AffiliatesSearch2.1.pdf]
23
+ * Crunchyroll: Scrapes Crunchyroll pages
24
+
25
+ == REQUIREMENTS
26
+
27
+ Similar to MWhich, these gems are needed:
28
+
29
+ * yajl-ruby
30
+ * nokogiri
31
+ * ruby-hmac
32
+
33
+ == USING STREPI
34
+
35
+ While
36
+
37
+ To create a basic MWhich instance:
38
+
39
+ m = Strepi::Client.new
40
+
41
+ You can search for a movie like this:
42
+
43
+ w.search("The Prestige")
44
+ # => {:amazon=>[], :hulu=>[], :itunes=>["feature-movie: The Prestige ($9.99)"], :netflix=>[The Prestige is available!, :crunchyroll=>[]}
45
+
46
+ At this time, this merely returns a hash of key/value pairs indicating which
47
+ services the movie or TV show was found on. The value is a simple string with
48
+ the type of media found and the title. Comments specific to each service
49
+ may also appear. For example:
50
+
51
+ * Hulu sometimes links to external content, "Not on hulu!" will identify this.
52
+ * iTunes will display prices of product
53
+
54
+ Limit your searches by service
55
+
56
+ w = Strepi::Client.new(:services => [:netflix, :hulu])
57
+ m.search("Knight Rider")
58
+ # => {:hulu=>["episode: I Love the Knight Life", "episode: Knight and the City", "episode: Fly By Knight", "episode: Fight Knight", "episode: Exit Light, Enter Knight", "episode: Knight to King's Pawn", "episode: Day Turns Into Knight", "episode: Don't Stop the Knight", "episode: Knight Fever", "episode: Knight of the Zodiac"], :netflix=>["Series: Knight Rider", "Series: Knight Rider"]}
59
+
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'Strepi'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+
24
+
25
+
26
+ Bundler::GemHelper.install_tasks
27
+
28
+ require 'rake/testtask'
29
+
30
+ Rake::TestTask.new(:test) do |t|
31
+ t.libs << 'lib'
32
+ t.libs << 'test'
33
+ t.pattern = 'test/**/*_test.rb'
34
+ t.verbose = false
35
+ end
36
+
37
+
38
+ task :default => :test
@@ -0,0 +1,19 @@
1
+ require 'rubygems'
2
+
3
+ require 'net/http'
4
+ require 'uri'
5
+ require 'cgi'
6
+ require 'yajl'
7
+ require 'nokogiri'
8
+ require 'time'
9
+ require 'hmac-sha2'
10
+ require 'base64'
11
+ require 'amazon/ecs'
12
+ require 'netflix_roulette'
13
+
14
+ require 'strepi/amazon_ecs'
15
+ require 'strepi/hulu'
16
+ require 'strepi/itunes'
17
+ require 'strepi/netflix'
18
+ require 'strepi/crunchyroll'
19
+ require 'strepi/client'
@@ -0,0 +1,41 @@
1
+ module Strepi
2
+ module Services
3
+ class AmazonEcs
4
+ def initialize(options={})
5
+ Amazon::Ecs.options = {
6
+ :associate_tag => options[:ecs_credentials][:associate_tag],
7
+ :AWS_access_key_id => options[:ecs_credentials][:AWS_access_key_id],
8
+ :AWS_secret_key => options[:ecs_credentials][:AWS_secret_key]
9
+ }
10
+ end
11
+
12
+ def search(title, media="DVD")
13
+ result = {}
14
+ data = request(title, media)
15
+
16
+ result['count'] = data.items.size
17
+ result['results'] = []
18
+
19
+ data.items.each do |item|
20
+ result['results'] << {
21
+ 'name' => item.get('ItemAttributes/Title'),
22
+ 'media_type' => item.get('ItemAttributes/Binding'),
23
+ 'purchase_option' => 'buy', # change this
24
+ 'price' => item.get('ItemAttributes/ListPrice/FormattedPrice'),
25
+ 'artwork_url' => item.get('MediumImage/URL'),
26
+ 'release_date' => item.get('ItemAttributes/ReleaseDate'),
27
+ 'url' => item.get('DetailPageURL')
28
+ }
29
+ end
30
+
31
+ result
32
+ end
33
+
34
+ protected
35
+
36
+ def request(title, media="DVD")
37
+ return Amazon::Ecs.item_search(title, { :response_group => 'Medium', :sort => 'relevancerank', :search_index => media })
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,36 @@
1
+ module Strepi
2
+ class Client
3
+
4
+ VALID_SERVICES = [:amazon,:hulu,:itunes,:netflix]
5
+ SERVICE_MAP = {
6
+ :amazon => Strepi::Services::AmazonEcs,
7
+ :hulu => Strepi::Services::Hulu,
8
+ :itunes => Strepi::Services::ITunes,
9
+ :netflix => Strepi::Services::Netflix,
10
+ :crunchyroll => Strepi::Services::Crunchyroll
11
+
12
+ }
13
+ IGNORE_MEDIA = [:clips, :trailers]
14
+
15
+ attr_accessor :services, :ignore, :ecs_credentials
16
+
17
+ # Arguments (all are optional):
18
+ # - :services - One or more of :amazon, :netflix, :hulu, or :itunes. Default is :all
19
+ def initialize(options={})
20
+ self.services = options[:services] || VALID_SERVICES
21
+ self.ignore = options[:ignore] ? IGNORE_MEDIA & options[:ignore] : IGNORE_MEDIA
22
+ self.ecs_credentials = options[:ecs_credentials]
23
+ end
24
+
25
+ # Search for a movie/tv show by title
26
+ def search(title)
27
+ results = {}
28
+ self.services.each do |service|
29
+ s = SERVICE_MAP[service].new(:ignore => ignore, :ecs_credentials => ecs_credentials)
30
+ results[service] = s.search(title) #each search goes into results hash!!!
31
+ end
32
+
33
+ results
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,32 @@
1
+ module Strepi
2
+ module Services
3
+ class Crunchyroll #very similar to hulu probably, should finish this
4
+ def initialize(options={})
5
+ @endpoint_url = "http://crunchyroll.com"
6
+ @ignore_media = []
7
+
8
+ end
9
+
10
+ def search(title)
11
+
12
+ new_title = title.gsub(/[^a-z0-9\s]/i, '').gsub(' ', '-') #new title foormat to be inserted into URL for crunchyroll, takes away all non-alphanumeric character and then replaces spaces with dashes
13
+
14
+ titles = []
15
+ page_request = Net::HTTP.get_response(URI.parse("#{@endpoint_url}/#{new_title}"))
16
+ if page_request.code != "200"
17
+ nil
18
+ else
19
+
20
+ titles << "#{title} is on Crunchyroll!"
21
+ end
22
+
23
+
24
+ titles
25
+ end
26
+
27
+
28
+
29
+
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,39 @@
1
+ module Strepi
2
+ module Services
3
+ class Hulu
4
+ def initialize(options={})
5
+ @endpoint_url = "http://m.hulu.com"
6
+ @ignore_media = []
7
+ if options[:ignore]
8
+ @ignore_media << 'film_trailer' if options[:ignore].include?:trailers
9
+ @ignore_media << 'clip' if options[:ignore].include?:clips
10
+ end
11
+ end
12
+
13
+ def search(title)
14
+ results = request(title)
15
+
16
+ titles = []
17
+ results.xpath("//video").each do |result|
18
+ next if @ignore_media.include?result.css('video-type').inner_html
19
+ append = ""
20
+ if (ishulu = result.css('is-hulu'))
21
+ append = " - Not on hulu!" if ishulu.inner_html == "0"
22
+ end
23
+ titles << "#{result.css('video-type').inner_html}: #{result.css('title').inner_html}#{append}"
24
+ end
25
+
26
+ titles
27
+ end
28
+
29
+ protected
30
+
31
+ def request(title)
32
+ url = "#{@endpoint_url}/search?dp_identifier=hulu&query=#{URI::escape(title)}&items_per_page=10&page=1"
33
+
34
+ response = Net::HTTP.get_response(URI.parse(url))
35
+ Nokogiri::XML(response.body)
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,45 @@
1
+ module Strepi
2
+ module Services
3
+ class ITunes
4
+ def initialize(options={})
5
+ @endpoint = "http://ax.phobos.apple.com.edgesuite.net/WebObjects/MZStoreServices.woa/wa/wsSearch"
6
+ end
7
+
8
+ def search(title, media="movie")
9
+ result = {}
10
+ data = request(title, media)
11
+
12
+ result['count'] = data['results'].length
13
+ result['results'] = []
14
+
15
+ data['results'].each_with_index do |r, index|
16
+ result['results'] << {
17
+ 'name' => r['trackName'],
18
+ 'media_type' => media,
19
+ 'purchase_option' => 'rent', # change this
20
+ 'price' => r['trackPrice'],
21
+ 'artwork_url' => r['artworkUrl100'],
22
+ 'release_date' => r['releaseDate']
23
+ }
24
+ end
25
+
26
+ result
27
+
28
+ end
29
+
30
+ protected
31
+
32
+ def request(title, media="movie")
33
+ # We'll do searches across both TV and movies and merge the results
34
+ results = []
35
+
36
+ url = "#{@endpoint}?term=#{URI::escape(title)}&media=#{media}"
37
+ response = Net::HTTP.get_response(URI.parse(url))
38
+ data = Yajl::Parser.parse(response.body)
39
+
40
+ data
41
+ end
42
+
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,32 @@
1
+ module Strepi
2
+ module Services
3
+ class Netflix
4
+
5
+ def initialize(options={})
6
+
7
+
8
+ end
9
+
10
+ def search(title)
11
+ #BRYAN FIND OUT HOW TO SEARCH FOR MOVIES USING NETFLIX ROULETTE!!!!
12
+
13
+ titles = []
14
+
15
+
16
+ if NetflixRoulette.get_media_poster(title) == "Unable to locate data"
17
+ nil
18
+ else
19
+ titles << "#{title} is Available!"
20
+ end
21
+
22
+
23
+
24
+
25
+
26
+ titles
27
+ end
28
+
29
+
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,3 @@
1
+ module Strepi
2
+ VERSION = "0.0.2"
3
+ end
metadata ADDED
@@ -0,0 +1,172 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: strepi
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - bryangross
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-05-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: nokogiri
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: yajl-ruby
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: ruby-hmac
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: amazon-ecs
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: netflix_roulette
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: test-unit
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: sqlite3
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: Strepi was made as an update to the now defunct MWhich[https://github.com/dacort/mwhich]
126
+ created by dacort[https://github.com/dacort], which was no longer maintained because
127
+ of the lack of a Netflix API. I was able to restore Netflix functionality to Strepi
128
+ and add Crunchyroll[crunchyroll.com](Anime streaming website) service. Strepi checks
129
+ to see if a movie/TV show is available on ITunes, Amazon, Crunchyroll, Netflix,
130
+ or Amazon.
131
+ email:
132
+ executables: []
133
+ extensions: []
134
+ extra_rdoc_files: []
135
+ files:
136
+ - MIT-LICENSE
137
+ - README.md
138
+ - Rakefile
139
+ - lib/strepi.rb
140
+ - lib/strepi/amazon_ecs.rb
141
+ - lib/strepi/client.rb
142
+ - lib/strepi/crunchyroll.rb
143
+ - lib/strepi/hulu.rb
144
+ - lib/strepi/itunes.rb
145
+ - lib/strepi/netflix.rb
146
+ - lib/strepi/version.rb
147
+ homepage: http://github.com/bryangross/strepi
148
+ licenses:
149
+ - MIT-LICENSE
150
+ metadata: {}
151
+ post_install_message:
152
+ rdoc_options: []
153
+ require_paths:
154
+ - lib
155
+ required_ruby_version: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ required_rubygems_version: !ruby/object:Gem::Requirement
161
+ requirements:
162
+ - - ">="
163
+ - !ruby/object:Gem::Version
164
+ version: '0'
165
+ requirements: []
166
+ rubyforge_project:
167
+ rubygems_version: 2.4.6
168
+ signing_key:
169
+ specification_version: 4
170
+ summary: Allows you to search through Amazon, Netflix, Hulu, ITunes, and Crunchyroll
171
+ to see if a movie/TV show is available.
172
+ test_files: []