修复短视频解析工具

This commit is contained in:
net909
2025-09-20 17:10:47 +08:00
parent ad228a550b
commit f5a6c11dda
19 changed files with 1766 additions and 18 deletions
+34
View File
@@ -0,0 +1,34 @@
<?php
namespace plugin\utility\videoparse\api;
use Exception;
use plugin\utility\videoparse\api;
class qmkg implements api
{
public function parse($url){
if(!preg_match('/\?s=(.*)/', $url, $match)) throw new Exception('视频id获取失败');
$id = $match[1];
$requrl = 'https://kg.qq.com/node/play?s=' . $id;
$text = get_curl($requrl);
preg_match('/<title>(.*?)-(.*?)-/', $text, $video_title);
preg_match('/cover\":\"(.*?)\"/', $text, $video_cover);
preg_match('/playurl_video\":\"(.*?)\"/', $text, $video_url);
if(!isset($video_url[1]))preg_match('/playurl\":\"(.*?)\"/', $text, $video_url);
preg_match('/{\"activity_id\":0\,\"avatar\":\"(.*?)\"/', $text, $video_avatar);
preg_match('/<p class=\"singer_more__time\">(.*?)<\/p>/', $text, $video_time);
if (isset($video_url[1])) {
return [
'title' => $video_title[2],
'cover' => $video_cover[1],
'url' => $video_url[1],
'author' => $video_title[1],
'avatar' => $video_avatar[1],
'time' => $video_time[1],
];
}else{
throw new Exception('视频解析失败');
}
}
}