@sockethub/platform-metadata 1.0.1-beta.3 → 1.0.1-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -1
- package/dist/index.js +129 -18
- package/dist/index.js.map +4 -4
- package/dist/resolvers.d.ts +63 -10
- package/package.json +5 -5
package/dist/resolvers.d.ts
CHANGED
|
@@ -35,6 +35,31 @@ export declare function extractYouTubeDescription(html: string): string | undefi
|
|
|
35
35
|
* with COMPAT_USER_AGENT (see index.ts), like Reddit.
|
|
36
36
|
*/
|
|
37
37
|
export declare function isFacebookUrl(url: string): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* True for Amazon storefront URLs and their short links. Amazon answers
|
|
40
|
+
* unrecognized scrapers (our own UA, and the Discordbot compat UA) with a
|
|
41
|
+
* captcha page or a generic "Amazon" share card; it serves the product's
|
|
42
|
+
* Open Graph title and image to WhatsApp's link-preview crawler.
|
|
43
|
+
*/
|
|
44
|
+
export declare function isAmazonUrl(url: string): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Amazon's mobile-app share links (`/gp/aw/d/<ASIN>`) get a generic "Amazon"
|
|
47
|
+
* card even for WhatsApp's crawler, while `/dp/<ASIN>` on the same host gets
|
|
48
|
+
* the product. Returns the `/dp/` URL, or null for any other URL.
|
|
49
|
+
*/
|
|
50
|
+
export declare function resolveAmazonAppLink(url: string): string | null;
|
|
51
|
+
/**
|
|
52
|
+
* Product image from an Amazon desktop product page. Amazon randomly serves
|
|
53
|
+
* the crawler that page (no product Open Graph tags, only its logo) instead
|
|
54
|
+
* of the share-card one; the main image is still in `#landingImage`.
|
|
55
|
+
*/
|
|
56
|
+
export declare function extractAmazonImage(html: string | undefined): string | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* Summary from schema.org JSON-LD for pages without a meta description: a
|
|
59
|
+
* `description`, else a `headline` that isn't just the page title (Wikipedia
|
|
60
|
+
* puts its short description there, e.g. "1979 studio album by Brian Eno").
|
|
61
|
+
*/
|
|
62
|
+
export declare function schemaOrgSummary(jsonLD: unknown, title?: string): string | undefined;
|
|
38
63
|
/**
|
|
39
64
|
* Remove the engagement-stats segment Facebook prepends to video titles:
|
|
40
65
|
* "2.2M views · 21K reactions | <video title> | <author>". The stats are
|
|
@@ -105,6 +130,20 @@ export interface RedditPost {
|
|
|
105
130
|
};
|
|
106
131
|
}>;
|
|
107
132
|
};
|
|
133
|
+
/** Gallery posts carry no `preview`; their images live here instead. */
|
|
134
|
+
gallery_data?: {
|
|
135
|
+
items?: Array<{
|
|
136
|
+
media_id?: string;
|
|
137
|
+
}>;
|
|
138
|
+
};
|
|
139
|
+
media_metadata?: Record<string, {
|
|
140
|
+
s?: {
|
|
141
|
+
u?: string;
|
|
142
|
+
gif?: string;
|
|
143
|
+
x?: number;
|
|
144
|
+
y?: number;
|
|
145
|
+
};
|
|
146
|
+
}>;
|
|
108
147
|
}
|
|
109
148
|
/** Validate and extract the post object from Reddit's listing response. */
|
|
110
149
|
export declare function parseRedditPost(value: unknown): RedditPost | null;
|
|
@@ -137,6 +176,21 @@ export declare function redditPostImages(images: PageObject["image"]): PageObjec
|
|
|
137
176
|
* excessive vertical whitespace at one blank line.
|
|
138
177
|
*/
|
|
139
178
|
export declare function normalizeDescription(value: string): string;
|
|
179
|
+
/** Media attached to an FxTwitter status (or to the status it quotes). */
|
|
180
|
+
interface FxTwitterMedia {
|
|
181
|
+
photos?: Array<{
|
|
182
|
+
url?: string;
|
|
183
|
+
width?: number;
|
|
184
|
+
height?: number;
|
|
185
|
+
}>;
|
|
186
|
+
videos?: Array<{
|
|
187
|
+
url?: string;
|
|
188
|
+
thumbnail_url?: string;
|
|
189
|
+
width?: number;
|
|
190
|
+
height?: number;
|
|
191
|
+
duration?: number;
|
|
192
|
+
}>;
|
|
193
|
+
}
|
|
140
194
|
/** Subset of the FxTwitter status API response the platform consumes. */
|
|
141
195
|
export interface FxTwitterStatus {
|
|
142
196
|
code: number;
|
|
@@ -147,21 +201,19 @@ export interface FxTwitterStatus {
|
|
|
147
201
|
author?: {
|
|
148
202
|
name?: string;
|
|
149
203
|
screen_name?: string;
|
|
204
|
+
avatar_url?: string;
|
|
150
205
|
};
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
url?: string;
|
|
154
|
-
width?: number;
|
|
155
|
-
height?: number;
|
|
156
|
-
}>;
|
|
157
|
-
videos?: Array<{
|
|
206
|
+
card?: {
|
|
207
|
+
image?: {
|
|
158
208
|
url?: string;
|
|
159
|
-
thumbnail_url?: string;
|
|
160
209
|
width?: number;
|
|
161
210
|
height?: number;
|
|
162
|
-
|
|
163
|
-
|
|
211
|
+
};
|
|
212
|
+
};
|
|
213
|
+
quote?: {
|
|
214
|
+
media?: FxTwitterMedia;
|
|
164
215
|
};
|
|
216
|
+
media?: FxTwitterMedia;
|
|
165
217
|
article?: {
|
|
166
218
|
title?: string;
|
|
167
219
|
preview_text?: string;
|
|
@@ -213,3 +265,4 @@ export interface PageObject {
|
|
|
213
265
|
* reports anything but success (the caller falls back to the OG scrape).
|
|
214
266
|
*/
|
|
215
267
|
export declare function tweetToPageObject(status: FxTwitterStatus): PageObject | null;
|
|
268
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sockethub/platform-metadata",
|
|
3
|
-
"version": "1.0.1-beta.
|
|
3
|
+
"version": "1.0.1-beta.5",
|
|
4
4
|
"description": "Fetch metadata from a given URL",
|
|
5
5
|
"author": "Nick Jennings <nick@silverbucket.net>",
|
|
6
6
|
"license": "LGPL-3.0+",
|
|
@@ -42,16 +42,16 @@
|
|
|
42
42
|
"clean:deps": "rm -rf node_modules"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@sockethub/util": "^1.0.0-beta.
|
|
45
|
+
"@sockethub/util": "^1.0.0-beta.5",
|
|
46
46
|
"open-graph-scraper": "^6.11.0",
|
|
47
47
|
"undici": "^7.30.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@sockethub/schemas": "^3.0.0-beta.
|
|
50
|
+
"@sockethub/schemas": "^3.0.0-beta.5"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"@sockethub/server": "^5.0.0-beta.
|
|
53
|
+
"@sockethub/server": "^5.0.0-beta.5"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "2dffe4cc1bea5375e38531b1012b56bcbab93569",
|
|
56
56
|
"types": "./dist/index.d.ts"
|
|
57
57
|
}
|