picgo-plugin-bilibili
Advanced tools
Comparing version
{ | ||
"name": "picgo-plugin-bilibili", | ||
"version": "1.1.6", | ||
"version": "1.1.7", | ||
"description": "bilibili 图床", | ||
@@ -11,3 +11,3 @@ "main": "src/index.js", | ||
"scripts": { | ||
"publish": "npm publish --registry http://registry.npmjs.org", | ||
"publish": "npm publish --registry https://registry.npmjs.org", | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
@@ -14,0 +14,0 @@ "patch": "npm version patch && git push origin master && git push origin --tags", |
@@ -36,3 +36,3 @@ ## picgo-plugin-bilibili | ||
切换到新目录执行 `npm install ./picgo-plugin-smms-user`,然后重启应用即可。 | ||
切换到新目录执行 `npm install ./picgo-plugin-bilibili`,然后重启应用即可。 | ||
@@ -39,0 +39,0 @@ |
@@ -12,6 +12,6 @@ const fs = require('fs') | ||
} | ||
const postOptions = (SESSDATA, fileName, image) => { | ||
const postOptions = (SESSDATA, csrf, fileName, image) => { | ||
return { | ||
method: 'POST', | ||
url: `https://api.vc.bilibili.com/api/v1/drawImage/upload`, | ||
url: `https://api.bilibili.com/x/dynamic/feed/draw/upload_bfs`, | ||
headers: { | ||
@@ -24,3 +24,4 @@ contentType: 'multipart/form-data', | ||
category: 'daily', | ||
biz: 'draw' | ||
biz: 'new_dyn', | ||
csrf | ||
} | ||
@@ -40,3 +41,13 @@ } | ||
} | ||
if (!userConfig.csrf) { | ||
ctx.emit('notification', { | ||
title: '请先配置csrf', | ||
body: '链接已复制,请打开浏览器粘贴地址查看相关教程', | ||
text: 'https://www.yuque.com/docs/share/9035662a-f2bd-4ba2-aa24-73acb98635c7' | ||
}) | ||
return | ||
// throw new Error('请先配置SESSDATA') | ||
} | ||
const SESSDATA = userConfig.SESSDATA | ||
const csrf = userConfig.csrf | ||
const imgList = ctx.output | ||
@@ -52,3 +63,3 @@ for (let i in imgList) { | ||
await fs.writeFileSync(filePath, data) | ||
const postConfig = postOptions(SESSDATA, fileName, fs.createReadStream(filePath)) | ||
const postConfig = postOptions(SESSDATA, csrf, fileName, fs.createReadStream(filePath)) | ||
let body = await ctx.Request.request(postConfig) | ||
@@ -55,0 +66,0 @@ fs.unlink(filePath, () => {}) |
9151
4.68%104
11.83%