diff --git a/api.py b/api.py index 1c94709..0bb6768 100644 --- a/api.py +++ b/api.py @@ -22,14 +22,12 @@ def get_urls(): def proxy(): # 从请求参数中获取视频链接 video_url = request.args.get("url") + print(video_url) # 检查视频链接是否提供 if not video_url: return Response("No video URL provided", status=400) - # URL解码 - video_url = urllib.parse.unquote(video_url) - headers = { "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1 Edg/122.0.0.0" } diff --git a/qushuiyin.py b/qushuiyin.py index 70854b3..8331a07 100644 --- a/qushuiyin.py +++ b/qushuiyin.py @@ -101,6 +101,172 @@ class Video: except Exception as e: return None + def pipigaoxiao(self, url): + match = re.search(r"post/(\d+)", url) + if match: + id = match.group(1) + response = self.pipigaoxiao_curl(id) + arr = json.loads(response) + img_id = arr["data"]["post"]["imgs"][0]["id"] + if img_id: + result = { + "code": 200, + "msg": "解析成功", + "data": { + "title": arr["data"]["post"]["content"], + "cover": endecode_and_proxy_url( + f"https://file.ippzone.com/img/view/id/{img_id}" + ), + "url": endecode_and_proxy_url( + arr["data"]["post"]["videos"][str(img_id)]["url"] + ), + }, + } + return result + + def pipigaoxiao_curl(self, id): + post_data = json.dumps({"pid": int(id), "type": "post", "mid": None}) + headers = { + "Referer": "http://share.ippzone.com/ppapi/share/fetch_content", + "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36", + "Content-Encoding": "gzip,deflate", + } + response = requests.post( + "http://share.ippzone.com/ppapi/share/fetch_content", + data=post_data, + headers=headers, + verify=False, + timeout=5, + ) + return response.text + + def kuaishou(self, url): + headers = { + "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3" + } + + if "v.kuaishou.com" in url: + response = requests.head(url, headers=headers, allow_redirects=True) + url = response.url + match = re.search(r"photoId=(.*?)&", url) + else: + match = re.search(r"short-video/(.*?)\?", url) + + if match: + photo_id = match.group(1) + headers = { + "Cookie": "did=web_0694588f58404427ac09c75f1845df47; didv=1721897287000;", + "Referer": url, + "Content-Type": "application/json", + } + post_data = json.dumps( + { + "photoId": photo_id.replace("video/", "").replace("?", ""), + "isLongVideo": False, + } + ) + url = "https://v.m.chenzhongtech.com/rest/wd/photo/info" + response = requests.post(url, headers=headers, data=post_data) + json_data = response.json() + + video_url = json_data["photo"]["mainMvUrls"][0]["url"] + if video_url: + result = { + "code": 200, + "msg": "解析成功", + "data": { + "avatar": endecode_and_proxy_url(json_data["photo"]["headUrl"]), + "author": json_data["photo"]["userName"], + "time": json_data["photo"]["timestamp"], + "title": json_data["photo"]["caption"], + "cover": endecode_and_proxy_url( + json_data["photo"]["coverUrls"][0]["url"] + ), + "url": endecode_and_proxy_url(video_url), + }, + } + return result + return None + + def zuiyou(self, url): + response = requests.get(url) + text = response.text + video = re.search(r'fullscreen="false" src="(.*?)"', text) + video_title = re.search(r":