class Shin::Play::Tv4play

Public Instance Methods

movies() click to toggle source

Movies

# File lib/shin/play/tv4play.rb, line 73
def movies
  # Response
  response = Base.get('http://webapi.tv4play.se/play/movie_assets?platform=web&start=0&rows=9999')
  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
new() click to toggle source
# File lib/shin/play/tv4play.rb, line 6
def new
  self
end
programs() click to toggle source

Programs

# File lib/shin/play/tv4play.rb, line 11
def programs
  # Response
  response = Base.get('http://webapi.tv4play.se/play/programs?per_page=900&page=1')
  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
video(params={}) click to toggle source

Video

# File lib/shin/play/tv4play.rb, line 49
def video(params={})
  raise MissingArgument, "You are missing the argument 'id' which is required to use this source." unless params[:id] != ""

  # Response
  response = Base.get('http://webapi.tv4play.se/play/video_assets?id=' + 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
    if data['total_hits'] == 0
      raise NotValid, "No results"
    else
      data['results'].first.to_hashugar
    end

  else
    raise NotValid, "Couldn't parse the JSON"
  end
end
videos(params={}) click to toggle source

Videos

# File lib/shin/play/tv4play.rb, line 29
def videos(params={})
  raise MissingArgument, "You are missing the argument 'id' which is required to use this source." unless params[:id] != ""

  # Response
  response = Base.get('http://webapi.tv4play.se/play/video_assets?type=episode&is_live=false&platform=web&per_page=99999&node_nids=' + 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['results'].to_hashugar
  else
    raise NotValid, "Couldn't parse the JSON"
  end

end