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:
@@ -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') };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user