Skip to content

Commit

Permalink
fix: Actualiser le scraper de The Guardian.
Browse files Browse the repository at this point in the history
  • Loading branch information
regseb committed Oct 20, 2024
1 parent 800d01b commit 2f5c88b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 2 additions & 4 deletions src/core/scraper/theguardian.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,14 @@ const actionVideo = async function (_url, metadata, context) {

const doc = await metadata.html();
const div = doc.querySelector(
'div[data-testid^="youtube-sticky-"][data-testid$="-server"]',
'div[data-component="youtube-atom"][data-video-id]',
);
if (null === div) {
return undefined;
}

return await metaExtract(
new URL(
`https://www.youtube.com/embed/${div.dataset.testid.slice(15, -7)}`,
),
new URL(`https://www.youtube.com/embed/${div.dataset.videoId}`),
{ ...context, depth: true },
);
};
Expand Down
6 changes: 4 additions & 2 deletions test/unit/core/scraper/theguardian.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ describe("core/scraper/theguardian.js", function () {
Promise.resolve(
new DOMParser().parseFromString(
`<html><body>
<div data-testid="youtube-sticky-bar-server" />
<div data-component="youtube-atom"
data-video-id="bar" />
</body></html>`,
"text/html",
),
Expand Down Expand Up @@ -84,7 +85,8 @@ describe("core/scraper/theguardian.js", function () {
Promise.resolve(
new DOMParser().parseFromString(
`<html><body>
<div data-testid="youtube-sticky-bar-server" />
<div data-component="youtube-atom"
data-video-id="bar" />
</body></html>`,
"text/html",
),
Expand Down

0 comments on commit 2f5c88b

Please sign in to comment.