mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-03-07 12:00:01 +03:00
Merge pull request #1039 from Tzahi12345/video-info-bug-fix
Video info bug fix
This commit is contained in:
@@ -590,17 +590,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() {
|
||||
@@ -1871,11 +1860,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);
|
||||
|
||||
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) {
|
||||
|
||||
@@ -460,7 +460,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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user