class Shin::Play::Sbstv

Public Instance Methods

before(params={}) click to toggle source

Fix these before running

# 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() click to toggle source
# File lib/shin/play/sbstv.rb, line 8
def new
  self
end
programs() click to toggle source

Programs

# 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={}) click to toggle source

Video

# 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={}) click to toggle source

Videos

# 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