@postfetch/core 0.12.5 → 0.13.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/README.md +10 -1
- package/dist/hls.d.ts +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.js +1147 -850
- package/dist/internal.d.ts +16 -3
- package/dist/spotify.d.ts +3 -0
- package/package.json +3 -2
- package/src/download.ts +26 -16
- package/src/hls.ts +14 -11
- package/src/index.ts +4 -2
- package/src/internal.ts +36 -1
- package/src/postfetch.ts +7 -1
- package/src/spotify.ts +271 -0
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @postfetch/core
|
|
2
2
|
|
|
3
|
-
Zero-dependency typed core that turns Facebook, Instagram, LinkedIn, Pinterest, Reddit, SoundCloud, TikTok, X and YouTube post URLs into media files. Part of [postfetch](https://github.com/chelokot/postfetch).
|
|
3
|
+
Zero-dependency typed core that turns Facebook, Instagram, LinkedIn, Pinterest, Reddit, SoundCloud, Spotify, TikTok, X and YouTube post URLs into media files. Part of [postfetch](https://github.com/chelokot/postfetch).
|
|
4
4
|
|
|
5
5
|
```ts
|
|
6
6
|
import { postfetch, download, downloadBlob, archive, toResponse, PostfetchError } from "@postfetch/core";
|
|
@@ -13,6 +13,15 @@ for (const item of result.items) {
|
|
|
13
13
|
|
|
14
14
|
`postfetch(url, options?)` detects the platform and resolves its media into a typed `PostfetchResult` (URLs plus the headers needed to fetch them). It performs no side effects beyond the lookup — `download`, `downloadBlob`, `archive` and `toResponse` materialize the result.
|
|
15
15
|
|
|
16
|
+
Spotify track URLs are matched to YouTube by artist, title and duration, preferring
|
|
17
|
+
artist uploads and rejecting recognizable alternate versions unless requested.
|
|
18
|
+
Results have `platform: "spotify"`, Spotify metadata and
|
|
19
|
+
`metadata.extra.youtubeUrl` with the exact matched watch URL. Media items remain
|
|
20
|
+
YouTube videos and use the existing video + audio download path and HLS fallback.
|
|
21
|
+
`toResponse` also exposes the URL as `x-media-youtube-url`. Matching is heuristic;
|
|
22
|
+
no match throws a `404` `PostfetchError`. Spotify albums, playlists and shortlinks
|
|
23
|
+
are not supported.
|
|
24
|
+
|
|
16
25
|
`downloadBlob(itemOrUrl, options?)` materializes resolved media for clients that
|
|
17
26
|
need an uploadable `Blob`. Prefer `downloadBlob(item, { remux: true })` to
|
|
18
27
|
include separate audio, assemble HLS playlists and use the item's headers.
|
package/dist/hls.d.ts
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Turn a public social post URL into its media.
|
|
3
3
|
*
|
|
4
|
-
* {@link postfetch} resolves
|
|
5
|
-
*
|
|
4
|
+
* {@link postfetch} resolves public social post and Spotify track URLs to typed
|
|
5
|
+
* {@link MediaItem}s. Spotify tracks are matched to YouTube videos.
|
|
6
|
+
* Zero dependencies, only Web-standard APIs
|
|
6
7
|
* (`fetch`, `Response`, `URL`, `crypto`) — so it runs on Deno, Node, Bun,
|
|
7
8
|
* Cloudflare Workers and browsers alike. It only resolves the media; the
|
|
8
9
|
* {@link download}, {@link downloadBlob}, {@link archive} and {@link toResponse}
|
|
@@ -23,4 +24,4 @@ export { postfetch, detect, type PostfetchOptions } from "./postfetch";
|
|
|
23
24
|
export { buildAudioSliderVideo, type AudioSliderVideoOptions } from "./audio-slider";
|
|
24
25
|
export { download, downloadBlob, archive, toResponse, type Archive, type DownloadBlobOptions, type DownloadOptions, type RemuxedVideo, } from "./download";
|
|
25
26
|
export { PostfetchError } from "./internal";
|
|
26
|
-
export type { InstagramExtra, MediaItem, MediaKind, PinterestExtra, Platform, PlatformResult, PostAuthor, PostComment, PostfetchReason, PostfetchResult, PostMetadata, RedditExtra, SoundcloudExtra, TiktokExtra, TwitterExtra, TwitterQuotedTweet, YoutubeExtra, } from "./internal";
|
|
27
|
+
export type { InstagramExtra, MediaItem, MediaKind, PinterestExtra, Platform, PlatformResult, PostAuthor, PostComment, PostfetchReason, PostfetchResult, PostMetadata, RedditExtra, SoundcloudExtra, SpotifyExtra, TiktokExtra, TwitterExtra, TwitterQuotedTweet, YoutubeExtra, } from "./internal";
|