https://boss.hdslb.com/xpeacha-pub/c7450694-ee75-48a4-8430-a73e787532e5.mp4
在一个动漫站 发现这样的直链。 然后研究了会~
发现是在 https://workshop.bilibili.com 上传的
进去后点发布 -> 插画 -> 仅展示 在上传图片那里就可以传 不过前端有限制文件格式 可以用开发者工具的文件替换 修改一下就可以绕过
上传后可以在网络面板找到链接,前面的域名可以替换为 boss.hdslb.com
----------------------------------------------------------------------------------------------
上面的是手动去上传的方法 这里说下用程序上传的方法 大佬有兴趣的话可以写个上传工具
因为上传的接口有跨越限制 所以我没弄网页版来上传,就分享下上传的方法
通过请求 https://api.live.bilibili.com/xlive/virtual-interface/v2/common/upload_file?suffix=mp4&bucket=xpeacha-pub (需要Cookie SESSDATA) 获取到上传链接
然后直接用PUT方法上传文件即可~ 上传完成后 上传链接去掉参数 就是文件直链 域名可以换成boss.hdslb.com
php源码
<?php
if(PHP_SAPI != 'cli')exit('请在CLI模式下运行!');
$cookie = 'SESSDATA=;';//这里填写自己的Cookie
$type = 'mp4';
$list = glob('*.'.$type);
var_dump($list);
foreach($list as $file){
$result = curl('https://api.live.bilibili.com/xlive/virtual-interface/v2/common/upload_file?suffix='.$type.'&bucket=xpeacha-pub',0,$cookie);
if($result){
$result = json_decode($result,true);
if($result['code'] == 0 && $result['data']['url']){
$r = curlupload($result['data']['url'],$cookie,$file);
echo explode('?',$result['data']['url'])[0];
}else{
cliecho('['.$file.'] '.'获取上传链接失败');
}
}
}
function cliecho($msg){
echo '['.date('H:i:s').'] '.$msg.PHP_EOL;
}
function curl($url,$post=false,$cookie=false,$header=false,$split=false){
$ch = curl_init();
if($header){
curl_setopt($ch,CURLOPT_HEADER, 1);
}else{
curl_setopt($ch,CURLOPT_HEADER, 0);
}
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch,CURLINFO_HEADER_OUT,1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.62 Safari/537.36');
if($post){
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$post);
}
if($cookie){
curl_setopt($ch, CURLOPT_COOKIE,$cookie);
}
$result = curl_exec($ch);
if($split){
$headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = substr($result, 0, $headerSize);
$body = substr($result, $headerSize);
$result=array();
$result['header']=$header;
$result['body']=$body;
}
curl_close($ch);
return $result;
}
function curlupload($url,$cookie=false,$put=false){
$ch = curl_init();
curl_setopt($ch,CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch,CURLINFO_HEADER_OUT,1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_NOPROGRESS, 0);
curl_setopt($ch, CURLOPT_PROGRESSFUNCTION ,'callback');
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.62 Safari/537.36');
if($cookie){
curl_setopt($ch, CURLOPT_COOKIE,$cookie);
}
if($put){
curl_setopt($ch, CURLOPT_PUT, 1);
$fh = fopen($put,'rw');
curl_setopt($ch, CURLOPT_INFILE ,$fh);
curl_setopt($ch, CURLOPT_INFILESIZE ,filesize($put));
}
$result = curl_exec($ch);
curl_close($ch);
if($put&&$fh)fclose($fh);
return $result;
}
function callback($ch, $downloadSize = 0, $downloaded = 0, $uploadSize = 0, $uploaded = 0){
// 这里是之前项目的代码复制过来的 貌似也没啥影响 就不改了
global $startTime,$preTime,$preSize,$sizeErr;
if($preTime == 0)$preTime = $startTime;
$nowTime = time();
/* 限制1秒输出一次下载进度 */
if($nowTime > $preTime){
$preTime = $nowTime;
$uploadSize = intval($uploadSize / 1024 / 1024);
$uploaded = intval($uploaded / 1024 / 1024);
if($preSize == $uploaded){
$sizeErr++;
if($sizeErr >= 30){
return true;
cliecho('进度已30s不变,结束此次上传');
}
}else{
$sizeErr = 0;
}
$preSize = $uploaded;
cliecho($uploaded.' MB/'.$uploadSize.' MB');
}
}