Skip to content

Commit

Permalink
fix(route): Fix bloomberg story when parsing react rendered page and …
Browse files Browse the repository at this point in the history
…videos missing id (DIYgod#13082)

* fix minor bugs

* fix page sel

* reformat

* wordaround to fix the deepscan error

* fix bloomberg when dealing with 404 direct link

* fix processVideo in cyclic depend

* remove the toggle

* change into new story api

* reorg the files

* use prop not instead of lodash

* remove useless exports

* use parseVideo in diff files

* refactor to remove deps

* add try/catch for renderer page

* use story api for newsletters

* update features example

* change audio

* add tabularData

* fix bug on bloomberg react page

---------

Co-authored-by: Chenfei Xu <chenfxu@ebay.com>
  • Loading branch information
bigfei and Chenfei Xu authored Aug 20, 2023
1 parent f5f3149 commit e62b65d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/v2/bloomberg/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const got = require('@/utils/got');
const { art } = require('@/utils/render');

const rootUrl = 'https://www.bloomberg.com/feeds';
const idSel = 'script[id^="article-info"][type="application/json"], script[class^="article-info"][type="application/json"]';
const idSel = 'script[id^="article-info"][type="application/json"], script[class^="article-info"][type="application/json"], script#dvz-config';
const idUrl = 'https://www.bloomberg.com/article/api/story/id/';

const headers = {
Expand Down Expand Up @@ -45,7 +45,7 @@ const apiEndpoints = {
// https://www.bloomberg.com/features/2023-stradivarius-murders/
url: 'https://www.bloomberg.com/features/',
sel: idSel,
props: 'id',
prop: 'id',
},
};

Expand Down Expand Up @@ -508,8 +508,10 @@ const nodeRenderers = {
if (t === 'video') {
const h = node.data;
const id = h.attachment?.id;
const desc = await processVideo(id, h.attachment?.title);
return art(path.join(__dirname, 'templates/video_media.art'), desc);
if (id) {
const desc = await processVideo(id, h.attachment?.title);
return art(path.join(__dirname, 'templates/video_media.art'), desc);
}
}
if (t === 'audio' && node.data.attachment) {
const B = node.data.attachment;
Expand Down

0 comments on commit e62b65d

Please sign in to comment.