class Getvideo::Iqiyi

Public Instance Methods

cover() click to toggle source
# File lib/getvideo/iqiyi.rb, line 29
def cover
  response_info["albumImage"]
end
flash() click to toggle source
# File lib/getvideo/iqiyi.rb, line 37
def flash
  position = response_info["logoPosition"]
  duration = response_info["totalDuration"]
  video_url =  response_info["videoUrl"].gsub("http://www.iqiyi.com/","")
  "http://player.video.qiyi.com/#{id}/#{position}/#{duration}/#{video_url}"[0..-5]+"swf"
end
html_url() click to toggle source
# File lib/getvideo/iqiyi.rb, line 11
def html_url
  response_info["videoUrl"]
end
id() click to toggle source
# File lib/getvideo/iqiyi.rb, line 15
def id
  if url =~ /\.html/
    parse_vid[1]
  elsif url =~ /swf/
    url.scan(/com\/([^\/]+)/)[0][0]
  else
    url
  end
end
ipad_response() click to toggle source
# File lib/getvideo/iqiyi.rb, line 7
def ipad_response
  @ipad_response ||= ipad_connection
end
m3u8() click to toggle source
# File lib/getvideo/iqiyi.rb, line 33
def m3u8
  ipad_response["data"]["mtl"][1]["m3u"]
end
media() click to toggle source
# File lib/getvideo/iqiyi.rb, line 44
def media
  video_list = {}
  video_list["mp4"] = []
  video_list["f4v"] = []
  mp4_file = ipad_response["data"]["mp4Url"]
  res  = Faraday.get "http://data.video.qiyi.com/#{mp4_file.split("/")[-1].split(".")[0]}.ts"
  video_list["mp4"] << "#{mp4_file}?#{URI.parse(res["location"]).query}"
  file = response_info["fileUrl"]["file"]
  size = response_info["fileBytes"]["size"]
  file.each_with_index do |f, i|
    res  = Faraday.get "http://data.video.qiyi.com/#{file[i].split("/")[-1].split(".")[0]}.ts"
    video_list["f4v"] << "#{f}?#{URI.parse(res["location"]).query}"
  end
  return  video_list
end
title() click to toggle source
# File lib/getvideo/iqiyi.rb, line 25
def title
  response_info["title"]
end

Private Instance Methods

ipad_connection() click to toggle source
# File lib/getvideo/iqiyi.rb, line 62
def ipad_connection
  conn = Faraday.new "http://cache.video.qiyi.com"
  conn.headers["User-Agent"] = ""
  response= conn.get "/m/#{id}/"
  MultiJson.load response.body.scan(/ipadUrl=([^*]+)/)[0][0]
end
parse_vid() click to toggle source
# File lib/getvideo/iqiyi.rb, line 69
def parse_vid
  conn = Faraday.new
  page_res = conn.get(url)
  return page_res.body.match(/data-player-videoid\s*[:=]\s*["']([^"']+)["']/)
end
response_info() click to toggle source
# File lib/getvideo/iqiyi.rb, line 75
def response_info
  response["root"]["video"]
end