cleaning up what i missed
This commit is contained in:
parent
18199c534f
commit
3c578d6d49
9 changed files with 17 additions and 17 deletions
|
@ -69,8 +69,8 @@ if (fs.existsSync('./.env') && process.env.selfURL && process.env.streamSalt &&
|
||||||
try {
|
try {
|
||||||
JSON.parse(buf);
|
JSON.parse(buf);
|
||||||
if (buf.length > 720) throw new Error();
|
if (buf.length > 720) throw new Error();
|
||||||
if (req.header('Content-Type') != "application/json") res.status(500).json({ 'status': 'error', 'text': 'invalid content type header' })
|
if (String(req.header('Content-Type')) !== "application/json") res.status(500).json({ 'status': 'error', 'text': 'invalid content type header' })
|
||||||
if (req.header('Accept') != "application/json") res.status(500).json({ 'status': 'error', 'text': 'invalid accept header' })
|
if (String(req.header('Accept')) !== "application/json") res.status(500).json({ 'status': 'error', 'text': 'invalid accept header' })
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
res.status(500).json({ 'status': 'error', 'text': 'invalid json body.' })
|
res.status(500).json({ 'status': 'error', 'text': 'invalid json body.' })
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ export function changelogHistory() { // blockId 0
|
||||||
|
|
||||||
let historyLen = history.length
|
let historyLen = history.length
|
||||||
for (let i in history) {
|
for (let i in history) {
|
||||||
let separator = (i != 0 && i != historyLen) ? '<div class="separator"></div>' : ''
|
let separator = (i !== 0 && i !== historyLen) ? '<div class="separator"></div>' : ''
|
||||||
render += `${separator}${history[i]["banner"] ? `<div class="changelog-banner"><img class="changelog-img" src="${history[i]["banner"]}" onerror="this.style.display='none'"></img></div>` : ''}<div id="popup-desc" class="changelog-subtitle">${history[i]["title"]}</div><div id="popup-desc" class="desc-padding">${history[i]["content"]}</div>`
|
render += `${separator}${history[i]["banner"] ? `<div class="changelog-banner"><img class="changelog-img" src="${history[i]["banner"]}" onerror="this.style.display='none'"></img></div>` : ''}<div id="popup-desc" class="changelog-subtitle">${history[i]["title"]}</div><div id="popup-desc" class="desc-padding">${history[i]["content"]}</div>`
|
||||||
}
|
}
|
||||||
return render;
|
return render;
|
||||||
|
|
|
@ -13,7 +13,7 @@ export default async function(obj) {
|
||||||
|
|
||||||
let video = data["secure_media"]["reddit_video"]["fallback_url"].split('?')[0],
|
let video = data["secure_media"]["reddit_video"]["fallback_url"].split('?')[0],
|
||||||
audio = video.match('.mp4') ? `${video.split('_')[0]}_audio.mp4` : `${data["secure_media"]["reddit_video"]["fallback_url"].split('DASH')[0]}audio`;
|
audio = video.match('.mp4') ? `${video.split('_')[0]}_audio.mp4` : `${data["secure_media"]["reddit_video"]["fallback_url"].split('DASH')[0]}audio`;
|
||||||
await fetch(audio, { method: "HEAD" }).then((r) => {if (r.status != 200) audio = ''}).catch(() => {audio = ''});
|
await fetch(audio, { method: "HEAD" }).then((r) => {if (Number(r.status) !== 200) audio = ''}).catch(() => {audio = ''});
|
||||||
|
|
||||||
let id = data["secure_media"]["reddit_video"]["fallback_url"].split('/')[3];
|
let id = data["secure_media"]["reddit_video"]["fallback_url"].split('/')[3];
|
||||||
if (!audio.length > 0) return { typeId: 1, urls: video };
|
if (!audio.length > 0) return { typeId: 1, urls: video };
|
||||||
|
|
|
@ -56,7 +56,7 @@ export default async function(obj) {
|
||||||
|
|
||||||
let fileUrlBase = json.media.transcodings[0]["url"].replace("/hls", "/progressive")
|
let fileUrlBase = json.media.transcodings[0]["url"].replace("/hls", "/progressive")
|
||||||
let fileUrl = `${fileUrlBase}${fileUrlBase.includes("?") ? "&" : "?"}client_id=${clientId}&track_authorization=${json.track_authorization}`;
|
let fileUrl = `${fileUrlBase}${fileUrlBase.includes("?") ? "&" : "?"}client_id=${clientId}&track_authorization=${json.track_authorization}`;
|
||||||
if (!fileUrl.substring(0, 54) === "https://api-v2.soundcloud.com/media/soundcloud:tracks:") return { error: 'ErrorEmptyDownload' };
|
if (fileUrl.substring(0, 54) !== "https://api-v2.soundcloud.com/media/soundcloud:tracks:") return { error: 'ErrorEmptyDownload' };
|
||||||
|
|
||||||
if (json.duration > maxAudioDuration) return { error: ['ErrorLengthAudioConvert', maxAudioDuration / 60000] };
|
if (json.duration > maxAudioDuration) return { error: ['ErrorLengthAudioConvert', maxAudioDuration / 60000] };
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,7 @@ export default async function(obj) {
|
||||||
if (!AudioSpaceById) return { error: 'ErrorEmptyDownload' };
|
if (!AudioSpaceById) return { error: 'ErrorEmptyDownload' };
|
||||||
|
|
||||||
if (!AudioSpaceById.data.audioSpace.metadata) return { error: 'ErrorEmptyDownload' };
|
if (!AudioSpaceById.data.audioSpace.metadata) return { error: 'ErrorEmptyDownload' };
|
||||||
if (!AudioSpaceById.data.audioSpace.metadata.is_space_available_for_replay === true) return { error: 'TwitterSpaceWasntRecorded' };
|
if (AudioSpaceById.data.audioSpace.metadata.is_space_available_for_replay !== true) return { error: 'TwitterSpaceWasntRecorded' };
|
||||||
|
|
||||||
let streamStatus = await fetch(
|
let streamStatus = await fetch(
|
||||||
`https://twitter.com/i/api/1.1/live_video_stream/status/${AudioSpaceById.data.audioSpace.metadata.media_key}`, { headers: _headers }
|
`https://twitter.com/i/api/1.1/live_video_stream/status/${AudioSpaceById.data.audioSpace.metadata.media_key}`, { headers: _headers }
|
||||||
|
|
|
@ -13,7 +13,7 @@ export default async function(obj) {
|
||||||
let best = all[0];
|
let best = all[0];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (obj.quality != "max") {
|
if (obj.quality !== "max") {
|
||||||
let pref = parseInt(quality[obj.quality], 10)
|
let pref = parseInt(quality[obj.quality], 10)
|
||||||
for (let i in all) {
|
for (let i in all) {
|
||||||
let currQuality = parseInt(all[i]["quality"].replace('p', ''), 10)
|
let currQuality = parseInt(all[i]["quality"].replace('p', ''), 10)
|
||||||
|
@ -50,7 +50,7 @@ export default async function(obj) {
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "parcel":
|
case "parcel":
|
||||||
if (obj.quality != "max") {
|
if (obj.quality !== "max") {
|
||||||
let pref = parseInt(quality[obj.quality], 10)
|
let pref = parseInt(quality[obj.quality], 10)
|
||||||
for (let i in masterJSON_Video) {
|
for (let i in masterJSON_Video) {
|
||||||
let currQuality = parseInt(services.vimeo.resolutionMatch[masterJSON_Video[i]["width"]], 10)
|
let currQuality = parseInt(services.vimeo.resolutionMatch[masterJSON_Video[i]["width"]], 10)
|
||||||
|
|
|
@ -12,7 +12,7 @@ export default async function(obj) {
|
||||||
|
|
||||||
let js = JSON.parse('{"lang":' + html.split(`{"lang":`)[1].split(']);')[0]);
|
let js = JSON.parse('{"lang":' + html.split(`{"lang":`)[1].split(']);')[0]);
|
||||||
|
|
||||||
if (!Number(js["mvData"]["is_active_live"]) === 0) return { error: 'ErrorLiveVideo' };
|
if (Number(js["mvData"]["is_active_live"]) !== 0) return { error: 'ErrorLiveVideo' };
|
||||||
if (js["mvData"]["duration"] > maxVideoDuration / 1000) return { error: ['ErrorLengthLimit', maxVideoDuration / 60000] };
|
if (js["mvData"]["duration"] > maxVideoDuration / 1000) return { error: ['ErrorLengthLimit', maxVideoDuration / 60000] };
|
||||||
|
|
||||||
let mpd = JSON.parse(xml2json(js["player"]["params"][0]["manifest"], { compact: true, spaces: 4 }));
|
let mpd = JSON.parse(xml2json(js["player"]["params"][0]["manifest"], { compact: true, spaces: 4 }));
|
||||||
|
|
|
@ -12,7 +12,7 @@ export default async function(obj) {
|
||||||
|
|
||||||
let videoMatch = [], fullVideoMatch = [], video = [],
|
let videoMatch = [], fullVideoMatch = [], video = [],
|
||||||
audio = info.filter((a) => {
|
audio = info.filter((a) => {
|
||||||
if (!a["isHLS"] && !a["isDashMPD"] && a["hasAudio"] && !a["hasVideo"] && a["container"] == obj.format) return true
|
if (!a["isHLS"] && !a["isDashMPD"] && a["hasAudio"] && !a["hasVideo"] && a["container"] === obj.format) return true
|
||||||
}).sort((a, b) => Number(b.bitrate) - Number(a.bitrate));
|
}).sort((a, b) => Number(b.bitrate) - Number(a.bitrate));
|
||||||
|
|
||||||
if (audio.length === 0) return { error: 'ErrorBadFetch' };
|
if (audio.length === 0) return { error: 'ErrorBadFetch' };
|
||||||
|
@ -20,11 +20,11 @@ export default async function(obj) {
|
||||||
|
|
||||||
if (!isAudioOnly) {
|
if (!isAudioOnly) {
|
||||||
video = info.filter((a) => {
|
video = info.filter((a) => {
|
||||||
if (!a["isHLS"] && !a["isDashMPD"] && a["hasVideo"] && a["container"] == obj.format) {
|
if (!a["isHLS"] && !a["isDashMPD"] && a["hasVideo"] && a["container"] === obj.format) {
|
||||||
if (obj.quality != "max") {
|
if (obj.quality !== "max") {
|
||||||
if (a["hasAudio"] && mq[obj.quality] == a["height"]) {
|
if (a["hasAudio"] && String(mq[obj.quality]) === String(a["height"])) {
|
||||||
fullVideoMatch.push(a)
|
fullVideoMatch.push(a)
|
||||||
} else if (!a["hasAudio"] && mq[obj.quality] == a["height"]) {
|
} else if (!a["hasAudio"] && String(mq[obj.quality]) === String(a["height"])) {
|
||||||
videoMatch.push(a)
|
videoMatch.push(a)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,11 +32,11 @@ export default async function(obj) {
|
||||||
}
|
}
|
||||||
}).sort((a, b) => Number(b.bitrate) - Number(a.bitrate));
|
}).sort((a, b) => Number(b.bitrate) - Number(a.bitrate));
|
||||||
|
|
||||||
if (obj.quality != "max") {
|
if (obj.quality !== "max") {
|
||||||
if (videoMatch.length === 0) {
|
if (videoMatch.length === 0) {
|
||||||
let ss = selectQuality("youtube", obj.quality, video[0]["qualityLabel"].slice(0, 5).replace('p', '').trim());
|
let ss = selectQuality("youtube", obj.quality, video[0]["qualityLabel"].slice(0, 5).replace('p', '').trim());
|
||||||
videoMatch = video.filter((a) => {
|
videoMatch = video.filter((a) => {
|
||||||
if (a["qualityLabel"].slice(0, 5).replace('p', '').trim() == ss) return true
|
if (a["qualityLabel"].slice(0, 5).replace('p', '').trim() === String(ss)) return true
|
||||||
})
|
})
|
||||||
} else if (fullVideoMatch.length > 0) {
|
} else if (fullVideoMatch.length > 0) {
|
||||||
videoMatch = [fullVideoMatch[0]]
|
videoMatch = [fullVideoMatch[0]]
|
||||||
|
|
|
@ -27,7 +27,7 @@ export function streamDefault(streamInfo, res) {
|
||||||
}
|
}
|
||||||
export function streamLiveRender(streamInfo, res) {
|
export function streamLiveRender(streamInfo, res) {
|
||||||
try {
|
try {
|
||||||
if (!streamInfo.urls.length === 2) {
|
if (streamInfo.urls.length !== 2) {
|
||||||
res.end();
|
res.end();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue