Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added support for content_loc, uploader info, error handler in sitema… #350

Merged
merged 1 commit into from
Feb 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 6.4.0

- added support for content_loc parsing #347 and uploader info attr
- added error handler option to sitemapstream #349 Thanks @marcoreni

## 6.3.6

- bump dependencies
Expand Down
8 changes: 7 additions & 1 deletion lib/sitemap-item-stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,13 @@ export class SitemapItemStream extends Transform {
}

if (video.uploader) {
this.push(element(TagNames['video:uploader'], video.uploader));
this.push(
element(
TagNames['video:uploader'],
attrBuilder(video, 'uploader:info'),
video.uploader
)
);
}

if (video.platform) {
Expand Down
10 changes: 10 additions & 0 deletions lib/sitemap-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ export class XMLToSitemapItemStream extends Transform {
case TagNames['video:player_loc']:
currentVideo.player_loc = text;
break;
case TagNames['video:content_loc']:
currentVideo.content_loc = text;
break;
case TagNames['video:requires_subscription']:
if (isValidYesNo(text)) {
currentVideo.requires_subscription = text;
Expand Down Expand Up @@ -410,6 +413,13 @@ export class XMLToSitemapItemStream extends Transform {
);
}
break;
case TagNames['video:uploader']:
if (attr.name === 'info') {
currentVideo['uploader:info'] = attr.value;
} else {
this.logger('log', 'unhandled attr for video:uploader', attr.name);
}
break;
default:
this.logger('log', 'unhandled attr', currentTag, attr.name);
}
Expand Down
6 changes: 6 additions & 0 deletions lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,12 @@ interface VideoItemBase {
*/
'restriction:relationship'?: EnumAllowDeny;
gallery_loc?: string;
/**
* [Optional] Specifies the URL of a webpage with additional information about this uploader. This URL must be in the same domain as the <loc> tag.
* @see https://developers.google.com/search/docs/advanced/sitemaps/video-sitemaps
* @example http://www.example.com/users/grillymcgrillerson
*/
'uploader:info'?: string;
'gallery_loc:title'?: string;
/**
* The price to download or view the video. Omit this tag for free videos.
Expand Down
552 changes: 308 additions & 244 deletions package-lock.json

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sitemap",
"version": "6.3.6",
"version": "6.4.0",
"description": "Sitemap-generating lib/cli",
"keywords": [
"sitemap",
Expand Down Expand Up @@ -155,28 +155,28 @@
}
},
"dependencies": {
"@types/node": "^14.14.25",
"@types/node": "^14.14.28",
"@types/sax": "^1.2.1",
"arg": "^5.0.0",
"sax": "^1.2.4"
},
"devDependencies": {
"@babel/core": "^7.12.13",
"@babel/core": "^7.12.16",
"@babel/plugin-proposal-class-properties": "^7.12.13",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.12.13",
"@babel/plugin-proposal-optional-chaining": "^7.12.13",
"@babel/plugin-transform-typescript": "^7.12.13",
"@babel/preset-env": "^7.12.13",
"@babel/preset-typescript": "^7.12.13",
"@babel/plugin-proposal-optional-chaining": "^7.12.16",
"@babel/plugin-transform-typescript": "^7.12.16",
"@babel/preset-env": "^7.12.16",
"@babel/preset-typescript": "^7.12.16",
"@types/jest": "^26.0.20",
"@typescript-eslint/eslint-plugin": "^4.15.0",
"@typescript-eslint/parser": "^4.15.0",
"@typescript-eslint/eslint-plugin": "^4.15.1",
"@typescript-eslint/parser": "^4.15.1",
"babel-eslint": "^10.1.0",
"babel-polyfill": "^6.26.0",
"concurrently": "^5.3.0",
"eslint": "^7.19.0",
"eslint": "^7.20.0",
"eslint-config-prettier": "^7.2.0",
"eslint-plugin-jest": "^24.1.3",
"eslint-plugin-jest": "^24.1.5",
"eslint-plugin-prettier": "^3.3.1",
"express": "^4.17.1",
"husky": "^4.3.8",
Expand Down
4 changes: 2 additions & 2 deletions tests/mocks/alltags.cdata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<video:gallery_loc title="awhu series page&amp;>&lt;'&quot;">https://roosterteeth.com/series/awhu&amp;&gt;&lt;'"</video:gallery_loc>
<video:price resolution="HD" currency="USD" type="rent">1.99</video:price>
<video:requires_subscription>no</video:requires_subscription>
<video:uploader>GrillyMcGrillerson&amp;&gt;&lt;'"</video:uploader>
<video:uploader info="http://www.example.com/users/grillymcgrillerson">GrillyMcGrillerson&amp;&gt;&lt;'"</video:uploader>
<video:platform relationship="allow">tv</video:platform>
<video:live>no</video:live>
</video:video>
Expand All @@ -62,7 +62,7 @@
<video:description>
<![CDATA[Achievement Hunter's House Party quest for some one-night intimacy continues. Can they use Ashley and Madison's sibling rivalry for their own dubious gains?&><'"]]>
</video:description>
<video:player_loc>https://roosterteeth.com/embed/let-s-watch-2018-house-party-part-2&amp;&gt;&lt;'"</video:player_loc>
<video:content_loc>http://streamserver.example.com/video123.mp4</video:content_loc>
<video:duration>2422</video:duration>
<video:publication_date>2018-04-26T17:00:00.000Z</video:publication_date>
<video:requires_subscription>no</video:requires_subscription>
Expand Down
5 changes: 3 additions & 2 deletions tests/mocks/alltags.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<video:gallery_loc title="awhu series page&amp;>&lt;'&quot;">https://roosterteeth.com/series/awhu&amp;&gt;&lt;'"</video:gallery_loc>
<video:price resolution="HD" currency="USD" type="rent">1.99</video:price>
<video:requires_subscription>no</video:requires_subscription>
<video:uploader>GrillyMcGrillerson&amp;&gt;&lt;'"</video:uploader>
<video:uploader info="http://www.example.com/users/grillymcgrillerson">GrillyMcGrillerson&amp;&gt;&lt;'"</video:uploader>
<video:platform relationship="allow">tv</video:platform>
<video:live>no</video:live>
</video:video>
Expand All @@ -50,7 +50,8 @@
<video:thumbnail_loc>https://rtv3-img-roosterteeth.akamaized.net/store/9dd9681a-0557-45fe-86b3-b662c91bbae7.jpg/sm/thumblwhouseparty2v4.jpg&amp;&gt;&lt;'"</video:thumbnail_loc>
<video:title>2018:E10 - House Party - Part 2 (Uncensored)&amp;&gt;&lt;'"</video:title>
<video:description>Achievement Hunter's House Party quest for some one-night intimacy continues. Can they use Ashley and Madison's sibling rivalry for their own dubious gains?&amp;&gt;&lt;'"</video:description>
<video:player_loc>https://roosterteeth.com/embed/let-s-watch-2018-house-party-part-2&amp;&gt;&lt;'"</video:player_loc>
<video:content_loc>
http://streamserver.example.com/video123.mp4</video:content_loc>
<video:duration>2422</video:duration>
<video:publication_date>2018-04-26T17:00:00.000Z</video:publication_date>
<video:requires_subscription>no</video:requires_subscription>
Expand Down
4 changes: 2 additions & 2 deletions tests/mocks/bad-tag-sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<video:gallery_loc title="awhu series page&amp;>&lt;'&quot;">https://roosterteeth.com/series/awhu&amp;&gt;&lt;'"</video:gallery_loc>
<video:price resolution="HD" currency="USD" type="rent">1.99</video:price>
<video:requires_subscription>no</video:requires_subscription>
<video:uploader>GrillyMcGrillerson&amp;&gt;&lt;'"</video:uploader>
<video:uploader info="http://www.example.com/users/grillymcgrillerson">GrillyMcGrillerson&amp;&gt;&lt;'"</video:uploader>
<video:platform relationship="allow">tv</video:platform>
<video:live>no</video:live>
</video:video>
Expand All @@ -53,7 +53,7 @@
<video:thumbnail_loc>https://rtv3-img-roosterteeth.akamaized.net/store/9dd9681a-0557-45fe-86b3-b662c91bbae7.jpg/sm/thumblwhouseparty2v4.jpg&amp;&gt;&lt;'"</video:thumbnail_loc>
<video:title>2018:E10 - House Party - Part 2 (Uncensored)&amp;&gt;&lt;'"</video:title>
<video:description>Achievement Hunter's House Party quest for some one-night intimacy continues. Can they use Ashley and Madison's sibling rivalry for their own dubious gains?&amp;&gt;&lt;'"</video:description>
<video:player_loc>https://roosterteeth.com/embed/let-s-watch-2018-house-party-part-2&amp;&gt;&lt;'"</video:player_loc>
<video:content_loc>http://streamserver.example.com/video123.mp4</video:content_loc>
<video:duration>2422</video:duration>
<video:publication_date>2018-04-26T17:00:00.000Z</video:publication_date>
<video:requires_subscription>no</video:requires_subscription>
Expand Down
Loading