Class: Shin::Play::Cmore
- Inherits:
-
Object
- Object
- Shin::Play::Cmore
- Defined in:
- lib/shin/play/cmore.rb
Defined Under Namespace
Classes: HTTPError, MissingArgument, NotValid
Instance Method Summary collapse
-
#before(params = {}) ⇒ Object
Fix these before running.
-
#find(params = {}) ⇒ Object
Find.
-
#list(list_id) ⇒ Object
Get a list.
-
#movie(params = {}) ⇒ Object
Movie.
- #new ⇒ Object
-
#show(params = {}) ⇒ Object
Show.
Instance Method Details
#before(params = {}) ⇒ Object
Fix these before running
12 13 14 15 16 |
# File 'lib/shin/play/cmore.rb', line 12 def before(params={}) raise MissingArgument, "You are missing the argument 'cmore_code' which is required to use this source." unless Shin.get[:cmore_code] != nil return "http://www.cmore." + Shin.get[:cmore_code] + "/", CMORE_API_URL + "capiche.cmore." + Shin.get[:cmore_code] + "/" end |
#find(params = {}) ⇒ Object
Find
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/shin/play/cmore.rb', line 81 def find(params={}) domain, api_domain = before() country = Shin.get[:cmore_code] # Response response = Base.get(api_domain + 'films/find.json?page_count=50&' + URI.encode_www_form(params)) raise HTTPError, "The response didn't have a 200 HTTP Code. It had #{response.code}." unless response.code == 200 # Data data = Oj.load(response.body) rescue nil # Can't be nil if data != nil data.to_hashugar else raise NotValid, "Couldn't parse the JSON" end end |
#list(list_id) ⇒ Object
Get a list
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/shin/play/cmore.rb', line 19 def list(list_id) domain, api_domain = before() country = Shin.get[:cmore_code] # Get list response = Base.get(api_domain + 'api/CMA/content/panel/' + list_id + '.json') raise HTTPError, "The response didn't have a 200 HTTP Code. It had #{response.code}." unless response.code == 200 # Data data = Oj.load(response.body) rescue nil # Can't be nil if data != nil data['results'].to_hashugar else raise NotValid, "Couldn't parse the JSON" end end |
#movie(params = {}) ⇒ Object
Movie
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/shin/play/cmore.rb', line 60 def movie(params={}) domain, api_domain = before() country = Shin.get[:cmore_code] # Response response = Base.get(api_domain + 'film/' + params[:id] + '.json') raise HTTPError, "The response didn't have a 200 HTTP Code. It had #{response.code}." unless response.code == 200 # Data data = Oj.load(response.body) rescue nil # Can't be nil if data != nil data.to_hashugar else raise NotValid, "Couldn't parse the JSON" end end |
#new ⇒ Object
7 8 9 |
# File 'lib/shin/play/cmore.rb', line 7 def new self end |
#show(params = {}) ⇒ Object
Show
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/shin/play/cmore.rb', line 39 def show(params={}) domain, api_domain = before() country = Shin.get[:cmore_code] # Response response = Base.get(api_domain + 'serie/' + params[:id] + '.json') raise HTTPError, "The response didn't have a 200 HTTP Code. It had #{response.code}." unless response.code == 200 # Data data = Oj.load(response.body) rescue nil # Can't be nil if data != nil data.to_hashugar else raise NotValid, "Couldn't parse the JSON" end end |