Add more output to debug.txt

This commit is contained in:
Godzil 2018-07-19 23:08:51 +01:00
parent 04b22fdce5
commit 817843c40c
3 changed files with 36 additions and 2 deletions

View File

@ -77,7 +77,11 @@ export default function(args: string[], done: (err?: Error) => void)
{ {
if (tasksArr[i].retry <= 0) if (tasksArr[i].retry <= 0)
{ {
console.error(errin); log.error(errin.stack || errin);
if (config.debug)
{
log.dumpToDebug('BatchGiveUp', errin.stack || errin);
}
log.error('Cannot get episodes from "' + tasksArr[i].address + '", please rerun later'); log.error('Cannot get episodes from "' + tasksArr[i].address + '", please rerun later');
/* Go to the next on the list */ /* Go to the next on the list */
i += 1; i += 1;
@ -86,7 +90,11 @@ export default function(args: string[], done: (err?: Error) => void)
{ {
if (config.verbose) if (config.verbose)
{ {
console.error(errin); log.error(errin);
}
if (config.debug)
{
log.dumpToDebug('BatchRetry', errin.stack || errin);
} }
log.warn('Retrying to fetch episodes list from' + tasksArr[i].retry + ' / ' + config.retry); log.warn('Retrying to fetch episodes list from' + tasksArr[i].retry + ' / ' + config.retry);
tasksArr[i].retry -= 1; tasksArr[i].retry -= 1;

View File

@ -277,10 +277,21 @@ function scrapePage(config: IConfig, address: string, done: (err: Error, page?:
const episodeTitle = $('#showmedia_about_name').text().replace(/[“”]/g, ''); const episodeTitle = $('#showmedia_about_name').text().replace(/[“”]/g, '');
const data = regexp.exec(look); const data = regexp.exec(look);
if (config.debug)
{
log.dumpToDebug('episode page', $.html());
}
if (!swf || !data) if (!swf || !data)
{ {
log.warn('Somethig unexpected in the page at ' + address + ' (data are: ' + look + ')'); log.warn('Somethig unexpected in the page at ' + address + ' (data are: ' + look + ')');
log.warn('Setting Season to 0 and episode to 0...'); log.warn('Setting Season to 0 and episode to 0...');
if (config.debug)
{
log.dumpToDebug('episode unexpected', look);
}
done(null, { done(null, {
episode: '0', episode: '0',
id: epId, id: epId,
@ -367,6 +378,11 @@ function scrapePlayer(config: IConfig, address: string, id: number, done: (err:
}); });
} catch (parseError) } catch (parseError)
{ {
if (config.debug)
{
log.dumpToDebug('player scrape', parseError);
}
done(parseError); done(parseError);
} }
}); });

View File

@ -51,6 +51,11 @@ export default function(config: IConfig, address: string, done: (err: Error) =>
let i = 0; let i = 0;
(function next() (function next()
{ {
if (config.debug)
{
log.dumpToDebug('Episode ' + i, JSON.stringify(page.episodes[i]));
}
if (i >= page.episodes.length) return done(null); if (i >= page.episodes.length) return done(null);
download(cache, config, address, page.episodes[i], (errD, ignored) => download(cache, config, address, page.episodes[i], (errD, ignored) =>
{ {
@ -166,6 +171,11 @@ function page(config: IConfig, address: string, done: (err: Error, result?: ISer
const $ = cheerio.load(result); const $ = cheerio.load(result);
const title = $('span[itemprop=name]').text(); const title = $('span[itemprop=name]').text();
if (config.debug)
{
log.dumpToDebug('serie page', $.html());
}
if (!title) { if (!title) {
if (config.debug) if (config.debug)
{ {