mirror of
https://github.com/neosubhamoy/neodlp.git
synced 2026-03-22 12:35:49 +05:30
refactor: improved search logging
This commit is contained in:
@@ -47,7 +47,7 @@ export default function Navbar() {
|
|||||||
</Button>
|
</Button>
|
||||||
</DialogTrigger>
|
</DialogTrigger>
|
||||||
</TooltipTrigger>
|
</TooltipTrigger>
|
||||||
<TooltipContent>
|
<TooltipContent side="bottom">
|
||||||
<p>Logs</p>
|
<p>Logs</p>
|
||||||
</TooltipContent>
|
</TooltipContent>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
|||||||
@@ -103,7 +103,12 @@ export default function useDownloader() {
|
|||||||
const fetchVideoMetadata = async (params: FetchVideoMetadataParams): Promise<RawVideoInfo | null> => {
|
const fetchVideoMetadata = async (params: FetchVideoMetadataParams): Promise<RawVideoInfo | null> => {
|
||||||
const { url, formatId, playlistIndices, selectedSubtitles, resumeState, downloadConfig } = params;
|
const { url, formatId, playlistIndices, selectedSubtitles, resumeState, downloadConfig } = params;
|
||||||
try {
|
try {
|
||||||
const args = [url, '--dump-single-json', '--no-warnings'];
|
const args = [url, '--dump-single-json'];
|
||||||
|
if (DEBUG_MODE && LOG_VERBOSE) {
|
||||||
|
args.push('--verbose');
|
||||||
|
} else {
|
||||||
|
args.push('--no-warnings');
|
||||||
|
}
|
||||||
if (formatId) {
|
if (formatId) {
|
||||||
const isMultipleAudioFormatSelected = formatId.split('+').length > 2;
|
const isMultipleAudioFormatSelected = formatId.split('+').length > 2;
|
||||||
args.push('--format', formatId);
|
args.push('--format', formatId);
|
||||||
@@ -168,15 +173,25 @@ export default function useDownloader() {
|
|||||||
|
|
||||||
return new Promise<RawVideoInfo | null>((resolve) => {
|
return new Promise<RawVideoInfo | null>((resolve) => {
|
||||||
command.stdout.on('data', line => {
|
command.stdout.on('data', line => {
|
||||||
jsonOutput += line;
|
if (line.startsWith('{')) {
|
||||||
|
jsonOutput = line;
|
||||||
|
} else {
|
||||||
|
if (line.trim() !== '') LOG.info('YT-DLP', line);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
command.stderr.on('data', line => {
|
||||||
|
if (line.trim() !== '') LOG.info('YT-DLP', line);
|
||||||
});
|
});
|
||||||
|
|
||||||
command.on('close', async (data) => {
|
command.on('close', async (data) => {
|
||||||
if (data.code !== 0) {
|
if (data.code !== 0) {
|
||||||
console.error(`yt-dlp failed to fetch metadata with code ${data.code}`);
|
console.error(`yt-dlp exited with code ${data.code} while fetching metadata for URL: ${url}`);
|
||||||
LOG.error('NEODLP', `yt-dlp exited with code ${data.code} while fetching metadata for URL: ${url} (ignore if you manually cancelled)`);
|
LOG.error('NEODLP', `yt-dlp exited with code ${data.code} while fetching metadata for URL: ${url} (ignore if you manually cancelled)`);
|
||||||
resolve(null);
|
|
||||||
} else {
|
} else {
|
||||||
|
LOG.info('NEODLP', `yt-dlp exited with code ${data.code} while fetching metadata for URL: ${url}`);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const matchedJson = jsonOutput.match(/{.*}/);
|
const matchedJson = jsonOutput.match(/{.*}/);
|
||||||
if (!matchedJson) {
|
if (!matchedJson) {
|
||||||
@@ -193,7 +208,6 @@ export default function useDownloader() {
|
|||||||
LOG.error('NEODLP', `Failed to parse metadata JSON for URL: ${url}) with error: ${e}`);
|
LOG.error('NEODLP', `Failed to parse metadata JSON for URL: ${url}) with error: ${e}`);
|
||||||
resolve(null);
|
resolve(null);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
command.on('error', error => {
|
command.on('error', error => {
|
||||||
|
|||||||
Reference in New Issue
Block a user