Fixed issue where video info could not be retrieved

If youtube-dl update fails, error will show and server won't crash
pull/1039/head
Isaac Abadi 1 year ago
parent 6b59446a37
commit 344d959c05

@ -589,17 +589,6 @@ function generateEnvVarConfigItem(key) {
return {key: key, value: process['env'][key]};
}
// currently only works for single urls
async function getUrlInfos(url) {
const {parsed_output, err} = await youtubedl_api.runYoutubeDL(url, ['--dump-json']);
if (!parsed_output || parsed_output.length !== 1) {
logger.error(`Failed to retrieve available formats for url: ${url}`);
if (err) logger.error(err);
return null;
}
return parsed_output[0];
}
// youtube-dl functions
async function startYoutubeDL() {
@ -1870,11 +1859,11 @@ app.post('/api/clearAllLogs', optionalJwt, async function(req, res) {
});
app.post('/api/getFileFormats', optionalJwt, async (req, res) => {
let url = req.body.url;
let result = await getUrlInfos(url);
const url = req.body.url;
const result = await downloader_api.getVideoInfoByURL(url);
res.send({
result: result,
success: !!result
result: result && result.length === 1 ? result[0] : null,
success: result && result.length === 0
})
});

@ -118,10 +118,16 @@ async function downloadLatestYoutubeDLBinaryGeneric(youtubedl_fork, new_version,
const download_url = `${exports.youtubedl_forks[youtubedl_fork]['download_url']}${file_ext}`;
const output_path = custom_output_path || getYoutubeDLPath(youtubedl_fork);
await utils.fetchFile(download_url, output_path, `${youtubedl_fork} ${new_version}`);
fs.chmod(output_path, 0o777);
updateDetailsJSON(new_version, youtubedl_fork, output_path);
try {
await utils.fetchFile(download_url, output_path, `${youtubedl_fork} ${new_version}`);
fs.chmod(output_path, 0o777);
updateDetailsJSON(new_version, youtubedl_fork, output_path);
} catch (e) {
logger.error(`Failed to download new ${youtubedl_fork} version: ${new_version}`);
logger.error(e);
return;
}
}
exports.getLatestUpdateVersion = async (youtubedl_fork) => {

@ -548,7 +548,7 @@ export class MainComponent implements OnInit {
}
if (!(this.cachedAvailableFormats[url] && this.cachedAvailableFormats[url]['formats'])) {
this.cachedAvailableFormats[url]['formats_loading'] = true;
this.postsService.getFileFormats([url]).subscribe(res => {
this.postsService.getFileFormats(url).subscribe(res => {
this.cachedAvailableFormats[url]['formats_loading'] = false;
const infos = res['result'];
if (!infos || !infos.formats) {

@ -459,7 +459,7 @@ export class PostsService implements CanActivate {
return this.http.post<SuccessObject>(this.path + 'deleteArchiveItems', body, this.httpOptions);
}
getFileFormats(url) {
getFileFormats(url: string) {
const body: GetFileFormatsRequest = {url: url};
return this.http.post<GetFileFormatsResponse>(this.path + 'getFileFormats', body, this.httpOptions);
}

Loading…
Cancel
Save