Class: Shin::Play::Sbstv
- Inherits:
-
Object
- Object
- Shin::Play::Sbstv
- Defined in:
- lib/shin/play/sbstv.rb
Defined Under Namespace
Classes: HTTPError, MissingArgument, NotValid
Instance Method Summary collapse
-
#before(params = {}) ⇒ Object
Fix these before running.
- #new ⇒ Object
-
#programs ⇒ Object
Programs.
-
#video(params = {}) ⇒ Object
Video.
-
#videos(params = {}) ⇒ Object
Videos.
Instance Method Details
#before(params = {}) ⇒ Object
Fix these before running
13 14 15 16 17 |
# File 'lib/shin/play/sbstv.rb', line 13 def before(params={}) raise MissingArgument, "You are missing the argument 'sbstv_domain' which is required to use this source." unless Shin.get[:sbstv_domain] != nil "http://www." + Shin.get[:sbstv_domain] end |
#new ⇒ Object
8 9 10 |
# File 'lib/shin/play/sbstv.rb', line 8 def new self end |
#programs ⇒ Object
Programs
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/shin/play/sbstv.rb', line 20 def programs domain = before() # Response response = Base.get(domain + '/api/listPrograms?format=FLASH') 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 # Multiple if data != nil data.to_hashugar else raise NotValid, "Couldn't parse the JSON" end end |
#video(params = {}) ⇒ Object
Video
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/shin/play/sbstv.rb', line 59 def video(params={}) domain = before(params) raise MissingArgument, "You are missing the argument 'id' which is required to use this source." unless params[:id] != "" # Response response = Base.get(domain + '/api/getVideo?format=FLASH&videoId=' + params[:id].to_s ) 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 |
#videos(params = {}) ⇒ Object
Videos
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/shin/play/sbstv.rb', line 39 def videos(params={}) domain = before(params) raise MissingArgument, "You are missing the argument 'id' which is required to use this source." unless params[:id] != "" # Response response = Base.get(domain + '/api/listVideos?format=FLASH&programId=' + params[:id].to_s ) 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 # Multiple if data != nil data.to_hashugar else raise NotValid, "Couldn't parse the JSON" end end |