@postfetch/core 0.4.2 → 0.5.1
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/dist/index.js +1 -4
- package/package.json +1 -1
- package/src/reddit.ts +3 -3
- package/src/tiktok.ts +2 -1
package/dist/index.js
CHANGED
|
@@ -1012,9 +1012,6 @@ async function resolveReddit(input) {
|
|
|
1012
1012
|
const token = await appToken(input.net);
|
|
1013
1013
|
const post = await fetchPost(input.net, token, id);
|
|
1014
1014
|
const items = await mediaItems3(input, post, id);
|
|
1015
|
-
if (items.length === 0) {
|
|
1016
|
-
throw new Error("Reddit media not found");
|
|
1017
|
-
}
|
|
1018
1015
|
return { archiveFilename: filename(`reddit_${id}.zip`), id, items, metadata: redditMetadata(post), platform: "reddit" };
|
|
1019
1016
|
}
|
|
1020
1017
|
function redditMetadata(post) {
|
|
@@ -1470,7 +1467,7 @@ async function followShortlink(net, userAgent, input) {
|
|
|
1470
1467
|
return href ? new URL(href.split("?")[0]).href : input;
|
|
1471
1468
|
}
|
|
1472
1469
|
function videoId(input) {
|
|
1473
|
-
return asUrl(input).pathname.match(/video\/(\d+)/)?.[1] ?? null;
|
|
1470
|
+
return asUrl(input).pathname.match(/(?:video|photo)\/(\d+)/)?.[1] ?? null;
|
|
1474
1471
|
}
|
|
1475
1472
|
function itemStruct(html) {
|
|
1476
1473
|
if (html.includes("SlardarWAF") || html.includes("_wafchallengeid")) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@postfetch/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Zero-dependency typed core that turns Facebook, Instagram, Pinterest, Reddit, SoundCloud, TikTok, X and YouTube post URLs into media files.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
package/src/reddit.ts
CHANGED
|
@@ -27,10 +27,10 @@ export async function resolveReddit(input: ResolveContext): Promise<PostfetchRes
|
|
|
27
27
|
const id = await postId(input.net, input.url);
|
|
28
28
|
const token = await appToken(input.net);
|
|
29
29
|
const post = await fetchPost(input.net, token, id);
|
|
30
|
+
// A text post is a valid result with metadata and no media — fetchPost has
|
|
31
|
+
// already thrown if the post itself is missing, so empty items here mean a
|
|
32
|
+
// self/text post, not a failure.
|
|
30
33
|
const items = await mediaItems(input, post, id);
|
|
31
|
-
if (items.length === 0) {
|
|
32
|
-
throw new Error("Reddit media not found");
|
|
33
|
-
}
|
|
34
34
|
return { archiveFilename: filename(`reddit_${id}.zip`), id, items, metadata: redditMetadata(post), platform: "reddit" };
|
|
35
35
|
}
|
|
36
36
|
|
package/src/tiktok.ts
CHANGED
|
@@ -110,7 +110,8 @@ async function followShortlink(net: Net, userAgent: string, input: string): Prom
|
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
function videoId(input: string): string | null {
|
|
113
|
-
|
|
113
|
+
// Photo (slideshow) posts share the video id namespace under /photo/<id>.
|
|
114
|
+
return asUrl(input).pathname.match(/(?:video|photo)\/(\d+)/)?.[1] ?? null;
|
|
114
115
|
}
|
|
115
116
|
|
|
116
117
|
function itemStruct(html: string): Json {
|