Merge pull request #1039 from Tzahi12345/video-info-bug-fix

Video info bug fix
pull/1041/head
Tzahi12345 1 year ago committed by GitHub
commit 0644b194d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -590,17 +590,6 @@ function generateEnvVarConfigItem(key) {
return {key: key, value: process['env'][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 // youtube-dl functions
async function startYoutubeDL() { async function startYoutubeDL() {
@ -1871,11 +1860,11 @@ app.post('/api/clearAllLogs', optionalJwt, async function(req, res) {
}); });
app.post('/api/getFileFormats', optionalJwt, async (req, res) => { app.post('/api/getFileFormats', optionalJwt, async (req, res) => {
let url = req.body.url; const url = req.body.url;
let result = await getUrlInfos(url); const result = await downloader_api.getVideoInfoByURL(url);
res.send({ res.send({
result: result, result: result && result.length === 1 ? result[0] : null,
success: !!result 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 download_url = `${exports.youtubedl_forks[youtubedl_fork]['download_url']}${file_ext}`;
const output_path = custom_output_path || getYoutubeDLPath(youtubedl_fork); const output_path = custom_output_path || getYoutubeDLPath(youtubedl_fork);
await utils.fetchFile(download_url, output_path, `${youtubedl_fork} ${new_version}`); try {
fs.chmod(output_path, 0o777); await utils.fetchFile(download_url, output_path, `${youtubedl_fork} ${new_version}`);
fs.chmod(output_path, 0o777);
updateDetailsJSON(new_version, youtubedl_fork, output_path);
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) => { exports.getLatestUpdateVersion = async (youtubedl_fork) => {

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

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

Loading…
Cancel
Save