@steipete/summarize-core 0.7.0

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.
Files changed (182) hide show
  1. package/README.md +7 -0
  2. package/dist/esm/content/index.js +5 -0
  3. package/dist/esm/content/index.js.map +1 -0
  4. package/dist/esm/content/link-preview/client.js +28 -0
  5. package/dist/esm/content/link-preview/client.js.map +1 -0
  6. package/dist/esm/content/link-preview/content/article.js +155 -0
  7. package/dist/esm/content/link-preview/content/article.js.map +1 -0
  8. package/dist/esm/content/link-preview/content/cleaner.js +55 -0
  9. package/dist/esm/content/link-preview/content/cleaner.js.map +1 -0
  10. package/dist/esm/content/link-preview/content/constants.js +7 -0
  11. package/dist/esm/content/link-preview/content/constants.js.map +1 -0
  12. package/dist/esm/content/link-preview/content/fetcher.js +124 -0
  13. package/dist/esm/content/link-preview/content/fetcher.js.map +1 -0
  14. package/dist/esm/content/link-preview/content/firecrawl.js +86 -0
  15. package/dist/esm/content/link-preview/content/firecrawl.js.map +1 -0
  16. package/dist/esm/content/link-preview/content/html.js +162 -0
  17. package/dist/esm/content/link-preview/content/html.js.map +1 -0
  18. package/dist/esm/content/link-preview/content/index.js +345 -0
  19. package/dist/esm/content/link-preview/content/index.js.map +1 -0
  20. package/dist/esm/content/link-preview/content/jsonld.js +77 -0
  21. package/dist/esm/content/link-preview/content/jsonld.js.map +1 -0
  22. package/dist/esm/content/link-preview/content/parsers.js +77 -0
  23. package/dist/esm/content/link-preview/content/parsers.js.map +1 -0
  24. package/dist/esm/content/link-preview/content/podcast-utils.js +79 -0
  25. package/dist/esm/content/link-preview/content/podcast-utils.js.map +1 -0
  26. package/dist/esm/content/link-preview/content/readability.js +53 -0
  27. package/dist/esm/content/link-preview/content/readability.js.map +1 -0
  28. package/dist/esm/content/link-preview/content/twitter-utils.js +68 -0
  29. package/dist/esm/content/link-preview/content/twitter-utils.js.map +1 -0
  30. package/dist/esm/content/link-preview/content/types.js +4 -0
  31. package/dist/esm/content/link-preview/content/types.js.map +1 -0
  32. package/dist/esm/content/link-preview/content/utils.js +164 -0
  33. package/dist/esm/content/link-preview/content/utils.js.map +1 -0
  34. package/dist/esm/content/link-preview/content/video.js +96 -0
  35. package/dist/esm/content/link-preview/content/video.js.map +1 -0
  36. package/dist/esm/content/link-preview/content/youtube.js +82 -0
  37. package/dist/esm/content/link-preview/content/youtube.js.map +1 -0
  38. package/dist/esm/content/link-preview/deps.js +20 -0
  39. package/dist/esm/content/link-preview/deps.js.map +1 -0
  40. package/dist/esm/content/link-preview/fetch-with-timeout.js +35 -0
  41. package/dist/esm/content/link-preview/fetch-with-timeout.js.map +1 -0
  42. package/dist/esm/content/link-preview/types.js +2 -0
  43. package/dist/esm/content/link-preview/types.js.map +1 -0
  44. package/dist/esm/content/transcript/cache.js +79 -0
  45. package/dist/esm/content/transcript/cache.js.map +1 -0
  46. package/dist/esm/content/transcript/index.js +130 -0
  47. package/dist/esm/content/transcript/index.js.map +1 -0
  48. package/dist/esm/content/transcript/normalize.js +43 -0
  49. package/dist/esm/content/transcript/normalize.js.map +1 -0
  50. package/dist/esm/content/transcript/providers/generic.js +11 -0
  51. package/dist/esm/content/transcript/providers/generic.js.map +1 -0
  52. package/dist/esm/content/transcript/providers/podcast/apple-flow.js +222 -0
  53. package/dist/esm/content/transcript/providers/podcast/apple-flow.js.map +1 -0
  54. package/dist/esm/content/transcript/providers/podcast/apple.js +38 -0
  55. package/dist/esm/content/transcript/providers/podcast/apple.js.map +1 -0
  56. package/dist/esm/content/transcript/providers/podcast/constants.js +8 -0
  57. package/dist/esm/content/transcript/providers/podcast/constants.js.map +1 -0
  58. package/dist/esm/content/transcript/providers/podcast/flow-context.js +2 -0
  59. package/dist/esm/content/transcript/providers/podcast/flow-context.js.map +1 -0
  60. package/dist/esm/content/transcript/providers/podcast/itunes.js +134 -0
  61. package/dist/esm/content/transcript/providers/podcast/itunes.js.map +1 -0
  62. package/dist/esm/content/transcript/providers/podcast/json.js +34 -0
  63. package/dist/esm/content/transcript/providers/podcast/json.js.map +1 -0
  64. package/dist/esm/content/transcript/providers/podcast/media.js +345 -0
  65. package/dist/esm/content/transcript/providers/podcast/media.js.map +1 -0
  66. package/dist/esm/content/transcript/providers/podcast/results.js +28 -0
  67. package/dist/esm/content/transcript/providers/podcast/results.js.map +1 -0
  68. package/dist/esm/content/transcript/providers/podcast/rss.js +253 -0
  69. package/dist/esm/content/transcript/providers/podcast/rss.js.map +1 -0
  70. package/dist/esm/content/transcript/providers/podcast/spotify-flow.js +218 -0
  71. package/dist/esm/content/transcript/providers/podcast/spotify-flow.js.map +1 -0
  72. package/dist/esm/content/transcript/providers/podcast/spotify.js +113 -0
  73. package/dist/esm/content/transcript/providers/podcast/spotify.js.map +1 -0
  74. package/dist/esm/content/transcript/providers/podcast.js +222 -0
  75. package/dist/esm/content/transcript/providers/podcast.js.map +1 -0
  76. package/dist/esm/content/transcript/providers/youtube/api.js +257 -0
  77. package/dist/esm/content/transcript/providers/youtube/api.js.map +1 -0
  78. package/dist/esm/content/transcript/providers/youtube/apify.js +55 -0
  79. package/dist/esm/content/transcript/providers/youtube/apify.js.map +1 -0
  80. package/dist/esm/content/transcript/providers/youtube/captions.js +409 -0
  81. package/dist/esm/content/transcript/providers/youtube/captions.js.map +1 -0
  82. package/dist/esm/content/transcript/providers/youtube/yt-dlp.js +166 -0
  83. package/dist/esm/content/transcript/providers/youtube/yt-dlp.js.map +1 -0
  84. package/dist/esm/content/transcript/providers/youtube.js +173 -0
  85. package/dist/esm/content/transcript/providers/youtube.js.map +1 -0
  86. package/dist/esm/content/transcript/types.js +2 -0
  87. package/dist/esm/content/transcript/types.js.map +1 -0
  88. package/dist/esm/content/transcript/utils.js +259 -0
  89. package/dist/esm/content/transcript/utils.js.map +1 -0
  90. package/dist/esm/index.js +4 -0
  91. package/dist/esm/index.js.map +1 -0
  92. package/dist/esm/language.js +126 -0
  93. package/dist/esm/language.js.map +1 -0
  94. package/dist/esm/prompts/cli.js +20 -0
  95. package/dist/esm/prompts/cli.js.map +1 -0
  96. package/dist/esm/prompts/file.js +48 -0
  97. package/dist/esm/prompts/file.js.map +1 -0
  98. package/dist/esm/prompts/index.js +4 -0
  99. package/dist/esm/prompts/index.js.map +1 -0
  100. package/dist/esm/prompts/link-summary.js +116 -0
  101. package/dist/esm/prompts/link-summary.js.map +1 -0
  102. package/dist/esm/shared/contracts.js +2 -0
  103. package/dist/esm/shared/contracts.js.map +1 -0
  104. package/dist/esm/transcription/whisper/constants.js +8 -0
  105. package/dist/esm/transcription/whisper/constants.js.map +1 -0
  106. package/dist/esm/transcription/whisper/core.js +303 -0
  107. package/dist/esm/transcription/whisper/core.js.map +1 -0
  108. package/dist/esm/transcription/whisper/fal.js +41 -0
  109. package/dist/esm/transcription/whisper/fal.js.map +1 -0
  110. package/dist/esm/transcription/whisper/ffmpeg.js +179 -0
  111. package/dist/esm/transcription/whisper/ffmpeg.js.map +1 -0
  112. package/dist/esm/transcription/whisper/openai.js +47 -0
  113. package/dist/esm/transcription/whisper/openai.js.map +1 -0
  114. package/dist/esm/transcription/whisper/types.js +2 -0
  115. package/dist/esm/transcription/whisper/types.js.map +1 -0
  116. package/dist/esm/transcription/whisper/utils.js +63 -0
  117. package/dist/esm/transcription/whisper/utils.js.map +1 -0
  118. package/dist/esm/transcription/whisper/whisper-cpp.js +227 -0
  119. package/dist/esm/transcription/whisper/whisper-cpp.js.map +1 -0
  120. package/dist/esm/transcription/whisper.js +5 -0
  121. package/dist/esm/transcription/whisper.js.map +1 -0
  122. package/dist/types/content/index.d.ts +5 -0
  123. package/dist/types/content/link-preview/client.d.ts +18 -0
  124. package/dist/types/content/link-preview/content/article.d.ts +4 -0
  125. package/dist/types/content/link-preview/content/cleaner.d.ts +12 -0
  126. package/dist/types/content/link-preview/content/constants.d.ts +6 -0
  127. package/dist/types/content/link-preview/content/fetcher.d.ts +16 -0
  128. package/dist/types/content/link-preview/content/firecrawl.d.ts +14 -0
  129. package/dist/types/content/link-preview/content/html.d.ts +17 -0
  130. package/dist/types/content/link-preview/content/index.d.ts +4 -0
  131. package/dist/types/content/link-preview/content/jsonld.d.ts +6 -0
  132. package/dist/types/content/link-preview/content/parsers.d.ts +7 -0
  133. package/dist/types/content/link-preview/content/podcast-utils.d.ts +7 -0
  134. package/dist/types/content/link-preview/content/readability.d.ts +8 -0
  135. package/dist/types/content/link-preview/content/twitter-utils.d.ts +4 -0
  136. package/dist/types/content/link-preview/content/types.d.ts +61 -0
  137. package/dist/types/content/link-preview/content/utils.d.ts +17 -0
  138. package/dist/types/content/link-preview/content/video.d.ts +5 -0
  139. package/dist/types/content/link-preview/content/youtube.d.ts +1 -0
  140. package/dist/types/content/link-preview/deps.d.ts +167 -0
  141. package/dist/types/content/link-preview/fetch-with-timeout.d.ts +4 -0
  142. package/dist/types/content/link-preview/types.d.ts +37 -0
  143. package/dist/types/content/transcript/cache.d.ts +29 -0
  144. package/dist/types/content/transcript/index.d.ts +9 -0
  145. package/dist/types/content/transcript/normalize.d.ts +3 -0
  146. package/dist/types/content/transcript/providers/generic.d.ts +3 -0
  147. package/dist/types/content/transcript/providers/podcast/apple-flow.d.ts +4 -0
  148. package/dist/types/content/transcript/providers/podcast/apple.d.ts +6 -0
  149. package/dist/types/content/transcript/providers/podcast/constants.d.ts +7 -0
  150. package/dist/types/content/transcript/providers/podcast/flow-context.d.ts +11 -0
  151. package/dist/types/content/transcript/providers/podcast/itunes.d.ts +17 -0
  152. package/dist/types/content/transcript/providers/podcast/json.d.ts +8 -0
  153. package/dist/types/content/transcript/providers/podcast/media.d.ts +42 -0
  154. package/dist/types/content/transcript/providers/podcast/results.d.ts +10 -0
  155. package/dist/types/content/transcript/providers/podcast/rss.d.ts +22 -0
  156. package/dist/types/content/transcript/providers/podcast/spotify-flow.d.ts +3 -0
  157. package/dist/types/content/transcript/providers/podcast/spotify.d.ts +24 -0
  158. package/dist/types/content/transcript/providers/podcast.d.ts +20 -0
  159. package/dist/types/content/transcript/providers/youtube/api.d.ts +26 -0
  160. package/dist/types/content/transcript/providers/youtube/apify.d.ts +1 -0
  161. package/dist/types/content/transcript/providers/youtube/captions.d.ts +7 -0
  162. package/dist/types/content/transcript/providers/youtube/yt-dlp.d.ts +17 -0
  163. package/dist/types/content/transcript/providers/youtube.d.ts +3 -0
  164. package/dist/types/content/transcript/types.d.ts +30 -0
  165. package/dist/types/content/transcript/utils.d.ts +8 -0
  166. package/dist/types/index.d.ts +4 -0
  167. package/dist/types/language.d.ts +25 -0
  168. package/dist/types/prompts/cli.d.ts +10 -0
  169. package/dist/types/prompts/file.d.ts +17 -0
  170. package/dist/types/prompts/index.d.ts +4 -0
  171. package/dist/types/prompts/link-summary.d.ts +29 -0
  172. package/dist/types/shared/contracts.d.ts +2 -0
  173. package/dist/types/transcription/whisper/constants.d.ts +7 -0
  174. package/dist/types/transcription/whisper/core.d.ts +20 -0
  175. package/dist/types/transcription/whisper/fal.d.ts +1 -0
  176. package/dist/types/transcription/whisper/ffmpeg.d.ts +16 -0
  177. package/dist/types/transcription/whisper/openai.d.ts +2 -0
  178. package/dist/types/transcription/whisper/types.d.ts +17 -0
  179. package/dist/types/transcription/whisper/utils.d.ts +5 -0
  180. package/dist/types/transcription/whisper/whisper-cpp.d.ts +9 -0
  181. package/dist/types/transcription/whisper.d.ts +5 -0
  182. package/package.json +54 -0
@@ -0,0 +1,218 @@
1
+ import { TRANSCRIPTION_TIMEOUT_MS } from './constants.js';
2
+ import { resolvePodcastEpisodeFromItunesSearch, resolvePodcastFeedUrlFromItunesSearch, } from './itunes.js';
3
+ import { buildWhisperResult, joinNotes } from './results.js';
4
+ import { decodeXmlEntities, extractEnclosureForEpisode, tryFetchTranscriptFromFeedXml, } from './rss.js';
5
+ import { extractSpotifyEmbedData, extractSpotifyEpisodeId, fetchSpotifyEmbedHtml, } from './spotify.js';
6
+ export async function fetchSpotifyTranscript(flow) {
7
+ const spotifyEpisodeId = extractSpotifyEpisodeId(flow.context.url);
8
+ if (!spotifyEpisodeId)
9
+ return null;
10
+ try {
11
+ // Spotify episode pages frequently trigger bot protection (captcha/recaptcha) and the
12
+ // episode audio itself is sometimes DRM-protected. So we:
13
+ // - fetch the lightweight embed page for stable metadata (__NEXT_DATA__),
14
+ // - first try the embed-provided audio URL (works for many episodes),
15
+ // - then fall back to resolving the publisher RSS feed via Apple’s iTunes directory.
16
+ const embedUrl = `https://open.spotify.com/embed/episode/${spotifyEpisodeId}`;
17
+ const { html: embedHtml, via } = await fetchSpotifyEmbedHtml({
18
+ embedUrl,
19
+ episodeId: spotifyEpisodeId,
20
+ fetchImpl: flow.options.fetch,
21
+ scrapeWithFirecrawl: flow.options.scrapeWithFirecrawl ?? null,
22
+ });
23
+ const embedData = extractSpotifyEmbedData(embedHtml);
24
+ if (!embedData) {
25
+ throw new Error('Spotify embed data not found (missing __NEXT_DATA__)');
26
+ }
27
+ const showTitle = embedData.showTitle;
28
+ const episodeTitle = embedData.episodeTitle;
29
+ const embedAudioUrl = embedData.audioUrl;
30
+ const embedDurationSeconds = embedData.durationSeconds;
31
+ if (embedAudioUrl) {
32
+ const missing = flow.ensureTranscriptionProvider();
33
+ if (missing)
34
+ return missing;
35
+ flow.pushOnce('whisper');
36
+ const result = await flow.transcribe({
37
+ url: embedAudioUrl,
38
+ filenameHint: 'episode.mp4',
39
+ durationSecondsHint: embedDurationSeconds,
40
+ });
41
+ const embedTranscriptChars = result.text?.trim().length ?? 0;
42
+ const shouldTreatAsPreview = embedTranscriptChars > 0 &&
43
+ (embedTranscriptChars < 200 ||
44
+ (embedTranscriptChars < 800 &&
45
+ (embedDurationSeconds == null ||
46
+ (typeof embedDurationSeconds === 'number' && embedDurationSeconds >= 600))));
47
+ if (result.text && !shouldTreatAsPreview) {
48
+ flow.notes.push(via === 'firecrawl'
49
+ ? 'Resolved Spotify embed audio via Firecrawl'
50
+ : 'Resolved Spotify embed audio');
51
+ return buildWhisperResult({
52
+ attemptedProviders: flow.attemptedProviders,
53
+ notes: flow.notes,
54
+ outcome: result,
55
+ metadata: {
56
+ provider: 'podcast',
57
+ kind: 'spotify_embed_audio',
58
+ episodeId: spotifyEpisodeId,
59
+ showTitle,
60
+ episodeTitle,
61
+ audioUrl: embedAudioUrl,
62
+ durationSeconds: embedDurationSeconds,
63
+ drmFormat: embedData.drmFormat,
64
+ },
65
+ });
66
+ }
67
+ if (shouldTreatAsPreview) {
68
+ flow.notes.push(`Spotify embed audio looked like a short clip (${embedTranscriptChars} chars); falling back to iTunes RSS`);
69
+ }
70
+ flow.notes.push(`Spotify embed audio transcription failed; falling back to iTunes RSS: ${result.error?.message ?? 'unknown error'}`);
71
+ }
72
+ const feedUrl = await resolvePodcastFeedUrlFromItunesSearch(flow.options.fetch, showTitle);
73
+ if (!feedUrl) {
74
+ const episodeFromSearch = await resolvePodcastEpisodeFromItunesSearch(flow.options.fetch, showTitle, episodeTitle);
75
+ if (episodeFromSearch) {
76
+ const missing = flow.ensureTranscriptionProvider();
77
+ if (missing)
78
+ return missing;
79
+ flow.pushOnce('whisper');
80
+ const result = await flow.transcribe({
81
+ url: episodeFromSearch.episodeUrl,
82
+ filenameHint: 'episode.mp3',
83
+ durationSecondsHint: episodeFromSearch.durationSeconds,
84
+ });
85
+ if (result.text) {
86
+ flow.notes.push('Resolved Spotify episode via iTunes episode search');
87
+ return buildWhisperResult({
88
+ attemptedProviders: flow.attemptedProviders,
89
+ notes: flow.notes,
90
+ outcome: result,
91
+ metadata: {
92
+ provider: 'podcast',
93
+ kind: 'spotify_itunes_search_episode',
94
+ episodeId: spotifyEpisodeId,
95
+ showTitle,
96
+ episodeTitle: episodeFromSearch.episodeTitle,
97
+ episodeUrl: episodeFromSearch.episodeUrl,
98
+ durationSeconds: episodeFromSearch.durationSeconds,
99
+ },
100
+ });
101
+ }
102
+ }
103
+ throw new Error(`Spotify episode audio appears DRM-protected; could not resolve RSS feed via iTunes Search API for show "${showTitle}"`);
104
+ }
105
+ const feedResponse = await flow.options.fetch(feedUrl, {
106
+ signal: AbortSignal.timeout(TRANSCRIPTION_TIMEOUT_MS),
107
+ });
108
+ if (!feedResponse.ok) {
109
+ throw new Error(`Podcast feed fetch failed (${feedResponse.status})`);
110
+ }
111
+ const feedXml = await feedResponse.text();
112
+ let maybeTranscript = null;
113
+ if (/podcast:transcript/i.test(feedXml)) {
114
+ flow.pushOnce('podcastTranscript');
115
+ maybeTranscript = await tryFetchTranscriptFromFeedXml({
116
+ fetchImpl: flow.options.fetch,
117
+ feedXml,
118
+ episodeTitle,
119
+ notes: flow.notes,
120
+ });
121
+ }
122
+ if (maybeTranscript) {
123
+ return {
124
+ text: maybeTranscript.text,
125
+ source: 'podcastTranscript',
126
+ attemptedProviders: flow.attemptedProviders,
127
+ notes: joinNotes(flow.notes),
128
+ metadata: {
129
+ provider: 'podcast',
130
+ kind: 'spotify_itunes_rss_transcript',
131
+ episodeId: spotifyEpisodeId,
132
+ showTitle,
133
+ episodeTitle,
134
+ feedUrl,
135
+ transcriptUrl: maybeTranscript.transcriptUrl,
136
+ transcriptType: maybeTranscript.transcriptType,
137
+ },
138
+ };
139
+ }
140
+ const match = extractEnclosureForEpisode(feedXml, episodeTitle);
141
+ if (!match) {
142
+ const episodeFromSearch = await resolvePodcastEpisodeFromItunesSearch(flow.options.fetch, showTitle, episodeTitle);
143
+ if (episodeFromSearch) {
144
+ const missing = flow.ensureTranscriptionProvider();
145
+ if (missing)
146
+ return missing;
147
+ flow.pushOnce('whisper');
148
+ const result = await flow.transcribe({
149
+ url: episodeFromSearch.episodeUrl,
150
+ filenameHint: 'episode.mp3',
151
+ durationSecondsHint: episodeFromSearch.durationSeconds,
152
+ });
153
+ if (result.text) {
154
+ flow.notes.push('Resolved Spotify episode via iTunes episode search');
155
+ return buildWhisperResult({
156
+ attemptedProviders: flow.attemptedProviders,
157
+ notes: flow.notes,
158
+ outcome: result,
159
+ metadata: {
160
+ provider: 'podcast',
161
+ kind: 'spotify_itunes_search_episode',
162
+ episodeId: spotifyEpisodeId,
163
+ showTitle,
164
+ episodeTitle: episodeFromSearch.episodeTitle,
165
+ episodeUrl: episodeFromSearch.episodeUrl,
166
+ durationSeconds: episodeFromSearch.durationSeconds,
167
+ },
168
+ });
169
+ }
170
+ }
171
+ throw new Error(`Episode enclosure not found in RSS feed for "${episodeTitle}"`);
172
+ }
173
+ const enclosureUrl = decodeXmlEntities(match.enclosureUrl);
174
+ const durationSeconds = match.durationSeconds;
175
+ flow.notes.push(via === 'firecrawl'
176
+ ? 'Resolved Spotify episode via Firecrawl embed + iTunes RSS'
177
+ : 'Resolved Spotify episode via iTunes RSS');
178
+ const missing = flow.ensureTranscriptionProvider();
179
+ if (missing)
180
+ return missing;
181
+ flow.pushOnce('whisper');
182
+ const result = await flow.transcribe({
183
+ url: enclosureUrl,
184
+ filenameHint: 'episode.mp3',
185
+ durationSecondsHint: durationSeconds,
186
+ });
187
+ return buildWhisperResult({
188
+ attemptedProviders: flow.attemptedProviders,
189
+ notes: flow.notes,
190
+ outcome: result,
191
+ includeProviderOnFailure: true,
192
+ metadata: {
193
+ provider: 'podcast',
194
+ kind: 'spotify_itunes_rss_enclosure',
195
+ episodeId: spotifyEpisodeId,
196
+ showTitle,
197
+ episodeTitle,
198
+ feedUrl,
199
+ enclosureUrl,
200
+ durationSeconds,
201
+ },
202
+ });
203
+ }
204
+ catch (error) {
205
+ return {
206
+ text: null,
207
+ source: null,
208
+ attemptedProviders: flow.attemptedProviders,
209
+ notes: `Spotify episode fetch failed: ${error instanceof Error ? error.message : String(error)}`,
210
+ metadata: {
211
+ provider: 'podcast',
212
+ kind: 'spotify_itunes_rss_enclosure',
213
+ episodeId: spotifyEpisodeId,
214
+ },
215
+ };
216
+ }
217
+ }
218
+ //# sourceMappingURL=spotify-flow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spotify-flow.js","sourceRoot":"","sources":["../../../../../../src/content/transcript/providers/podcast/spotify-flow.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAA;AAEzD,OAAO,EACL,qCAAqC,EACr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AAE,SAAS;gBACnB,IAAI,EAAE,8BAA8B;gBACpC,SAAS,EAAE,gBAAgB;aAC5B;SACF,CAAA;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,113 @@
1
+ import { BLOCKED_HTML_HINT_PATTERN, TRANSCRIPTION_TIMEOUT_MS } from './constants.js';
2
+ import { getJsonNumber, getJsonPath, getJsonString } from './json.js';
3
+ export function extractSpotifyEpisodeId(url) {
4
+ try {
5
+ const parsed = new URL(url);
6
+ const host = parsed.hostname.toLowerCase();
7
+ if (!host.endsWith('spotify.com'))
8
+ return null;
9
+ const parts = parsed.pathname.split('/').filter(Boolean);
10
+ const idx = parts.indexOf('episode');
11
+ const id = idx >= 0 ? parts[idx + 1] : null;
12
+ return id && /^[A-Za-z0-9]+$/.test(id) ? id : null;
13
+ }
14
+ catch {
15
+ return null;
16
+ }
17
+ }
18
+ export function extractSpotifyEmbedData(html) {
19
+ const match = html.match(/<script[^>]*id=["']__NEXT_DATA__["'][^>]*>([\s\S]*?)<\/script>/i);
20
+ if (!match?.[1])
21
+ return null;
22
+ try {
23
+ const json = JSON.parse(match[1]);
24
+ const showTitle = (getJsonString(json, ['props', 'pageProps', 'state', 'data', 'entity', 'subtitle']) ?? '').trim();
25
+ const episodeTitle = (getJsonString(json, ['props', 'pageProps', 'state', 'data', 'entity', 'title']) ?? '').trim();
26
+ const durationMs = getJsonNumber(json, [
27
+ 'props',
28
+ 'pageProps',
29
+ 'state',
30
+ 'data',
31
+ 'entity',
32
+ 'duration',
33
+ ]);
34
+ const drmFormat = getJsonString(json, [
35
+ 'props',
36
+ 'pageProps',
37
+ 'state',
38
+ 'data',
39
+ 'defaultAudioFileObject',
40
+ 'format',
41
+ ]) ?? null;
42
+ const audioUrl = pickSpotifyEmbedAudioUrl(getJsonPath(json, ['props', 'pageProps', 'state', 'data', 'defaultAudioFileObject', 'url']));
43
+ if (!showTitle || !episodeTitle)
44
+ return null;
45
+ return {
46
+ showTitle,
47
+ episodeTitle,
48
+ durationSeconds: typeof durationMs === 'number' && Number.isFinite(durationMs) ? durationMs / 1000 : null,
49
+ drmFormat,
50
+ audioUrl,
51
+ };
52
+ }
53
+ catch {
54
+ return null;
55
+ }
56
+ }
57
+ export async function fetchSpotifyEmbedHtml({ embedUrl, episodeId, fetchImpl, scrapeWithFirecrawl, }) {
58
+ try {
59
+ // Try plain fetch first: fast, cheap, and often works with a realistic UA + referer.
60
+ const embedResponse = await fetchImpl(embedUrl, {
61
+ signal: AbortSignal.timeout(TRANSCRIPTION_TIMEOUT_MS),
62
+ headers: {
63
+ accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
64
+ 'accept-language': 'en-US,en;q=0.9',
65
+ referer: `https://open.spotify.com/episode/${episodeId}`,
66
+ 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120 Safari/537.36',
67
+ },
68
+ });
69
+ if (!embedResponse.ok) {
70
+ throw new Error(`Spotify embed fetch failed (${embedResponse.status})`);
71
+ }
72
+ const embedHtml = await embedResponse.text();
73
+ if (!looksLikeBlockedHtml(embedHtml)) {
74
+ return { html: embedHtml, via: 'fetch' };
75
+ }
76
+ throw new Error('Spotify embed HTML looked blocked (captcha)');
77
+ }
78
+ catch (error) {
79
+ if (!scrapeWithFirecrawl) {
80
+ throw error;
81
+ }
82
+ // Firecrawl is optional and only used as a fallback when Spotify blocks direct fetches.
83
+ const payload = await scrapeWithFirecrawl(embedUrl, {
84
+ cacheMode: 'bypass',
85
+ timeoutMs: TRANSCRIPTION_TIMEOUT_MS,
86
+ });
87
+ const text = (payload?.html ?? payload?.markdown ?? '').trim();
88
+ if (!text) {
89
+ throw new Error(`Spotify embed fetch failed and Firecrawl returned empty content (${error instanceof Error ? error.message : String(error)})`);
90
+ }
91
+ if (looksLikeBlockedHtml(text)) {
92
+ throw new Error('Spotify embed blocked even via Firecrawl (captcha)');
93
+ }
94
+ return { html: text, via: 'firecrawl' };
95
+ }
96
+ }
97
+ export function looksLikeBlockedHtml(html) {
98
+ const head = html.slice(0, 20000).toLowerCase();
99
+ // Spotify embed pages include `__NEXT_DATA__` even when the rest of the HTML is minimal; treat that
100
+ // as a strong "not blocked" signal to avoid unnecessary Firecrawl fallbacks.
101
+ if (head.includes('__next_data__'))
102
+ return false;
103
+ return BLOCKED_HTML_HINT_PATTERN.test(head);
104
+ }
105
+ function pickSpotifyEmbedAudioUrl(raw) {
106
+ const urls = Array.isArray(raw) ? raw.filter((v) => typeof v === 'string') : [];
107
+ const normalized = urls.map((u) => u.trim()).filter((u) => /^https?:\/\//i.test(u));
108
+ if (normalized.length === 0)
109
+ return null;
110
+ const scdn = normalized.find((u) => /scdn\.co/i.test(u));
111
+ return scdn ?? normalized[0] ?? null;
112
+ }
113
+ //# sourceMappingURL=spotify.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spotify.js","sourceRoot":"","sources":["../../../../../../src/content/transcript/providers/podcast/spotify.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAA;AACpF,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAErE,MAAM,UAAU,uBAAuB,CAAC,GAAW;IACjD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA;QAC3B,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAA;QAC1C,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC;YAAE,OAAO,IAAI,CAAA;QAE9C,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;QACxD,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;QACpC,MAAM,EAAE,GAAG,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AG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IACzF,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;IACnF,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAA;IACxC,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;IACxD,OAAO,IAAI,IAAI,UAAU,CAAC,CAAC,CAAC,IAAI,IAAI,CAAA;AACtC,CAAC"}
@@ -0,0 +1,222 @@
1
+ import { isWhisperCppReady } from '../../../transcription/whisper.js';
2
+ import { fetchAppleTranscriptFromEmbeddedHtml, fetchAppleTranscriptFromItunesLookup, } from './podcast/apple-flow.js';
3
+ import { FEED_HINT_URL_PATTERN, PODCAST_PLATFORM_HOST_PATTERN } from './podcast/constants.js';
4
+ import { resolvePodcastFeedUrlFromItunesSearch } from './podcast/itunes.js';
5
+ import { downloadCappedBytes, downloadToFile, filenameFromUrl, formatBytes, normalizeHeaderType, parseContentLength, probeRemoteMedia, transcribeMediaUrl, } from './podcast/media.js';
6
+ import { buildWhisperResult, joinNotes } from './podcast/results.js';
7
+ import { decodeXmlEntities, extractEnclosureForEpisode, extractEnclosureFromFeed, extractItemDurationSeconds, looksLikeRssOrAtomFeed, tryFetchTranscriptFromFeedXml, } from './podcast/rss.js';
8
+ import { looksLikeBlockedHtml } from './podcast/spotify.js';
9
+ import { fetchSpotifyTranscript } from './podcast/spotify-flow.js';
10
+ export const canHandle = ({ url, html }) => {
11
+ if (typeof html === 'string' && looksLikeRssOrAtomFeed(html))
12
+ return true;
13
+ if (PODCAST_PLATFORM_HOST_PATTERN.test(url))
14
+ return true;
15
+ return FEED_HINT_URL_PATTERN.test(url);
16
+ };
17
+ export const fetchTranscript = async (context, options) => {
18
+ const attemptedProviders = [];
19
+ const notes = [];
20
+ const pushOnce = (provider) => {
21
+ if (!attemptedProviders.includes(provider))
22
+ attemptedProviders.push(provider);
23
+ };
24
+ const hasTranscriptionKeys = Boolean(options.openaiApiKey || options.falApiKey);
25
+ const hasLocalWhisper = await isWhisperCppReady();
26
+ const missingTranscriptionProviderResult = () => ({
27
+ text: null,
28
+ source: null,
29
+ attemptedProviders,
30
+ metadata: { provider: 'podcast', reason: 'missing_transcription_keys' },
31
+ notes: 'Missing transcription provider (install whisper-cpp or set OPENAI_API_KEY/FAL_KEY)',
32
+ });
33
+ const ensureTranscriptionProvider = () => {
34
+ return !hasTranscriptionKeys && !hasLocalWhisper ? missingTranscriptionProviderResult() : null;
35
+ };
36
+ const progress = {
37
+ url: context.url,
38
+ service: 'podcast',
39
+ onProgress: options.onProgress ?? null,
40
+ };
41
+ const transcribe = (request) => transcribeMediaUrl({
42
+ fetchImpl: options.fetch,
43
+ openaiApiKey: options.openaiApiKey,
44
+ falApiKey: options.falApiKey,
45
+ notes,
46
+ progress,
47
+ ...request,
48
+ });
49
+ const flow = {
50
+ context,
51
+ options,
52
+ attemptedProviders,
53
+ notes,
54
+ pushOnce,
55
+ ensureTranscriptionProvider,
56
+ transcribe,
57
+ };
58
+ const feedHtml = typeof context.html === 'string' ? context.html : null;
59
+ if (feedHtml && /podcast:transcript/i.test(feedHtml)) {
60
+ pushOnce('podcastTranscript');
61
+ const direct = await tryFetchTranscriptFromFeedXml({
62
+ fetchImpl: options.fetch,
63
+ feedXml: feedHtml,
64
+ episodeTitle: null,
65
+ notes,
66
+ });
67
+ if (direct) {
68
+ return {
69
+ text: direct.text,
70
+ source: 'podcastTranscript',
71
+ attemptedProviders,
72
+ notes: joinNotes(notes),
73
+ metadata: {
74
+ provider: 'podcast',
75
+ kind: 'rss_podcast_transcript',
76
+ transcriptUrl: direct.transcriptUrl,
77
+ transcriptType: direct.transcriptType,
78
+ },
79
+ };
80
+ }
81
+ }
82
+ const spotifyResult = await fetchSpotifyTranscript(flow);
83
+ if (spotifyResult)
84
+ return spotifyResult;
85
+ const appleLookupResult = await fetchAppleTranscriptFromItunesLookup(flow);
86
+ if (appleLookupResult)
87
+ return appleLookupResult;
88
+ const appleEmbeddedResult = await fetchAppleTranscriptFromEmbeddedHtml(flow);
89
+ if (appleEmbeddedResult)
90
+ return appleEmbeddedResult;
91
+ const feedEnclosureUrl = feedHtml ? extractEnclosureFromFeed(feedHtml) : null;
92
+ if (feedEnclosureUrl && feedHtml) {
93
+ const resolvedUrl = decodeXmlEntities(feedEnclosureUrl.enclosureUrl);
94
+ const durationSeconds = feedEnclosureUrl.durationSeconds;
95
+ try {
96
+ const missing = ensureTranscriptionProvider();
97
+ if (missing)
98
+ return missing;
99
+ pushOnce('whisper');
100
+ const transcript = await transcribe({
101
+ url: resolvedUrl,
102
+ filenameHint: 'episode.mp3',
103
+ durationSecondsHint: durationSeconds,
104
+ });
105
+ return buildWhisperResult({
106
+ attemptedProviders,
107
+ notes,
108
+ outcome: transcript,
109
+ includeProviderOnFailure: true,
110
+ metadata: {
111
+ provider: 'podcast',
112
+ kind: 'rss_enclosure',
113
+ enclosureUrl: resolvedUrl,
114
+ durationSeconds,
115
+ },
116
+ });
117
+ }
118
+ catch (error) {
119
+ return {
120
+ text: null,
121
+ source: null,
122
+ attemptedProviders,
123
+ notes: `Podcast enclosure download failed: ${error instanceof Error ? error.message : String(error)}`,
124
+ metadata: { provider: 'podcast', kind: 'rss_enclosure', enclosureUrl: resolvedUrl },
125
+ };
126
+ }
127
+ }
128
+ const ogAudioUrl = feedHtml ? extractOgAudioUrl(feedHtml) : null;
129
+ if (ogAudioUrl) {
130
+ attemptedProviders.push('whisper');
131
+ const result = await transcribe({
132
+ url: ogAudioUrl,
133
+ filenameHint: 'audio.mp3',
134
+ durationSecondsHint: null,
135
+ });
136
+ if (result.text) {
137
+ notes.push('Used og:audio media (may be a preview clip, not the full episode)');
138
+ return buildWhisperResult({
139
+ attemptedProviders,
140
+ notes,
141
+ outcome: result,
142
+ metadata: {
143
+ provider: 'podcast',
144
+ kind: 'og_audio',
145
+ ogAudioUrl,
146
+ },
147
+ });
148
+ }
149
+ return {
150
+ text: null,
151
+ source: null,
152
+ attemptedProviders,
153
+ notes: result.error?.message ?? null,
154
+ metadata: { provider: 'podcast', kind: 'og_audio', ogAudioUrl },
155
+ };
156
+ }
157
+ if (options.ytDlpPath) {
158
+ attemptedProviders.push('yt-dlp');
159
+ try {
160
+ const mod = await import('./youtube/yt-dlp.js');
161
+ const result = await mod.fetchTranscriptWithYtDlp({
162
+ ytDlpPath: options.ytDlpPath,
163
+ openaiApiKey: options.openaiApiKey,
164
+ falApiKey: options.falApiKey,
165
+ url: context.url,
166
+ });
167
+ if (result.notes.length > 0)
168
+ notes.push(...result.notes);
169
+ return {
170
+ text: result.text,
171
+ source: result.text ? 'yt-dlp' : null,
172
+ attemptedProviders,
173
+ notes: joinNotes(notes),
174
+ metadata: { provider: 'podcast', kind: 'yt_dlp', transcriptionProvider: result.provider },
175
+ };
176
+ }
177
+ catch (error) {
178
+ return {
179
+ text: null,
180
+ source: null,
181
+ attemptedProviders,
182
+ notes: `yt-dlp transcription failed: ${error instanceof Error ? error.message : String(error)}`,
183
+ metadata: { provider: 'podcast', kind: 'yt_dlp' },
184
+ };
185
+ }
186
+ }
187
+ const missing = ensureTranscriptionProvider();
188
+ if (missing)
189
+ return missing;
190
+ return {
191
+ text: null,
192
+ source: null,
193
+ attemptedProviders,
194
+ metadata: { provider: 'podcast', reason: 'no_enclosure_and_no_yt_dlp' },
195
+ };
196
+ };
197
+ function extractOgAudioUrl(html) {
198
+ const match = html.match(/<meta\s+property=['"]og:audio['"]\s+content=['"]([^'"]+)['"][^>]*>/i);
199
+ if (!match?.[1])
200
+ return null;
201
+ const candidate = match[1].trim();
202
+ if (!candidate)
203
+ return null;
204
+ if (!/^https?:\/\//i.test(candidate))
205
+ return null;
206
+ return candidate;
207
+ }
208
+ // Test-only exports (not part of the public API; may change without notice).
209
+ export const __test__ = {
210
+ probeRemoteMedia,
211
+ downloadCappedBytes,
212
+ downloadToFile,
213
+ normalizeHeaderType,
214
+ parseContentLength,
215
+ filenameFromUrl,
216
+ looksLikeBlockedHtml,
217
+ extractItemDurationSeconds,
218
+ extractEnclosureForEpisode,
219
+ resolvePodcastFeedUrlFromItunesSearch,
220
+ formatBytes,
221
+ };
222
+ //# sourceMappingURL=podcast.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"podcast.js","sourceRoot":"","sources":["../../../../../src/content/transcript/providers/podcast.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAA;AAErE,OAAO,EACL,oCAAoC,EACpC,oCAAoC,GACrC,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,qBAAqB,EAAE,6BAA6B,EAAE,MAAM,wBAAwB,CAAA;AAE7F,OAAO,EAAE,qCAAqC,EAAE,MAAM,qBAAqB,CAAA;AAC3E,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf,WAAW,EACX,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAGhB,kBAAkB,GACnB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AACpE,OAAO,EACL,iBAAiB,EACjB,0BAA0B,EAC1B,wBAAwB,EACxB,0BAA0B,EAC1B,sBAAsB,EACtB,6BAA6B,GAC9B,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAA;A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