@sockethub/platform-metadata 1.0.1-beta.0 → 1.0.1-beta.2
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 +37 -5
- package/dist/event.d.ts +17 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.js +305 -3588
- package/dist/index.js.map +8 -20
- package/dist/resolvers.d.ts +26 -20
- package/dist/schema.d.ts +25 -0
- package/package.json +5 -5
package/dist/resolvers.d.ts
CHANGED
|
@@ -1,21 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* Site-specific URL resolution for pages that don't serve useful Open Graph
|
|
3
|
-
* data to scrapers.
|
|
4
|
-
*
|
|
5
|
-
* Some large platforms return a generic banner image (X/Twitter), serve
|
|
6
|
-
* their Open Graph data only to recognized embed crawlers (Reddit), or
|
|
7
|
-
* hide post media behind a login (Facebook):
|
|
8
|
-
*
|
|
9
|
-
* - X/Twitter → FxTwitter's JSON API (api.fxtwitter.com), built for embed
|
|
10
|
-
* previews, returns the tweet text plus direct photo/video URLs.
|
|
11
|
-
* - Reddit → the regular scrape works, but only when presented with an
|
|
12
|
-
* embed-crawler user agent (see COMPAT_USER_AGENT in index.ts).
|
|
13
|
-
* - Facebook → same crawler-UA gating as Reddit, plus its video titles
|
|
14
|
-
* arrive polluted with localized engagement stats that need stripping.
|
|
15
|
-
*
|
|
16
|
-
* These are pure URL matchers/mappers — the platform decides what to do
|
|
17
|
-
* with the resolution (call a JSON API vs. pick a scrape user agent).
|
|
18
|
-
*/
|
|
1
|
+
import type { PageEvent } from "./event";
|
|
19
2
|
/**
|
|
20
3
|
* Match an X/Twitter status URL and return the FxTwitter API URL for it,
|
|
21
4
|
* or null when the URL isn't a status page (profiles, search, home feed —
|
|
@@ -56,10 +39,32 @@ export declare function isFacebookUrl(url: string): boolean;
|
|
|
56
39
|
* Remove the engagement-stats segment Facebook prepends to video titles:
|
|
57
40
|
* "2.2M views · 21K reactions | <video title> | <author>". The stats are
|
|
58
41
|
* localized to the *scraping server's* geo-IP language, so match their
|
|
59
|
-
* shape
|
|
60
|
-
*
|
|
42
|
+
* shape rather than any particular wording: a leading pipe-delimited
|
|
43
|
+
* segment that either contains a digit and the "·" separator, or — when
|
|
44
|
+
* Facebook reports a single count, e.g. "330.213 Aufrufe | Reel by X",
|
|
45
|
+
* "347K views | …" or "2,2 mil. zhlédnutí | …" — is a count-shaped number
|
|
46
|
+
* (grouping or decimal separator, magnitude suffix, or at least four
|
|
47
|
+
* digits), an optional abbreviation, and one word. The view label itself
|
|
48
|
+
* cannot be matched: it is whatever Facebook's geo-IP locale produces. The
|
|
49
|
+
* count shape keeps a caption that merely starts with a small number
|
|
50
|
+
* ("10 Goals | Author") intact; only counts below 1,000 with no suffix
|
|
51
|
+
* would leak into the title.
|
|
61
52
|
*/
|
|
62
53
|
export declare function stripFacebookEngagement(title: string | undefined): string | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* Facebook's public embed plugin for a post. Unlike the post page, it is
|
|
56
|
+
* meant to be rendered by third-party sites, so it still carries the
|
|
57
|
+
* media thumbnail when the post page withholds its Open Graph image from
|
|
58
|
+
* an unrecognized or datacenter client. Video posts (reels, watch) use
|
|
59
|
+
* the video plugin; everything else the post plugin.
|
|
60
|
+
*/
|
|
61
|
+
export declare function resolveFacebookEmbed(url: string, ogType: string | undefined): string | null;
|
|
62
|
+
/**
|
|
63
|
+
* The media thumbnail from a Facebook embed-plugin page: the first `<img>`
|
|
64
|
+
* served from Facebook's CDN. The plugin renders the post media before
|
|
65
|
+
* the author avatar, so the first CDN image is the thumbnail.
|
|
66
|
+
*/
|
|
67
|
+
export declare function extractFacebookEmbedImage(html: string): string | undefined;
|
|
63
68
|
/**
|
|
64
69
|
* True for Reddit URLs (including redd.it short links). Reddit serves its
|
|
65
70
|
* Open Graph tags — with the post's real preview image — only to
|
|
@@ -199,6 +204,7 @@ export interface PageObject {
|
|
|
199
204
|
url?: string;
|
|
200
205
|
favicon?: string;
|
|
201
206
|
charset?: string;
|
|
207
|
+
event?: PageEvent;
|
|
202
208
|
}
|
|
203
209
|
/**
|
|
204
210
|
* Map an FxTwitter API response onto the platform's page object. The
|
package/dist/schema.d.ts
CHANGED
|
@@ -107,6 +107,31 @@ export declare const PlatformMetadataSchema: {
|
|
|
107
107
|
charset: {
|
|
108
108
|
type: string;
|
|
109
109
|
};
|
|
110
|
+
event: {
|
|
111
|
+
type: string;
|
|
112
|
+
required: string[];
|
|
113
|
+
additionalProperties: boolean;
|
|
114
|
+
properties: {
|
|
115
|
+
name: {
|
|
116
|
+
type: string;
|
|
117
|
+
};
|
|
118
|
+
startDate: {
|
|
119
|
+
type: string;
|
|
120
|
+
};
|
|
121
|
+
endDate: {
|
|
122
|
+
type: string;
|
|
123
|
+
};
|
|
124
|
+
location: {
|
|
125
|
+
type: string;
|
|
126
|
+
};
|
|
127
|
+
url: {
|
|
128
|
+
type: string;
|
|
129
|
+
};
|
|
130
|
+
status: {
|
|
131
|
+
enum: string[];
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
};
|
|
110
135
|
};
|
|
111
136
|
};
|
|
112
137
|
ogImage: {
|
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.2",
|
|
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.2",
|
|
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.2"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"@sockethub/server": "^5.0.0-beta.
|
|
53
|
+
"@sockethub/server": "^5.0.0-beta.2"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "d241420f9743f66a15ed083a1390595b331a96ac",
|
|
56
56
|
"types": "./dist/index.d.ts"
|
|
57
57
|
}
|