微软OneDrive的图片和音视频嵌入博客
- 方法一: 使用OneDrive网页版自带的嵌入,实测对图片文件管用,但是会压缩图片质量。
- 方法二: 使用 https://github.com/Mapaler/GetOneDriveDirectLink , 获得storage.live.com开头的固定直链网址, 图片、视频、音频都好使。
- 方法三: 给方法二获得的storage.live.com网址套一层cloudflare的CNAME,实测管用,可以规避未来storage.live.com被封的可能
- 方法四: 用1drv.ms的分享链接,手动修改重定向后的地址中的
redir
为download
,便可获取临时地址,但是会跳转到onedrive.live.com,因此需要国外服务器/cloudflare workers等作中转。
附cf workers关键代码:
addEventListener("fetch", (event) => {
event.respondWith(
handleRequest(event.request).catch(
(err) => new Response(err.stack, { status: 500 })
)
);
});
async function handleRequest(request) {
const { origin } = new URL(request.url);
var url1 = String(request.url).replace(origin + '/', 'https://1drv.ms/')
let url2 = await fetch(url1, {redirect: "manual"}).then(function(response){
let innerUrl2 = response.headers.get('location');
return innerUrl2.replace('/redir?', '/download?');
});
let url3 = await fetch(url2, {redirect: "manual"}).then(function(response){
let innerUrl3 = response.headers.get('location').replace('?download','?');
return innerUrl3;
});
return new Response(``, {
status: 301,
headers: {
Location: url3,
"Cache-Control":"max-age=60"
},
});
}
https://1drv.ms/v/s!AqpFcPtySpJNqAbVx3KvIpyx0bfk?e=geLwcy
https://github.com/Mapaler/GetOneDriveDirectLink
https://github.com/aploium/OneDrive-Direct-Link
https://github.com/spencerwooo/onedrive-cf-index
https://github.com/reruin/sharelist https://github.com/txperl/JustList
> link1 link2