twitter spaces and a ton of improvements
This commit is contained in:
@@ -23,9 +23,11 @@ export default async function (host, patternMatch, url, lang, obj) {
|
||||
switch (host) {
|
||||
case "twitter":
|
||||
r = await twitter({
|
||||
id: patternMatch["id"],
|
||||
id: patternMatch["id"] ? patternMatch["id"] : false,
|
||||
spaceId: patternMatch["spaceId"] ? patternMatch["spaceId"] : false,
|
||||
lang: lang
|
||||
});
|
||||
if (r.isAudioOnly) obj.isAudioOnly = true
|
||||
break;
|
||||
case "vk":
|
||||
r = await vk({
|
||||
|
||||
@@ -51,7 +51,7 @@ export default function(r, host, ip, audioFormat, isAudioOnly) {
|
||||
return apiJSON(5, {
|
||||
picker: r.picker,
|
||||
u: Array.isArray(r.urls) ? r.urls[1] : r.urls, service: host, ip: ip,
|
||||
filename: r.audioFilename, salt: process.env.streamSalt, isAudioOnly: true, audioFormat: audioFormat, copy: audioFormat == "best" ? true : false
|
||||
filename: r.audioFilename, salt: process.env.streamSalt, isAudioOnly: true, audioFormat: audioFormat, copy: audioFormat === "best" ? true : false
|
||||
})
|
||||
case "twitter":
|
||||
return apiJSON(5, {
|
||||
@@ -59,33 +59,38 @@ export default function(r, host, ip, audioFormat, isAudioOnly) {
|
||||
})
|
||||
}
|
||||
} else {
|
||||
if (host == "reddit" && r.typeId == 1 || audioIgnore.includes(host)) return apiJSON(0, { t: r.audioFilename });
|
||||
if (host === "reddit" && r.typeId === 1 || audioIgnore.includes(host)) return apiJSON(0, { t: r.audioFilename });
|
||||
let type = "render";
|
||||
let copy = false;
|
||||
|
||||
if (!supportedAudio.includes(audioFormat)) audioFormat = "best";
|
||||
if ((host == "tiktok" || host == "douyin") && isAudioOnly && services.tiktok.audioFormats.includes(audioFormat)) {
|
||||
if ((host === "tiktok" || host === "douyin") && isAudioOnly && services.tiktok.audioFormats.includes(audioFormat)) {
|
||||
if (r.isMp3) {
|
||||
if (audioFormat == "mp3" || audioFormat == "best") {
|
||||
if (audioFormat === "mp3" || audioFormat === "best") {
|
||||
audioFormat = "mp3"
|
||||
type = "bridge"
|
||||
}
|
||||
} else if (audioFormat == "best") {
|
||||
} else if (audioFormat === "best") {
|
||||
audioFormat = "m4a"
|
||||
type = "bridge"
|
||||
}
|
||||
}
|
||||
if ((audioFormat == "best" && services[host]["bestAudio"]) || services[host]["bestAudio"] && (audioFormat == services[host]["bestAudio"])) {
|
||||
if ((audioFormat === "best" && services[host]["bestAudio"]) || services[host]["bestAudio"] && (audioFormat === services[host]["bestAudio"])) {
|
||||
audioFormat = services[host]["bestAudio"]
|
||||
type = "bridge"
|
||||
} else if (audioFormat == "best") {
|
||||
} else if (audioFormat === "best") {
|
||||
audioFormat = "m4a"
|
||||
copy = true
|
||||
if (r.audioFilename.includes("twitterspaces")) {
|
||||
audioFormat = "mp3"
|
||||
copy = false
|
||||
}
|
||||
}
|
||||
return apiJSON(2, {
|
||||
type: type,
|
||||
u: Array.isArray(r.urls) ? r.urls[1] : r.urls, service: host, ip: ip,
|
||||
filename: r.audioFilename, salt: process.env.streamSalt, isAudioOnly: true, audioFormat: audioFormat, copy: copy
|
||||
filename: r.audioFilename, salt: process.env.streamSalt, isAudioOnly: true,
|
||||
audioFormat: audioFormat, copy: copy, fileMetadata: r.fileMetadata ? r.fileMetadata : false
|
||||
})
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -12,14 +12,12 @@
|
||||
"enabled": true
|
||||
},
|
||||
"twitter": {
|
||||
"patterns": [":user/status/:id", ":user/status/:id/video/1"],
|
||||
"alias": "twitter, twitter spaces",
|
||||
"patterns": [":user/status/:id", ":user/status/:id/video/1", "i/spaces/:spaceId"],
|
||||
"enabled": true
|
||||
},
|
||||
"vk": {
|
||||
"alias": "vk clips, vk video",
|
||||
"localizedAlias": {
|
||||
"ru": "vk видео, vk клипы"
|
||||
},
|
||||
"patterns": ["video-:userId_:videoId", "clip-:userId_:videoId", "clips-:userId?z=clip-:userId_:videoId"],
|
||||
"quality_match": {
|
||||
"2160": 7,
|
||||
@@ -79,8 +77,8 @@
|
||||
},
|
||||
"soundcloud": {
|
||||
"patterns": [":author/:song", ":shortLink"],
|
||||
"bestAudio": "mp3",
|
||||
"clientid": "lnFbWHXluNwOkW7TxTYUXrrse0qj1C72",
|
||||
"bestAudio": "none",
|
||||
"clientid": "1TLciEOiKE0PThutYu5Xj0kc8R4twD9p",
|
||||
"enabled": true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
export const testers = {
|
||||
"twitter": (patternMatch) => (patternMatch["id"] && patternMatch["id"].length < 20),
|
||||
"twitter": (patternMatch) => (patternMatch["id"] && patternMatch["id"].length < 20) || (patternMatch["spaceId"] && patternMatch["spaceId"].length === 13),
|
||||
|
||||
"vk": (patternMatch) => (patternMatch["userId"] && patternMatch["videoId"] &&
|
||||
patternMatch["userId"].length <= 10 && patternMatch["videoId"].length == 9),
|
||||
patternMatch["userId"].length <= 10 && patternMatch["videoId"].length === 9),
|
||||
|
||||
"bilibili": (patternMatch) => (patternMatch["id"] && patternMatch["id"].length >= 12),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user