mirror of
https://github.com/develop202/migu_video.git
synced 2025-12-17 15:25:03 +08:00
添加蓝光、高清、标清
This commit is contained in:
132
utils/androidURL.js
Normal file
132
utils/androidURL.js
Normal file
@@ -0,0 +1,132 @@
|
||||
import axios from "axios";
|
||||
import { getStringMD5 } from "./EncryUtils.js";
|
||||
import { getEncryptURL } from "./getddCalcuURL.js";
|
||||
import { changedDdCalcu } from "./datas.js";
|
||||
|
||||
function getSaltAndSign(md5) {
|
||||
|
||||
const salt = 1230024
|
||||
const suffix = "3ce941cc3cbc40528bfd1c64f9fdf6c0migu0123"
|
||||
const sign = getStringMD5(md5 + suffix)
|
||||
return {
|
||||
salt: salt,
|
||||
sign: sign
|
||||
}
|
||||
}
|
||||
|
||||
function replaceChars(url, pid, rateType) {
|
||||
|
||||
// 参数为空或者不符条件
|
||||
if (!url || rateType <= 1 || rateType >= 5 || !pid) {
|
||||
return ""
|
||||
}
|
||||
const spl = url.split("&ddCalcu=")
|
||||
const prefix = spl[0]
|
||||
let suffix = spl[1]
|
||||
|
||||
suffix = suffix.replace("sv=10000&ct=www", "sv=10004&ct=android")
|
||||
// 默认替换方式
|
||||
let defaultChange = ["x", "a", "y", "a"]
|
||||
let index = [5, 8, 11, 14]
|
||||
// 一些标清不需要改
|
||||
let noChangeStandard = false
|
||||
|
||||
// 替换自定义替换方式
|
||||
if (changedDdCalcu[pid] != undefined) {
|
||||
noChangeStandard = changedDdCalcu[pid].noChangeStandard
|
||||
if (changedDdCalcu[pid]["all"] != undefined) {
|
||||
defaultChange = changedDdCalcu[pid]["all"].data
|
||||
index = changedDdCalcu[pid]["all"].index
|
||||
}
|
||||
if (changedDdCalcu[pid][rateType]) {
|
||||
// 若相邻两个重复可以写另一个的rateType
|
||||
if (!isNaN(changedDdCalcu[pid][rateType])) {
|
||||
const rate = changedDdCalcu[pid][rateType]
|
||||
defaultChange = changedDdCalcu[pid][rate].data
|
||||
index = changedDdCalcu[pid][rate].index
|
||||
} else {
|
||||
defaultChange = changedDdCalcu[pid][rateType].data
|
||||
index = changedDdCalcu[pid][rateType].index
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 一些标清需要改
|
||||
if (rateType == 2 && !noChangeStandard) {
|
||||
defaultChange[0] = "v"
|
||||
}
|
||||
|
||||
// 替换
|
||||
let suffixSplit = suffix.split("")
|
||||
for (let i = 0; i < index.length; i++) {
|
||||
suffixSplit[index[i] - 1] = defaultChange[i]
|
||||
}
|
||||
|
||||
return `${prefix}&ddCalcu=${suffixSplit.join("")}`
|
||||
}
|
||||
|
||||
async function getAndroidVideoURL(userId, token, exports, pid, rateType) {
|
||||
if (rateType <= 1 || rateType >= 5) {
|
||||
return {
|
||||
url: "",
|
||||
rateType: 0
|
||||
}
|
||||
}
|
||||
if (!exports) {
|
||||
return {
|
||||
url: "",
|
||||
rateType: 0
|
||||
}
|
||||
}
|
||||
// 获取url
|
||||
const timestramp = Date.now()
|
||||
const appVersion = "26000370"
|
||||
let headers = {
|
||||
AppVersion: 2600037000,
|
||||
TerminalId: "android",
|
||||
"X-UP-CLIENT-CHANNEL-ID": "2600037000-99000-200300220100002"
|
||||
}
|
||||
if (rateType != 2) {
|
||||
headers.UserId = userId
|
||||
headers.UserToken = token
|
||||
}
|
||||
// console.log(headers)
|
||||
const str = timestramp + pid + appVersion
|
||||
const md5 = getStringMD5(str)
|
||||
const result = getSaltAndSign(md5)
|
||||
|
||||
// 请求
|
||||
const baseURL = "https://play.miguvideo.com/playurl/v1/play/playurl"
|
||||
const params = "?sign=" + result.sign + "&rateType=" + rateType
|
||||
+ "&contId=" + pid + "×tamp=" + timestramp + "&salt=" + result.salt
|
||||
const respData = await axios.get(baseURL + params, {
|
||||
headers: headers
|
||||
}).then(r => r.data)
|
||||
|
||||
// console.log(respData)
|
||||
const url = respData.body.urlInfo?.url
|
||||
// console.log(rateType)
|
||||
// console.log(url)
|
||||
if (!url) {
|
||||
return {
|
||||
url: "",
|
||||
rateType: 0
|
||||
}
|
||||
}
|
||||
rateType = parseInt(respData.body.urlInfo?.rateType)
|
||||
|
||||
// 将URL加密
|
||||
const encryURL = getEncryptURL(exports, url)
|
||||
// console.log("加密后:" + encryURL)
|
||||
// 替换字符,拼接结果
|
||||
const resURL = replaceChars(encryURL, pid, rateType)
|
||||
// console.log("app替换后的链接:" + resURL)
|
||||
// console.log("播放画质:" + rateType)
|
||||
return {
|
||||
url: resURL,
|
||||
rateType: rateType
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default getAndroidVideoURL
|
||||
Reference in New Issue
Block a user