Skip to content
This repository was archived by the owner on Aug 15, 2023. It is now read-only.

Commit 191bd66

Browse files
committed
fix(yt:backend): error reporting for home videos parsing failure
1 parent a27487c commit 191bd66

File tree

1 file changed

+14
-5
lines changed
  • platforms/yttrex/shared/src/parser/parsers

1 file changed

+14
-5
lines changed

Diff for: platforms/yttrex/shared/src/parser/parsers/home.ts

+14-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { trexLogger } from '@shared/logger';
22
import { ParserFn } from '@shared/providers/parser.provider';
3-
import { HomeMetadata, ParsedInfo } from '../../models/Metadata';
43
import _ from 'lodash';
54
import moment from 'moment';
6-
import { HTMLSource } from '../source';
5+
import { HomeMetadata, ParsedInfo } from '../../models/Metadata';
76
import { YTParserConfig } from '../config';
7+
import { HTMLSource } from '../source';
88
import * as longlabel from './longlabel';
99
import * as shared from './shared';
1010
import uxlang from './uxlang';
@@ -277,7 +277,8 @@ interface SelectedAndSections {
277277

278278
function getSelectedAndSections(
279279
D: Document,
280-
clientTime: Date
280+
clientTime: Date,
281+
config: YTParserConfig
281282
): SelectedAndSections {
282283
/* selection findings */
283284
const sectionsWithTitle = _.compact(
@@ -325,6 +326,7 @@ function getSelectedAndSections(
325326
}
326327
throw new Error('No video Info');
327328
} catch (error) {
329+
config.errorReporter?.(error);
328330
homeLog.debug('Error during video dissect %O', error);
329331
const f = e.querySelector('#video-title-link');
330332
const s = f ? f.getAttribute('aria-label') : null;
@@ -364,7 +366,7 @@ export const processHome: ParserFn<
364366
HTMLSource,
365367
Omit<HomeMetadata, 'id'>,
366368
YTParserConfig
367-
> = async (envelop) => {
369+
> = async (envelop, findings, config) => {
368370
const retval: Omit<HomeMetadata, 'id'> = {
369371
type: 'home',
370372
clientTime: envelop.html.clientTime,
@@ -380,11 +382,18 @@ export const processHome: ParserFn<
380382
try {
381383
const { selected, sections } = getSelectedAndSections(
382384
envelop.jsdom,
383-
envelop.html.clientTime
385+
envelop.html.clientTime,
386+
{
387+
...config,
388+
errorReporter: () => {
389+
config.errorReporter?.(envelop);
390+
},
391+
}
384392
);
385393
retval.selected = selected;
386394
retval.sections = sections;
387395
} catch (e) {
396+
config.errorReporter?.(envelop);
388397
homeLog.error('Error in processing %s: %s', envelop.html.href, e.message);
389398
return null;
390399
}

0 commit comments

Comments
 (0)