BOBOBK

Using Python to Get Real Video URLs from VIP Parsing Sites

MISCELLANEOUS

There are currently many video sites in China, including Tencent Video, iQIYI, Youku, Bilibili, etc. These sites have a lot of VIP videos that require payment. Recently, there have been a few dramas I wanted to watch, but without a VIP membership, I can only watch fewer episodes. And there are a ton of ads—sometimes up to 2 minutes long…

We know there are many websites that offer VIP parsing services. You just need to enter the URL from a video site to watch VIP-paid videos for free. However, these sites are often filled with illegal gambling ads and other junk content.

So is there a way to directly get the real video URL and skip all those messy ads? The answer is yes! Here, I’ll share how to use Python to get the real video URL from a parsing website.

First, check the browser interaction of the VIP parsing API using Chrome’s Inspection tool

Analyze the API information

  1. lines - GET request: url=video address
  2. getdata - POST request: url=http%3A%2F%2Fv.qq.com%2Fx%2Fcover%2Frpup19lfbuf2skc%2Fg0029ekbpd6.html&type=&key=a0b923820dcc509a
  3. ifr - GET request: url=LiSg7jItqXTUjnI0rfar6jNr8672uNqmzcE3%2fE8whXz46oRaKtvpLWAbKlVXQURbI5uRDKSg3X56NfVYM8kbaQ%3d%3d&type=m3u8
  4. api - POST request: url=LiSg7jItqXTUjnI0rfar6jNr8672uNqmzcE3%2FE8whXz46oRaKtvpLWAbKlVXQURbI5uRDKSg3X56NfVYM8kbaQ%3D%3D&type=m3u8&from=jiexi_site_url&device=&up=0

After analyzing the above API and extracting the POST and GET parameters, we can easily get the final video URL using Python.

Here’s the code

#!env python
import requests
import re
import json
url = "http://v.qq.com/x/cover/5a3aweewodeclku/b0024j13g3b.html"

#def get_address(url):
md5 = re.search(r'key:"(.*?)"',requests.get("http://jiexi_site_url/lines?url="+url).text).group(1)
dic = json.loads(requests.post("http://jiexi_site_url/lines/getdata",data={"url":url,"type":"","key":md5}).text)

for i in dic:
    iurl=i["Url"]
    posturl= iurl.split("?url=")[0]+"/api/"
    url = iurl.split("url=")[1].split("&")[0].replace("%3d","=").replace("%2f","/").replace("%2b","+")
    if "type=" in iurl :
        utype=iurl.split("type=")[1]
    r = requests.post(posturl,data={"url":url,"type":utype,"from":"jiexi_site_url","device":"","up":""})
    print(r.text)

Once you run it, you’ll see the real video URL parsed and printed out.

As a bonus, you can use a free web player to build a parsing web page. Here’s the address: vip_parse

Check out how the interface performs—HD and ad-free, works great.

Related