Comparing version 0.2.3 to 0.2.4
{ | ||
"name": "bv2av", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"description": "Convert new bv code of bilibili to old av code", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -1,7 +0,7 @@ | ||
import axios from 'axios'; | ||
const axios = require("axios"); | ||
const API = 'https://api.bilibili.com/x/web-interface/view'; | ||
const API = "https://api.bilibili.com/x/web-interface/view"; | ||
const HEADER = { | ||
'User-Agent': | ||
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36', | ||
"User-Agent": | ||
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36", | ||
}; | ||
@@ -12,3 +12,3 @@ | ||
super(msg); | ||
this.name = 'RequestError'; | ||
this.name = "RequestError"; | ||
this.errorCode = code; | ||
@@ -21,3 +21,3 @@ } | ||
export async function getBvInfo(bv) { | ||
async function getBvInfo(bv) { | ||
const rsp = await axios.get(API, { | ||
@@ -47,5 +47,10 @@ params: { | ||
export async function bv2av(bv) { | ||
async function bv2av(bv) { | ||
const info = await getBvInfo(bv); | ||
return info.avID; | ||
} | ||
module.exports = { | ||
getBvInfo, | ||
bv2av, | ||
}; |
40398
81