reddit is back!
- fixed reddit support (i had no idea older posts had a different naming pattern for media files) - improved russian localisation - now frontend handles more unexpected api errors in case something goes absolutely wrong
This commit is contained in:
@@ -25,7 +25,7 @@ export default async function (host, patternMatch, url, ip, lang, format, qualit
|
||||
videoId: patternMatch["videoId"],
|
||||
lang: lang, quality: quality
|
||||
});
|
||||
return (!r.error) ? apiJSON(2, { type: "bridge", urls: r.url, filename: r.filename, service: host, ip: ip, salt: process.env.streamSalt }) : apiJSON(0, { t: r.error });
|
||||
return (!r.error) ? apiJSON(2, { type: "bridge", u: r.url, filename: r.filename, service: host, ip: ip, salt: process.env.streamSalt }) : apiJSON(0, { t: r.error });
|
||||
} else throw Error()
|
||||
case "bilibili":
|
||||
if (patternMatch["id"] && patternMatch["id"].length >= 12) {
|
||||
@@ -34,7 +34,7 @@ export default async function (host, patternMatch, url, ip, lang, format, qualit
|
||||
lang: lang
|
||||
});
|
||||
return (!r.error) ? apiJSON(2, {
|
||||
type: "render", urls: r.urls, lang: lang,
|
||||
type: "render", u: r.urls, lang: lang,
|
||||
service: host, ip: ip,
|
||||
filename: r.filename,
|
||||
salt: process.env.streamSalt, time: r.time
|
||||
@@ -62,7 +62,7 @@ export default async function (host, patternMatch, url, ip, lang, format, qualit
|
||||
}
|
||||
let r = await youtube(fetchInfo);
|
||||
return (!r.error) ? apiJSON(2, {
|
||||
type: r.type, urls: r.urls, service: host, ip: ip,
|
||||
type: r.type, u: r.urls, service: host, ip: ip,
|
||||
filename: r.filename, salt: process.env.streamSalt,
|
||||
isAudioOnly: fetchInfo["isAudioOnly"] ? fetchInfo["isAudioOnly"] : false,
|
||||
time: r.time,
|
||||
@@ -75,8 +75,8 @@ export default async function (host, patternMatch, url, ip, lang, format, qualit
|
||||
id: patternMatch["id"],
|
||||
title: patternMatch["title"], lang: lang,
|
||||
});
|
||||
return (!r.error) ? apiJSON(2, {
|
||||
type: "render", urls: r.urls,
|
||||
return (!r.error) ? apiJSON(r.typeId, {
|
||||
type: r.type, u: r.urls,
|
||||
service: host, ip: ip,
|
||||
filename: r.filename, salt: process.env.streamSalt
|
||||
}) : apiJSON(0, { t: r.error });
|
||||
|
||||
@@ -193,7 +193,7 @@ export default function(obj) {
|
||||
</div>
|
||||
</footer>
|
||||
</body>
|
||||
<script type="text/javascript">const loc = {noInternet:"${loc(obj.lang, 'apiError', 'noInternet')}"}</script>
|
||||
<script type="text/javascript">const loc = {noInternet:"${loc(obj.lang, 'apiError', 'noInternet')}", noURLReturned: "${loc(obj.lang, 'apiError', 'errorFetch')}"}</script>
|
||||
<script type="text/javascript" src="cobalt.js"></script>
|
||||
</html>`;
|
||||
} catch (err) {
|
||||
|
||||
@@ -7,7 +7,18 @@ export default async function(obj) {
|
||||
let req = await got.get(`https://www.reddit.com/r/${obj.sub}/comments/${obj.id}/${obj.name}.json`, { headers: { "user-agent": genericUserAgent } });
|
||||
let data = (JSON.parse(req.body))[0]["data"]["children"][0]["data"];
|
||||
if ("reddit_video" in data["secure_media"] && data["secure_media"]["reddit_video"]["duration"] * 1000 < maxVideoDuration) {
|
||||
return { urls: [data["secure_media"]["reddit_video"]["fallback_url"].split('?')[0], `${data["secure_media"]["reddit_video"]["fallback_url"].split('_')[0]}_audio.mp4`], filename: `reddit_${data["secure_media"]["reddit_video"]["fallback_url"].split('/')[3]}.mp4` };
|
||||
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`;
|
||||
try {
|
||||
await got.head(audio, { headers: { "user-agent": genericUserAgent } });
|
||||
} catch (err) {
|
||||
audio = ''
|
||||
}
|
||||
if (audio.length > 0) {
|
||||
return { typeId: 2, type: "render", urls: [video, audio], filename: `reddit_${data["secure_media"]["reddit_video"]["fallback_url"].split('/')[3]}.mp4` };
|
||||
} else {
|
||||
return { typeId: 1, urls: video};
|
||||
}
|
||||
} else {
|
||||
return { error: loc(obj.lang, 'apiError', 'nothingToDownload') };
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ export function createStream(obj) {
|
||||
id: streamUUID,
|
||||
service: obj.service,
|
||||
type: obj.type,
|
||||
urls: obj.urls,
|
||||
urls: obj.u,
|
||||
filename: obj.filename,
|
||||
hmac: ghmac,
|
||||
ip: iphmac,
|
||||
|
||||
@@ -42,7 +42,8 @@ export async function streamLiveRender(streamInfo, res) {
|
||||
'-map', '1:a',
|
||||
];
|
||||
args = args.concat(ffmpegArgs[format])
|
||||
args.push('-t', msToTime(streamInfo.time), '-f', format, 'pipe:5');
|
||||
if (streamInfo.time) args.push('-t', msToTime(streamInfo.time));
|
||||
args.push('-f', format, 'pipe:5');
|
||||
const ffmpegProcess = spawn(ffmpeg, args, {
|
||||
windowsHide: true,
|
||||
stdio: [
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { createStream } from "../stream/manage.js";
|
||||
import { execSync } from "child_process";
|
||||
|
||||
export function apiJSON(type, obj) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user