@hallelx/youtube-transcript 0.1.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.
- package/LICENSE +25 -0
- package/README.md +270 -0
- package/dist/cli.cjs +1224 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.js +1221 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.cjs +1032 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +344 -0
- package/dist/index.d.ts +344 -0
- package/dist/index.js +987 -0
- package/dist/index.js.map +1 -0
- package/package.json +83 -0
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/settings.ts","../src/errors/index.ts","../src/utils/htmlEntities.ts","../src/transcripts/fetchedTranscript.ts","../src/utils/xml.ts","../src/transcripts/parser.ts","../src/transcripts/transcript.ts","../src/transcripts/transcriptList.ts","../src/transcripts/fetcher.ts","../src/utils/httpClient.ts","../src/api.ts","../src/formatters/base.ts","../src/formatters/jsonFormatter.ts","../src/formatters/prettyPrintFormatter.ts","../src/formatters/textFormatter.ts","../src/formatters/textBasedFormatter.ts","../src/formatters/srtFormatter.ts","../src/formatters/webvttFormatter.ts","../src/formatters/index.ts","../src/proxies/proxyConfig.ts","../src/proxies/genericProxyConfig.ts","../src/proxies/webshareProxyConfig.ts","../src/utils/argv.ts","../src/cli.ts"],"names":[],"mappings":";;AAAO,IAAM,kBAAA,GAAqB,4CAAA;AAC3B,IAAM,0BAAA,GACX,0DAAA;AAEK,IAAM,iBAAA,GAAoB;AAAA,EAC/B,MAAA,EAAQ;AAAA,IACN,UAAA,EAAY,SAAA;AAAA,IACZ,aAAA,EAAe;AAAA;AAEnB,CAAA;AAEO,SAAS,SAAS,OAAA,EAAyB;AAChD,EAAA,OAAO,kBAAA,CAAmB,OAAA,CAAQ,YAAA,EAAc,OAAO,CAAA;AACzD;AAEO,SAAS,gBAAgB,MAAA,EAAwB;AACtD,EAAA,O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AAG;AAEH,IAAI,WAAA,EAAa;AACf,EAAA,KAAK,IAAA,EAAK;AACZ","file":"cli.js","sourcesContent":["export const WATCH_URL_TEMPLATE = 'https://www.youtube.com/watch?v={video_id}';\nexport const INNERTUBE_API_URL_TEMPLATE =\n 'https://www.youtube.com/youtubei/v1/player?key={api_key}';\n\nexport const INNERTUBE_CONTEXT = {\n client: {\n clientName: 'ANDROID',\n clientVersion: '20.10.38',\n },\n} as const;\n\nexport function watchUrl(videoId: string): string {\n return WATCH_URL_TEMPLATE.replace('{video_id}', videoId);\n}\n\nexport function innertubeApiUrl(apiKey: string): string {\n return INNERTUBE_API_URL_TEMPLATE.replace('{api_key}', apiKey);\n}\n","import { watchUrl } from '../settings.js';\n\nexport class YouTubeTranscriptApiException extends Error {\n constructor(message?: string) {\n super(message);\n this.name = new.target.name;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class CookieError extends YouTubeTranscriptApiException {}\n\nexport class CookiePathInvalid extends CookieError {\n constructor(cookiePath: string) {\n super(`Can't load the provided cookie file: ${cookiePath}`);\n }\n}\n\nexport class CookieInvalid extends CookieError {\n constructor(cookiePath: string) {\n super(\n `The cookies provided are not valid (may have expired): ${cookiePath}`,\n );\n }\n}\n\nconst ERROR_MESSAGE_TEMPLATE =\n '\\nCould not retrieve a transcript for the video {video_url}!';\nconst CAUSE_MESSAGE_INTRO = ' This is most likely caused by:\\n\\n{cause}';\nconst GITHUB_REFERRAL =\n '\\n\\nIf you are sure that the described cause is not responsible for this error ' +\n 'and that a transcript should be retrievable, please create an issue at ' +\n 'https://github.com/jdepoix/youtube-transcript-api/issues. ' +\n 'Please add which version of youtube_transcript_api you are using ' +\n 'and provide the information needed to replicate the error. ' +\n 'Also make sure that there are no open issues which already describe your problem!';\n\nexport class CouldNotRetrieveTranscript extends YouTubeTranscriptApiException {\n readonly videoId: string;\n protected static CAUSE_MESSAGE = '';\n\n constructor(videoId: string) {\n super('');\n this.videoId = videoId;\n this.message = this.buildErrorMessage();\n }\n\n protected buildErrorMessage(): string {\n let errorMessage = ERROR_MESSAGE_TEMPLATE.replace(\n '{video_url}',\n watchUrl(this.videoId),\n );\n const cause = this.cause;\n if (cause) {\n errorMessage += CAUSE_MESSAGE_INTRO.replace('{cause}', cause) + GITHUB_REFERRAL;\n }\n return errorMessage;\n }\n\n override get cause(): string {\n return (this.constructor as typeof CouldNotRetrieveTranscript).CAUSE_MESSAGE;\n }\n\n override toString(): string {\n return this.buildErrorMessage();\n }\n}\n\nexport class YouTubeDataUnparsable extends CouldNotRetrieveTranscript {\n protected static override CAUSE_MESSAGE =\n 'The data required to fetch the transcript is not parsable. This should ' +\n 'not happen, please open an issue (make sure to include the video ID)!';\n}\n\nexport class YouTubeRequestFailed extends CouldNotRetrieveTranscript {\n reason: string = '';\n protected static override CAUSE_MESSAGE = 'Request to YouTube failed: {reason}';\n\n constructor(videoId: string, httpError: Error | string) {\n super(videoId);\n this.reason = typeof httpError === 'string' ? httpError : String(httpError);\n this.message = this.buildErrorMessage();\n }\n\n override get cause(): string {\n if (!this.reason) return '';\n return (\n this.constructor as typeof YouTubeRequestFailed\n ).CAUSE_MESSAGE.replace('{reason}', this.reason);\n }\n}\n\nexport class VideoUnplayable extends CouldNotRetrieveTranscript {\n reason: string | null = null;\n subReasons: string[] = [];\n protected static override CAUSE_MESSAGE =\n 'The video is unplayable for the following reason: {reason}';\n protected static SUBREASON_MESSAGE = '\\n\\nAdditional Details:\\n{sub_reasons}';\n\n private _initialized = false;\n\n constructor(videoId: string, reason: string | null, subReasons: string[]) {\n super(videoId);\n this.reason = reason;\n this.subReasons = subReasons;\n this._initialized = true;\n this.message = this.buildErrorMessage();\n }\n\n override get cause(): string {\n if (!this._initialized) return '';\n let reason = this.reason === null ? 'No reason specified!' : this.reason;\n if (this.subReasons.length > 0) {\n const subReasons = this.subReasons.map((s) => ` - ${s}`).join('\\n');\n reason =\n reason +\n VideoUnplayable.SUBREASON_MESSAGE.replace('{sub_reasons}', subReasons);\n }\n return (this.constructor as typeof VideoUnplayable).CAUSE_MESSAGE.replace(\n '{reason}',\n reason,\n );\n }\n}\n\nexport class VideoUnavailable extends CouldNotRetrieveTranscript {\n protected static override CAUSE_MESSAGE = 'The video is no longer available';\n}\n\nexport class InvalidVideoId extends CouldNotRetrieveTranscript {\n protected static override CAUSE_MESSAGE =\n 'You provided an invalid video id. Make sure you are using the video id and NOT the url!\\n\\n' +\n 'Do NOT run: `YouTubeTranscriptApi().fetch(\"https://www.youtube.com/watch?v=1234\")`\\n' +\n 'Instead run: `YouTubeTranscriptApi().fetch(\"1234\")`';\n}\n\nconst REQUEST_BLOCKED_BASE_CAUSE_MESSAGE =\n 'YouTube is blocking requests from your IP. This usually is due to one of the ' +\n 'following reasons:\\n' +\n '- You have done too many requests and your IP has been blocked by YouTube\\n' +\n '- You are doing requests from an IP belonging to a cloud provider (like AWS, ' +\n 'Google Cloud Platform, Azure, etc.). Unfortunately, most IPs from cloud ' +\n 'providers are blocked by YouTube.\\n\\n';\n\nexport class RequestBlocked extends CouldNotRetrieveTranscript {\n protected static override CAUSE_MESSAGE =\n REQUEST_BLOCKED_BASE_CAUSE_MESSAGE +\n 'There are two things you can do to work around this:\\n' +\n '1. Use proxies to hide your IP address, as explained in the \"Working around ' +\n 'IP bans\" section of the README ' +\n '(https://github.com/jdepoix/youtube-transcript-api' +\n '?tab=readme-ov-file' +\n '#working-around-ip-bans-requestblocked-or-ipblocked-exception).\\n' +\n '2. (NOT RECOMMENDED) If you authenticate your requests using cookies, you ' +\n 'will be able to continue doing requests for a while. However, YouTube will ' +\n 'eventually permanently ban the account that you have used to authenticate ' +\n \"with! So only do this if you don't mind your account being banned!\";\n\n protected static WITH_GENERIC_PROXY_CAUSE_MESSAGE =\n 'YouTube is blocking your requests, despite you using proxies. Keep in mind ' +\n 'that a proxy is just a way to hide your real IP behind the IP of that proxy, ' +\n \"but there is no guarantee that the IP of that proxy won't be blocked as \" +\n 'well.\\n\\n' +\n 'The only truly reliable way to prevent IP blocks is rotating through a large ' +\n 'pool of residential IPs, by using a provider like Webshare ' +\n '(https://www.webshare.io/?referral_code=w0xno53eb50g), which provides you ' +\n 'with a pool of >30M residential IPs (make sure to purchase ' +\n '\"Residential\" proxies, NOT \"Proxy Server\" or \"Static Residential\"!).\\n\\n' +\n 'You will find more information on how to easily integrate Webshare here: ' +\n 'https://github.com/jdepoix/youtube-transcript-api' +\n '?tab=readme-ov-file#using-webshare';\n\n protected static WITH_WEBSHARE_PROXY_CAUSE_MESSAGE =\n 'YouTube is blocking your requests, despite you using Webshare proxies. ' +\n 'Please make sure that you have purchased \"Residential\" proxies and ' +\n 'NOT \"Proxy Server\" or \"Static Residential\", as those won\\'t work as ' +\n 'reliably! The free tier also uses \"Proxy Server\" and will NOT work!\\n\\n' +\n 'The only reliable option is using \"Residential\" proxies (not \"Static ' +\n 'Residential\"), as this allows you to rotate through a pool of over 30M IPs, ' +\n \"which means you will always find an IP that hasn't been blocked by YouTube \" +\n 'yet!\\n\\n' +\n 'You can support the development of this open source project by making your ' +\n 'Webshare purchases through this affiliate link: ' +\n 'https://www.webshare.io/?referral_code=w0xno53eb50g \\n\\n' +\n 'Thank you for your support! <3';\n\n private _proxyConfig: { constructor?: { name?: string } } | null = null;\n\n withProxyConfig(proxyConfig: object | null | undefined): this {\n this._proxyConfig =\n (proxyConfig as { constructor?: { name?: string } } | null | undefined) ??\n null;\n this.message = this.buildErrorMessage();\n return this;\n }\n\n override get cause(): string {\n if (this._proxyConfig !== null && this._proxyConfig !== undefined) {\n const name = this._proxyConfig.constructor?.name ?? '';\n if (name === 'WebshareProxyConfig') {\n return RequestBlocked.WITH_WEBSHARE_PROXY_CAUSE_MESSAGE;\n }\n if (name) {\n return RequestBlocked.WITH_GENERIC_PROXY_CAUSE_MESSAGE;\n }\n }\n return (this.constructor as typeof RequestBlocked).CAUSE_MESSAGE;\n }\n}\n\nexport class IpBlocked extends RequestBlocked {\n protected static override CAUSE_MESSAGE =\n REQUEST_BLOCKED_BASE_CAUSE_MESSAGE +\n 'Ways to work around this are explained in the \"Working around IP ' +\n 'bans\" section of the README (https://github.com/jdepoix/youtube-transcript-api' +\n '?tab=readme-ov-file' +\n '#working-around-ip-bans-requestblocked-or-ipblocked-exception).\\n';\n}\n\nexport class TranscriptsDisabled extends CouldNotRetrieveTranscript {\n protected static override CAUSE_MESSAGE = 'Subtitles are disabled for this video';\n}\n\nexport class AgeRestricted extends CouldNotRetrieveTranscript {\n protected static override CAUSE_MESSAGE =\n 'This video is age-restricted. Therefore, you are unable to retrieve ' +\n 'transcripts for it without authenticating yourself.\\n\\n' +\n 'Unfortunately, Cookie Authentication is temporarily unsupported in ' +\n \"youtube-transcript-api, as recent changes in YouTube's API broke the previous \" +\n 'implementation. I will do my best to re-implement it as soon as possible.';\n}\n\nexport class NotTranslatable extends CouldNotRetrieveTranscript {\n protected static override CAUSE_MESSAGE =\n 'The requested language is not translatable';\n}\n\nexport class TranslationLanguageNotAvailable extends CouldNotRetrieveTranscript {\n protected static override CAUSE_MESSAGE =\n 'The requested translation language is not available';\n}\n\nexport class FailedToCreateConsentCookie extends CouldNotRetrieveTranscript {\n protected static override CAUSE_MESSAGE =\n 'Failed to automatically give consent to saving cookies';\n}\n\nexport class NoTranscriptFound extends CouldNotRetrieveTranscript {\n private _requestedLanguageCodes: readonly string[] = [];\n private _transcriptData: { toString(): string } = { toString: () => '' };\n private _initialized = false;\n protected static override CAUSE_MESSAGE =\n 'No transcripts were found for any of the requested language codes: {requested_language_codes}\\n\\n' +\n '{transcript_data}';\n\n constructor(\n videoId: string,\n requestedLanguageCodes: Iterable<string>,\n transcriptData: { toString(): string },\n ) {\n super(videoId);\n this._requestedLanguageCodes = Array.from(requestedLanguageCodes);\n this._transcriptData = transcriptData;\n this._initialized = true;\n this.message = this.buildErrorMessage();\n }\n\n override get cause(): string {\n if (!this._initialized) return '';\n const langs = `[${this._requestedLanguageCodes\n .map((c) => `'${c}'`)\n .join(', ')}]`;\n return (this.constructor as typeof NoTranscriptFound).CAUSE_MESSAGE.replace(\n '{requested_language_codes}',\n langs,\n ).replace('{transcript_data}', String(this._transcriptData));\n }\n}\n\nexport class PoTokenRequired extends CouldNotRetrieveTranscript {\n protected static override CAUSE_MESSAGE =\n 'The requested video cannot be retrieved without a PO Token. If this happens, ' +\n 'please open a GitHub issue!';\n}\n","const NAMED: Record<string, string> = {\n amp: '&',\n lt: '<',\n gt: '>',\n quot: '\"',\n apos: \"'\",\n nbsp: '\\u00a0',\n};\n\nexport function decodeHtmlEntities(input: string): string {\n if (!input) return input;\n return input.replace(/&(#x[0-9a-fA-F]+|#[0-9]+|[a-zA-Z][a-zA-Z0-9]+);/g, (match, body: string) => {\n if (body.startsWith('#x') || body.startsWith('#X')) {\n const code = Number.parseInt(body.slice(2), 16);\n if (Number.isFinite(code) && code >= 0 && code <= 0x10ffff) {\n try {\n return String.fromCodePoint(code);\n } catch {\n return match;\n }\n }\n return match;\n }\n if (body.startsWith('#')) {\n const code = Number.parseInt(body.slice(1), 10);\n if (Number.isFinite(code) && code >= 0 && code <= 0x10ffff) {\n try {\n return String.fromCodePoint(code);\n } catch {\n return match;\n }\n }\n return match;\n }\n const named = NAMED[body];\n return named ?? match;\n });\n}\n","export interface FetchedTranscriptSnippet {\n text: string;\n start: number;\n duration: number;\n}\n\nexport interface FetchedTranscriptInit {\n snippets: FetchedTranscriptSnippet[];\n videoId: string;\n language: string;\n languageCode: string;\n isGenerated: boolean;\n}\n\nexport class FetchedTranscript {\n readonly snippets: FetchedTranscriptSnippet[];\n readonly videoId: string;\n readonly language: string;\n readonly languageCode: string;\n readonly isGenerated: boolean;\n\n constructor(init: FetchedTranscriptInit) {\n this.snippets = init.snippets;\n this.videoId = init.videoId;\n this.language = init.language;\n this.languageCode = init.languageCode;\n this.isGenerated = init.isGenerated;\n }\n\n [Symbol.iterator](): IterableIterator<FetchedTranscriptSnippet> {\n return this.snippets[Symbol.iterator]();\n }\n\n get length(): number {\n return this.snippets.length;\n }\n\n toRawData(): Array<{ text: string; start: number; duration: number }> {\n return this.snippets.map((s) => ({\n text: s.text,\n start: s.start,\n duration: s.duration,\n }));\n }\n}\n","export interface RawTranscriptElement {\n text: string;\n attrs: Record<string, string>;\n}\n\nconst TEXT_ELEMENT_REGEX = /<text\\b([^>]*)>([\\s\\S]*?)<\\/text>/g;\nconst ATTR_REGEX = /([a-zA-Z_:][\\w:.-]*)\\s*=\\s*\"([^\"]*)\"/g;\n\nexport function parseTranscriptXml(raw: string): RawTranscriptElement[] {\n const out: RawTranscriptElement[] = [];\n TEXT_ELEMENT_REGEX.lastIndex = 0;\n let match: RegExpExecArray | null;\n while ((match = TEXT_ELEMENT_REGEX.exec(raw)) !== null) {\n const attrString = match[1] ?? '';\n const innerText = match[2] ?? '';\n const attrs: Record<string, string> = {};\n ATTR_REGEX.lastIndex = 0;\n let attrMatch: RegExpExecArray | null;\n while ((attrMatch = ATTR_REGEX.exec(attrString)) !== null) {\n const key = attrMatch[1];\n const value = attrMatch[2];\n if (key !== undefined && value !== undefined) {\n attrs[key] = value;\n }\n }\n out.push({ text: innerText, attrs });\n }\n return out;\n}\n","import { decodeHtmlEntities } from '../utils/htmlEntities.js';\nimport { parseTranscriptXml } from '../utils/xml.js';\nimport type { FetchedTranscriptSnippet } from './fetchedTranscript.js';\n\nconst FORMATTING_TAGS = [\n 'strong',\n 'em',\n 'b',\n 'i',\n 'mark',\n 'small',\n 'del',\n 'ins',\n 'sub',\n 'sup',\n];\n\nconst STRIP_ALL_REGEX = /<[^>]*>/gi;\n\nfunction buildPreserveRegex(): RegExp {\n const formats = FORMATTING_TAGS.join('|');\n return new RegExp(`<\\\\/?(?!\\\\/?(${formats})\\\\b).*?\\\\b>`, 'gi');\n}\n\nexport class TranscriptParser {\n private readonly _htmlRegex: RegExp;\n\n constructor(preserveFormatting: boolean = false) {\n this._htmlRegex = preserveFormatting ? buildPreserveRegex() : STRIP_ALL_REGEX;\n }\n\n parse(rawData: string): FetchedTranscriptSnippet[] {\n const elements = parseTranscriptXml(rawData);\n const out: FetchedTranscriptSnippet[] = [];\n for (const el of elements) {\n // Skip empty <text></text> elements (matches Python ElementTree behaviour\n // where xml_element.text is None for empty elements).\n if (el.text === '') continue;\n // Two decoding passes to mirror Python: defusedxml.ElementTree decodes\n // XML entities once when parsing, then html.unescape decodes the inner\n // HTML entities. YouTube double-escapes content (e.g. \"&#39;\" for an\n // apostrophe), so a single pass would leave \"'\" in the output.\n const xmlDecoded = decodeHtmlEntities(el.text);\n const htmlDecoded = decodeHtmlEntities(xmlDecoded);\n // Reset lastIndex because we share a global regex across calls.\n this._htmlRegex.lastIndex = 0;\n const stripped = htmlDecoded.replace(this._htmlRegex, '');\n const startAttr = el.attrs['start'] ?? '0';\n const durAttr = el.attrs['dur'] ?? '0.0';\n out.push({\n text: stripped,\n start: Number.parseFloat(startAttr),\n duration: Number.parseFloat(durAttr),\n });\n }\n return out;\n }\n}\n","import { NotTranslatable, PoTokenRequired, TranslationLanguageNotAvailable, YouTubeRequestFailed, IpBlocked } from '../errors/index.js';\nimport type { HttpClient } from '../utils/httpClient.js';\nimport { FetchedTranscript, type FetchedTranscriptSnippet } from './fetchedTranscript.js';\nimport { TranscriptParser } from './parser.js';\n\nexport interface TranslationLanguage {\n language: string;\n languageCode: string;\n}\n\nexport interface TranscriptFetchOptions {\n preserveFormatting?: boolean;\n}\n\nexport class Transcript {\n readonly videoId: string;\n readonly language: string;\n readonly languageCode: string;\n readonly isGenerated: boolean;\n readonly translationLanguages: readonly TranslationLanguage[];\n\n private readonly _httpClient: HttpClient;\n private readonly _url: string;\n private readonly _translationLanguagesByCode: Map<string, string>;\n\n constructor(\n httpClient: HttpClient,\n videoId: string,\n url: string,\n language: string,\n languageCode: string,\n isGenerated: boolean,\n translationLanguages: readonly TranslationLanguage[],\n ) {\n this._httpClient = httpClient;\n this.videoId = videoId;\n this._url = url;\n this.language = language;\n this.languageCode = languageCode;\n this.isGenerated = isGenerated;\n this.translationLanguages = translationLanguages;\n this._translationLanguagesByCode = new Map(\n translationLanguages.map((tl) => [tl.languageCode, tl.language]),\n );\n }\n\n get isTranslatable(): boolean {\n return this.translationLanguages.length > 0;\n }\n\n async fetch(options: TranscriptFetchOptions = {}): Promise<FetchedTranscript> {\n if (this._url.includes('&exp=xpe')) {\n throw new PoTokenRequired(this.videoId);\n }\n const response = await this._httpClient.get(this._url);\n if (response.status === 429) {\n throw new IpBlocked(this.videoId);\n }\n if (!response.ok) {\n throw new YouTubeRequestFailed(\n this.videoId,\n `${response.status} ${response.statusText}`,\n );\n }\n const xml = await response.text();\n const parser = new TranscriptParser(options.preserveFormatting ?? false);\n const snippets: FetchedTranscriptSnippet[] = parser.parse(xml);\n return new FetchedTranscript({\n snippets,\n videoId: this.videoId,\n language: this.language,\n languageCode: this.languageCode,\n isGenerated: this.isGenerated,\n });\n }\n\n translate(languageCode: string): Transcript {\n if (!this.isTranslatable) {\n throw new NotTranslatable(this.videoId);\n }\n const targetLanguage = this._translationLanguagesByCode.get(languageCode);\n if (targetLanguage === undefined) {\n throw new TranslationLanguageNotAvailable(this.videoId);\n }\n return new Transcript(\n this._httpClient,\n this.videoId,\n `${this._url}&tlang=${languageCode}`,\n targetLanguage,\n languageCode,\n true,\n [],\n );\n }\n\n toString(): string {\n return `${this.languageCode} (\"${this.language}\")${\n this.isTranslatable ? '[TRANSLATABLE]' : ''\n }`;\n }\n}\n","import { NoTranscriptFound } from '../errors/index.js';\nimport type { HttpClient } from '../utils/httpClient.js';\nimport { Transcript, type TranslationLanguage } from './transcript.js';\n\ninterface RawCaptionTrack {\n baseUrl: string;\n name: { runs: Array<{ text: string }> };\n languageCode: string;\n isTranslatable?: boolean;\n kind?: string;\n}\n\ninterface RawTranslationLanguage {\n languageCode: string;\n languageName: { runs: Array<{ text: string }> };\n}\n\nexport interface CaptionsJson {\n captionTracks: RawCaptionTrack[];\n translationLanguages?: RawTranslationLanguage[];\n}\n\nexport class TranscriptList implements Iterable<Transcript> {\n readonly videoId: string;\n private readonly _manuallyCreated: Map<string, Transcript>;\n private readonly _generated: Map<string, Transcript>;\n private readonly _translationLanguages: readonly TranslationLanguage[];\n\n constructor(\n videoId: string,\n manuallyCreated: Map<string, Transcript>,\n generated: Map<string, Transcript>,\n translationLanguages: readonly TranslationLanguage[],\n ) {\n this.videoId = videoId;\n this._manuallyCreated = manuallyCreated;\n this._generated = generated;\n this._translationLanguages = translationLanguages;\n }\n\n static build(\n httpClient: HttpClient,\n videoId: string,\n captionsJson: CaptionsJson,\n ): TranscriptList {\n const translationLanguages: TranslationLanguage[] = (\n captionsJson.translationLanguages ?? []\n ).map((tl) => ({\n language: tl.languageName.runs[0]?.text ?? '',\n languageCode: tl.languageCode,\n }));\n\n const manuallyCreated = new Map<string, Transcript>();\n const generated = new Map<string, Transcript>();\n\n for (const caption of captionsJson.captionTracks) {\n const isAsr = caption.kind === 'asr';\n const target = isAsr ? generated : manuallyCreated;\n const cleanedUrl = caption.baseUrl.replace('&fmt=srv3', '');\n const transcriptTranslationLangs = caption.isTranslatable\n ? translationLanguages\n : [];\n target.set(\n caption.languageCode,\n new Transcript(\n httpClient,\n videoId,\n cleanedUrl,\n caption.name.runs[0]?.text ?? '',\n caption.languageCode,\n isAsr,\n transcriptTranslationLangs,\n ),\n );\n }\n\n return new TranscriptList(\n videoId,\n manuallyCreated,\n generated,\n translationLanguages,\n );\n }\n\n *[Symbol.iterator](): IterableIterator<Transcript> {\n for (const t of this._manuallyCreated.values()) yield t;\n for (const t of this._generated.values()) yield t;\n }\n\n findTranscript(languageCodes: Iterable<string>): Transcript {\n return this._findTranscript(languageCodes, [\n this._manuallyCreated,\n this._generated,\n ]);\n }\n\n findGeneratedTranscript(languageCodes: Iterable<string>): Transcript {\n return this._findTranscript(languageCodes, [this._generated]);\n }\n\n findManuallyCreatedTranscript(languageCodes: Iterable<string>): Transcript {\n return this._findTranscript(languageCodes, [this._manuallyCreated]);\n }\n\n private _findTranscript(\n languageCodes: Iterable<string>,\n transcriptDicts: ReadonlyArray<Map<string, Transcript>>,\n ): Transcript {\n const codes = Array.from(languageCodes);\n for (const code of codes) {\n for (const dict of transcriptDicts) {\n const found = dict.get(code);\n if (found !== undefined) return found;\n }\n }\n throw new NoTranscriptFound(this.videoId, codes, this);\n }\n\n toString(): string {\n const describe = (lines: string[]): string =>\n lines.length === 0 ? 'None' : lines.map((l) => ` - ${l}`).join('\\n');\n\n const manuallyCreated = describe(\n Array.from(this._manuallyCreated.values()).map((t) => t.toString()),\n );\n const generated = describe(\n Array.from(this._generated.values()).map((t) => t.toString()),\n );\n const translations = describe(\n this._translationLanguages.map(\n (tl) => `${tl.languageCode} (\"${tl.language}\")`,\n ),\n );\n\n return (\n `For this video (${this.videoId}) transcripts are available in the following languages:\\n\\n` +\n `(MANUALLY CREATED)\\n${manuallyCreated}\\n\\n` +\n `(GENERATED)\\n${generated}\\n\\n` +\n `(TRANSLATION LANGUAGES)\\n${translations}`\n );\n }\n}\n","import {\n AgeRestricted,\n FailedToCreateConsentCookie,\n InvalidVideoId,\n IpBlocked,\n RequestBlocked,\n TranscriptsDisabled,\n VideoUnavailable,\n VideoUnplayable,\n YouTubeDataUnparsable,\n YouTubeRequestFailed,\n} from '../errors/index.js';\nimport type { ProxyConfig } from '../proxies/proxyConfig.js';\nimport { innertubeApiUrl, INNERTUBE_CONTEXT, watchUrl } from '../settings.js';\nimport { decodeHtmlEntities } from '../utils/htmlEntities.js';\nimport type { HttpClient } from '../utils/httpClient.js';\nimport { TranscriptList, type CaptionsJson } from './transcriptList.js';\n\nconst PLAYABILITY_STATUS_OK = 'OK';\nconst PLAYABILITY_STATUS_ERROR = 'ERROR';\nconst PLAYABILITY_STATUS_LOGIN_REQUIRED = 'LOGIN_REQUIRED';\n\n// NOTE: byte-identical to Python source — uses U+2019 right single quotation mark.\nconst REASON_BOT_DETECTED = 'Sign in to confirm you\\u2019re not a bot';\nconst REASON_AGE_RESTRICTED = 'This video may be inappropriate for some users.';\nconst REASON_VIDEO_UNAVAILABLE = 'This video is unavailable';\n\nconst INNERTUBE_API_KEY_REGEX = /\"INNERTUBE_API_KEY\":\\s*\"([a-zA-Z0-9_-]+)\"/;\nconst CONSENT_COOKIE_REGEX = /name=\"v\" value=\"(.*?)\"/;\nconst CONSENT_FORM_MARKER = 'action=\"https://consent.youtube.com/s\"';\nconst RECAPTCHA_MARKER = 'class=\"g-recaptcha\"';\n\ninterface PlayabilityStatusData {\n status?: string;\n reason?: string;\n errorScreen?: {\n playerErrorMessageRenderer?: {\n subreason?: {\n runs?: Array<{ text?: string }>;\n };\n };\n };\n}\n\ninterface InnertubeData {\n playabilityStatus?: PlayabilityStatusData;\n captions?: {\n playerCaptionsTracklistRenderer?: CaptionsJson;\n };\n}\n\nasync function raiseHttpErrors(\n response: Response,\n videoId: string,\n): Promise<Response> {\n if (response.status === 429) {\n throw new IpBlocked(videoId);\n }\n if (!response.ok) {\n throw new YouTubeRequestFailed(\n videoId,\n `${response.status} ${response.statusText || 'HTTP error'}`,\n );\n }\n return response;\n}\n\nexport class TranscriptListFetcher {\n private readonly _httpClient: HttpClient;\n private readonly _proxyConfig: ProxyConfig | undefined;\n\n constructor(httpClient: HttpClient, proxyConfig: ProxyConfig | undefined) {\n this._httpClient = httpClient;\n this._proxyConfig = proxyConfig;\n }\n\n async fetch(videoId: string): Promise<TranscriptList> {\n const captionsJson = await this._fetchCaptionsJson(videoId, 0);\n return TranscriptList.build(this._httpClient, videoId, captionsJson);\n }\n\n private async _fetchCaptionsJson(\n videoId: string,\n tryNumber: number,\n ): Promise<CaptionsJson> {\n try {\n const html = await this._fetchVideoHtml(videoId);\n const apiKey = this._extractInnertubeApiKey(html, videoId);\n const innertubeData = await this._fetchInnertubeData(videoId, apiKey);\n return this._extractCaptionsJson(innertubeData, videoId);\n } catch (err) {\n if (err instanceof RequestBlocked) {\n const retries = this._proxyConfig?.retriesWhenBlocked ?? 0;\n if (tryNumber + 1 < retries) {\n return this._fetchCaptionsJson(videoId, tryNumber + 1);\n }\n throw err.withProxyConfig(this._proxyConfig ?? null);\n }\n throw err;\n }\n }\n\n private _extractInnertubeApiKey(html: string, videoId: string): string {\n const match = INNERTUBE_API_KEY_REGEX.exec(html);\n if (match && match[1]) {\n return match[1];\n }\n if (html.includes(RECAPTCHA_MARKER)) {\n throw new IpBlocked(videoId);\n }\n throw new YouTubeDataUnparsable(videoId);\n }\n\n private _extractCaptionsJson(\n innertubeData: InnertubeData,\n videoId: string,\n ): CaptionsJson {\n this._assertPlayability(innertubeData.playabilityStatus, videoId);\n const captionsJson =\n innertubeData.captions?.playerCaptionsTracklistRenderer;\n if (!captionsJson || !captionsJson.captionTracks) {\n throw new TranscriptsDisabled(videoId);\n }\n return captionsJson;\n }\n\n private _assertPlayability(\n playabilityStatusData: PlayabilityStatusData | undefined,\n videoId: string,\n ): void {\n if (!playabilityStatusData) return;\n const status = playabilityStatusData.status;\n if (!status || status === PLAYABILITY_STATUS_OK) return;\n const reason = playabilityStatusData.reason;\n if (status === PLAYABILITY_STATUS_LOGIN_REQUIRED) {\n if (reason === REASON_BOT_DETECTED) {\n throw new RequestBlocked(videoId);\n }\n if (reason === REASON_AGE_RESTRICTED) {\n throw new AgeRestricted(videoId);\n }\n }\n if (\n status === PLAYABILITY_STATUS_ERROR &&\n reason === REASON_VIDEO_UNAVAILABLE\n ) {\n if (videoId.startsWith('http://') || videoId.startsWith('https://')) {\n throw new InvalidVideoId(videoId);\n }\n throw new VideoUnavailable(videoId);\n }\n const subreasons =\n playabilityStatusData.errorScreen?.playerErrorMessageRenderer?.subreason\n ?.runs ?? [];\n throw new VideoUnplayable(\n videoId,\n reason ?? null,\n subreasons.map((r) => r.text ?? ''),\n );\n }\n\n private _createConsentCookie(html: string, videoId: string): void {\n const match = CONSENT_COOKIE_REGEX.exec(html);\n if (!match || !match[1]) {\n throw new FailedToCreateConsentCookie(videoId);\n }\n this._httpClient.setCookie('CONSENT', `YES+${match[1]}`, '.youtube.com');\n }\n\n private async _fetchVideoHtml(videoId: string): Promise<string> {\n let html = await this._fetchHtml(videoId);\n if (html.includes(CONSENT_FORM_MARKER)) {\n this._createConsentCookie(html, videoId);\n html = await this._fetchHtml(videoId);\n if (html.includes(CONSENT_FORM_MARKER)) {\n throw new FailedToCreateConsentCookie(videoId);\n }\n }\n return html;\n }\n\n private async _fetchHtml(videoId: string): Promise<string> {\n const response = await this._httpClient.get(watchUrl(videoId));\n const checked = await raiseHttpErrors(response, videoId);\n const text = await checked.text();\n return decodeHtmlEntities(text);\n }\n\n private async _fetchInnertubeData(\n videoId: string,\n apiKey: string,\n ): Promise<InnertubeData> {\n const response = await this._httpClient.post(innertubeApiUrl(apiKey), {\n context: INNERTUBE_CONTEXT,\n videoId,\n });\n const checked = await raiseHttpErrors(response, videoId);\n return (await checked.json()) as InnertubeData;\n }\n}\n","import type { ProxyConfig } from '../proxies/proxyConfig.js';\n\nexport type FetchFn = typeof fetch;\n\nexport interface HttpClientOptions {\n proxyConfig?: ProxyConfig;\n fetchFn?: FetchFn;\n}\n\nfunction isBun(): boolean {\n return typeof (globalThis as { Bun?: unknown }).Bun !== 'undefined';\n}\n\nfunction isDeno(): boolean {\n return typeof (globalThis as { Deno?: unknown }).Deno !== 'undefined';\n}\n\ninterface CookieJar {\n // domain (with or without leading dot) -> name -> value\n get(host: string): string | undefined;\n set(name: string, value: string, domain: string): void;\n}\n\nfunction createCookieJar(): CookieJar {\n const store = new Map<string, Map<string, string>>();\n return {\n set(name, value, domain) {\n const key = domain.startsWith('.') ? domain : `.${domain}`;\n let inner = store.get(key);\n if (!inner) {\n inner = new Map();\n store.set(key, inner);\n }\n inner.set(name, value);\n },\n get(host) {\n // Suffix-match host against each stored domain.\n const parts: string[] = [];\n for (const [domain, cookies] of store) {\n const bare = domain.startsWith('.') ? domain.slice(1) : domain;\n if (host === bare || host.endsWith(`.${bare}`)) {\n for (const [name, value] of cookies) {\n parts.push(`${name}=${value}`);\n }\n }\n }\n return parts.length > 0 ? parts.join('; ') : undefined;\n },\n };\n}\n\nexport class HttpClient {\n private readonly _proxyConfig?: ProxyConfig;\n private readonly _userFetch?: FetchFn;\n private readonly _cookies = createCookieJar();\n private _undiciDispatcher: unknown = null;\n private _undiciLoaded = false;\n\n constructor(options: HttpClientOptions = {}) {\n this._proxyConfig = options.proxyConfig;\n this._userFetch = options.fetchFn;\n if (this._proxyConfig && !this._userFetch && isDeno()) {\n throw new Error(\n 'Proxy support on Deno requires a custom fetchFn. Pass `fetchFn` ' +\n 'configured with `Deno.createHttpClient` to YouTubeTranscriptApi.',\n );\n }\n }\n\n setCookie(name: string, value: string, domain: string): void {\n this._cookies.set(name, value, domain);\n }\n\n async get(url: string): Promise<Response> {\n return this._fetch(url, { method: 'GET' });\n }\n\n async post(url: string, jsonBody: unknown): Promise<Response> {\n return this._fetch(url, {\n method: 'POST',\n body: JSON.stringify(jsonBody),\n headers: { 'Content-Type': 'application/json' },\n });\n }\n\n private async _fetch(url: string, init: RequestInit): Promise<Response> {\n const headers = new Headers(init.headers);\n if (!headers.has('Accept-Language')) {\n headers.set('Accept-Language', 'en-US');\n }\n if (this._proxyConfig?.preventKeepingConnectionsAlive) {\n headers.set('Connection', 'close');\n }\n let host: string;\n try {\n host = new URL(url).host;\n } catch {\n host = '';\n }\n if (host) {\n const cookieHeader = this._cookies.get(host);\n if (cookieHeader) {\n headers.set('Cookie', cookieHeader);\n }\n }\n\n const finalInit: RequestInit = { ...init, headers };\n\n if (this._userFetch) {\n return this._userFetch(url, finalInit);\n }\n\n if (this._proxyConfig) {\n const proxyUrl = url.startsWith('https:')\n ? this._proxyConfig.httpsUrl\n : this._proxyConfig.httpUrl;\n if (proxyUrl) {\n if (isBun()) {\n const bunRef = (globalThis as { Bun?: { fetch: FetchFn } }).Bun;\n if (bunRef) {\n return bunRef.fetch(url, {\n ...finalInit,\n // Bun-specific option\n proxy: proxyUrl,\n } as RequestInit & { proxy: string });\n }\n }\n // Node path: lazy-load undici and create a ProxyAgent dispatcher.\n const dispatcher = await this._getUndiciDispatcher(proxyUrl);\n return fetch(url, {\n ...finalInit,\n dispatcher,\n } as RequestInit & { dispatcher: unknown });\n }\n }\n\n return fetch(url, finalInit);\n }\n\n private async _getUndiciDispatcher(proxyUrl: string): Promise<unknown> {\n if (this._undiciLoaded && this._undiciDispatcher) {\n return this._undiciDispatcher;\n }\n try {\n const undici = (await import('undici')) as {\n ProxyAgent: new (options: { uri: string }) => unknown;\n };\n this._undiciDispatcher = new undici.ProxyAgent({ uri: proxyUrl });\n this._undiciLoaded = true;\n return this._undiciDispatcher;\n } catch (err) {\n throw new Error(\n 'Proxy support on Node.js requires the optional peer dependency ' +\n '`undici`. Install it with `npm install undici`, or pass a custom ' +\n '`fetchFn` to YouTubeTranscriptApi. Original error: ' +\n String(err),\n );\n }\n }\n}\n\n// Re-export so that downstream code does not import the type-only `Bun`/`Deno`\n// stubs from this file.\nexport { isBun as _isBun, isDeno as _isDeno };\n","import type { ProxyConfig } from './proxies/proxyConfig.js';\nimport type { FetchedTranscript } from './transcripts/fetchedTranscript.js';\nimport { TranscriptListFetcher } from './transcripts/fetcher.js';\nimport type { TranscriptList } from './transcripts/transcriptList.js';\nimport { HttpClient, type FetchFn } from './utils/httpClient.js';\n\nexport interface YouTubeTranscriptApiOptions {\n proxyConfig?: ProxyConfig;\n fetchFn?: FetchFn;\n}\n\nexport interface FetchOptions {\n languages?: Iterable<string>;\n preserveFormatting?: boolean;\n}\n\nexport class YouTubeTranscriptApi {\n private readonly _httpClient: HttpClient;\n private readonly _fetcher: TranscriptListFetcher;\n\n constructor(options: YouTubeTranscriptApiOptions = {}) {\n this._httpClient = new HttpClient(options);\n this._fetcher = new TranscriptListFetcher(this._httpClient, options.proxyConfig);\n }\n\n async list(videoId: string): Promise<TranscriptList> {\n return this._fetcher.fetch(videoId);\n }\n\n async fetch(\n videoId: string,\n options: FetchOptions = {},\n ): Promise<FetchedTranscript> {\n const languages = Array.from(options.languages ?? ['en']);\n const transcriptList = await this.list(videoId);\n const transcript = transcriptList.findTranscript(languages);\n return transcript.fetch({\n preserveFormatting: options.preserveFormatting ?? false,\n });\n }\n}\n","import type { FetchedTranscript } from '../transcripts/fetchedTranscript.js';\n\nexport abstract class Formatter {\n abstract formatTranscript(\n transcript: FetchedTranscript,\n options?: Record<string, unknown>,\n ): string;\n\n abstract formatTranscripts(\n transcripts: FetchedTranscript[],\n options?: Record<string, unknown>,\n ): string;\n}\n","import type { FetchedTranscript } from '../transcripts/fetchedTranscript.js';\nimport { Formatter } from './base.js';\n\nexport interface JsonFormatterOptions {\n indent?: number | string;\n}\n\nexport class JSONFormatter extends Formatter {\n override formatTranscript(\n transcript: FetchedTranscript,\n options: JsonFormatterOptions = {},\n ): string {\n return JSON.stringify(transcript.toRawData(), null, options.indent);\n }\n\n override formatTranscripts(\n transcripts: FetchedTranscript[],\n options: JsonFormatterOptions = {},\n ): string {\n return JSON.stringify(\n transcripts.map((t) => t.toRawData()),\n null,\n options.indent,\n );\n }\n}\n","import type { FetchedTranscript } from '../transcripts/fetchedTranscript.js';\nimport { Formatter } from './base.js';\n\n/**\n * Pretty-prints a transcript using JSON.stringify with two-space indentation.\n *\n * Note: this differs from the Python upstream, which uses Python's `pprint`\n * module (producing Python-repr style output). The TypeScript port uses\n * indented JSON for the same human-readable purpose.\n */\nexport class PrettyPrintFormatter extends Formatter {\n override formatTranscript(transcript: FetchedTranscript): string {\n return JSON.stringify(transcript.toRawData(), null, 2);\n }\n\n override formatTranscripts(transcripts: FetchedTranscript[]): string {\n return JSON.stringify(\n transcripts.map((t) => t.toRawData()),\n null,\n 2,\n );\n }\n}\n","import type { FetchedTranscript } from '../transcripts/fetchedTranscript.js';\nimport { Formatter } from './base.js';\n\nexport class TextFormatter extends Formatter {\n override formatTranscript(transcript: FetchedTranscript): string {\n return transcript.snippets.map((s) => s.text).join('\\n');\n }\n\n override formatTranscripts(transcripts: FetchedTranscript[]): string {\n return transcripts.map((t) => this.formatTranscript(t)).join('\\n\\n\\n');\n }\n}\n","import type {\n FetchedTranscript,\n FetchedTranscriptSnippet,\n} from '../transcripts/fetchedTranscript.js';\nimport { TextFormatter } from './textFormatter.js';\n\nexport abstract class TextBasedFormatter extends TextFormatter {\n protected abstract _formatTimestamp(\n hours: number,\n mins: number,\n secs: number,\n ms: number,\n ): string;\n\n protected abstract _formatTranscriptHeader(lines: string[]): string;\n\n protected abstract _formatTranscriptHelper(\n i: number,\n timeText: string,\n snippet: FetchedTranscriptSnippet,\n ): string;\n\n protected _secondsToTimestamp(time: number): string {\n const t = Number(time);\n const totalSecs = Math.floor(t);\n const hours = Math.floor(totalSecs / 3600);\n const mins = Math.floor((totalSecs - hours * 3600) / 60);\n const secs = totalSecs - hours * 3600 - mins * 60;\n const ms = Math.round((t - totalSecs) * 1000);\n return this._formatTimestamp(hours, mins, secs, ms);\n }\n\n override formatTranscript(transcript: FetchedTranscript): string {\n const lines: string[] = [];\n const snippets = transcript.snippets;\n for (let i = 0; i < snippets.length; i++) {\n const line = snippets[i]!;\n const end = line.start + line.duration;\n const next = snippets[i + 1];\n const endTime =\n next !== undefined && next.start < end ? next.start : end;\n const timeText = `${this._secondsToTimestamp(line.start)} --> ${this._secondsToTimestamp(endTime)}`;\n lines.push(this._formatTranscriptHelper(i, timeText, line));\n }\n return this._formatTranscriptHeader(lines);\n }\n}\n\nfunction pad(value: number, width: number): string {\n return String(value).padStart(width, '0');\n}\n\nexport { pad as _pad };\n","import type { FetchedTranscriptSnippet } from '../transcripts/fetchedTranscript.js';\nimport { _pad, TextBasedFormatter } from './textBasedFormatter.js';\n\nexport class SRTFormatter extends TextBasedFormatter {\n protected override _formatTimestamp(\n hours: number,\n mins: number,\n secs: number,\n ms: number,\n ): string {\n return `${_pad(hours, 2)}:${_pad(mins, 2)}:${_pad(secs, 2)},${_pad(ms, 3)}`;\n }\n\n protected override _formatTranscriptHeader(lines: string[]): string {\n return lines.join('\\n\\n') + '\\n';\n }\n\n protected override _formatTranscriptHelper(\n i: number,\n timeText: string,\n snippet: FetchedTranscriptSnippet,\n ): string {\n return `${i + 1}\\n${timeText}\\n${snippet.text}`;\n }\n}\n","import type { FetchedTranscriptSnippet } from '../transcripts/fetchedTranscript.js';\nimport { _pad, TextBasedFormatter } from './textBasedFormatter.js';\n\nexport class WebVTTFormatter extends TextBasedFormatter {\n protected override _formatTimestamp(\n hours: number,\n mins: number,\n secs: number,\n ms: number,\n ): string {\n return `${_pad(hours, 2)}:${_pad(mins, 2)}:${_pad(secs, 2)}.${_pad(ms, 3)}`;\n }\n\n protected override _formatTranscriptHeader(lines: string[]): string {\n return 'WEBVTT\\n\\n' + lines.join('\\n\\n') + '\\n';\n }\n\n protected override _formatTranscriptHelper(\n _i: number,\n timeText: string,\n snippet: FetchedTranscriptSnippet,\n ): string {\n return `${timeText}\\n${snippet.text}`;\n }\n}\n","import type { Formatter } from './base.js';\nimport { JSONFormatter } from './jsonFormatter.js';\nimport { PrettyPrintFormatter } from './prettyPrintFormatter.js';\nimport { SRTFormatter } from './srtFormatter.js';\nimport { TextFormatter } from './textFormatter.js';\nimport { WebVTTFormatter } from './webvttFormatter.js';\n\nexport { Formatter } from './base.js';\nexport { JSONFormatter, type JsonFormatterOptions } from './jsonFormatter.js';\nexport { PrettyPrintFormatter } from './prettyPrintFormatter.js';\nexport { SRTFormatter } from './srtFormatter.js';\nexport { TextFormatter } from './textFormatter.js';\nexport { WebVTTFormatter } from './webvttFormatter.js';\nexport { TextBasedFormatter } from './textBasedFormatter.js';\n\nexport type FormatterType = 'json' | 'pretty' | 'text' | 'webvtt' | 'srt';\n\nconst TYPES: Record<FormatterType, new () => Formatter> = {\n json: JSONFormatter,\n pretty: PrettyPrintFormatter,\n text: TextFormatter,\n webvtt: WebVTTFormatter,\n srt: SRTFormatter,\n};\n\nexport class UnknownFormatterType extends Error {\n constructor(formatterType: string) {\n super(\n `The format '${formatterType}' is not supported. ` +\n `Choose one of the following formats: ${Object.keys(TYPES).join(', ')}`,\n );\n this.name = 'UnknownFormatterType';\n }\n}\n\nexport class FormatterLoader {\n static readonly TYPES = TYPES;\n\n load(formatterType: FormatterType | string = 'pretty'): Formatter {\n if (!(formatterType in TYPES)) {\n throw new UnknownFormatterType(formatterType);\n }\n const Cls = TYPES[formatterType as FormatterType];\n return new Cls();\n }\n}\n","export class InvalidProxyConfig extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'InvalidProxyConfig';\n }\n}\n\nexport abstract class ProxyConfig {\n abstract get httpUrl(): string | undefined;\n abstract get httpsUrl(): string | undefined;\n\n get preventKeepingConnectionsAlive(): boolean {\n return false;\n }\n\n get retriesWhenBlocked(): number {\n return 0;\n }\n}\n","import { InvalidProxyConfig, ProxyConfig } from './proxyConfig.js';\n\nexport interface GenericProxyConfigOptions {\n httpUrl?: string;\n httpsUrl?: string;\n}\n\nexport class GenericProxyConfig extends ProxyConfig {\n protected readonly _httpUrl?: string;\n protected readonly _httpsUrl?: string;\n\n constructor(options: GenericProxyConfigOptions = {}) {\n super();\n const { httpUrl, httpsUrl } = options;\n if (!httpUrl && !httpsUrl) {\n throw new InvalidProxyConfig(\n 'GenericProxyConfig requires you to define at least one of the two: ' +\n 'http or https',\n );\n }\n this._httpUrl = httpUrl;\n this._httpsUrl = httpsUrl;\n }\n\n override get httpUrl(): string | undefined {\n return this._httpUrl ?? this._httpsUrl;\n }\n\n override get httpsUrl(): string | undefined {\n return this._httpsUrl ?? this._httpUrl;\n }\n}\n","import { GenericProxyConfig } from './genericProxyConfig.js';\n\nexport interface WebshareProxyConfigOptions {\n proxyUsername: string;\n proxyPassword: string;\n filterIpLocations?: string[];\n retriesWhenBlocked?: number;\n domainName?: string;\n proxyPort?: number;\n}\n\nconst DEFAULT_DOMAIN_NAME = 'p.webshare.io';\nconst DEFAULT_PORT = 80;\nconst ROTATE_SUFFIX = '-rotate';\n\nexport class WebshareProxyConfig extends GenericProxyConfig {\n readonly proxyUsername: string;\n readonly proxyPassword: string;\n readonly domainName: string;\n readonly proxyPort: number;\n private readonly _filterIpLocations: string[];\n private readonly _retriesWhenBlocked: number;\n\n constructor(options: WebshareProxyConfigOptions) {\n // Bypass GenericProxyConfig's URL requirement check by providing a placeholder.\n super({ httpUrl: 'placeholder' });\n this.proxyUsername = options.proxyUsername;\n this.proxyPassword = options.proxyPassword;\n this.domainName = options.domainName ?? DEFAULT_DOMAIN_NAME;\n this.proxyPort = options.proxyPort ?? DEFAULT_PORT;\n this._filterIpLocations = options.filterIpLocations ?? [];\n this._retriesWhenBlocked = options.retriesWhenBlocked ?? 10;\n }\n\n get url(): string {\n const locationCodes = this._filterIpLocations\n .map((code) => `-${code.toUpperCase()}`)\n .join('');\n let username = this.proxyUsername;\n if (username.endsWith(ROTATE_SUFFIX)) {\n username = username.slice(0, -ROTATE_SUFFIX.length);\n }\n const encodedUser = encodeURIComponent(username);\n const encodedPass = encodeURIComponent(this.proxyPassword);\n return (\n `http://${encodedUser}${locationCodes}${ROTATE_SUFFIX}:${encodedPass}` +\n `@${this.domainName}:${this.proxyPort}/`\n );\n }\n\n override get httpUrl(): string {\n return this.url;\n }\n\n override get httpsUrl(): string {\n return this.url;\n }\n\n override get preventKeepingConnectionsAlive(): boolean {\n return true;\n }\n\n override get retriesWhenBlocked(): number {\n return this._retriesWhenBlocked;\n }\n}\n","export type FlagKind = 'boolean' | 'string' | 'string[]';\n\nexport interface FlagSpec {\n kind: FlagKind;\n default?: boolean | string | string[];\n}\n\nexport type ArgvSpec = Record<string, FlagSpec>;\n\nexport interface ParsedArgs {\n positional: string[];\n flags: Record<string, boolean | string | string[]>;\n}\n\nexport class ArgvError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'ArgvError';\n }\n}\n\nexport function parseArgs(argv: string[], spec: ArgvSpec): ParsedArgs {\n const flags: Record<string, boolean | string | string[]> = {};\n const positional: string[] = [];\n\n for (const [name, def] of Object.entries(spec)) {\n if (def.default !== undefined) {\n flags[name] = def.default;\n } else if (def.kind === 'boolean') {\n flags[name] = false;\n } else if (def.kind === 'string[]') {\n flags[name] = [];\n }\n }\n\n const known = new Set(Object.keys(spec));\n let i = 0;\n let stopFlags = false;\n\n while (i < argv.length) {\n const token = argv[i]!;\n if (stopFlags) {\n positional.push(token);\n i++;\n continue;\n }\n if (token === '--') {\n stopFlags = true;\n i++;\n continue;\n }\n if (token.startsWith('--')) {\n const eqIdx = token.indexOf('=');\n const rawName = eqIdx === -1 ? token.slice(2) : token.slice(2, eqIdx);\n const inlineValue = eqIdx === -1 ? undefined : token.slice(eqIdx + 1);\n const name = rawName.replace(/-/g, '_');\n if (!known.has(name)) {\n throw new ArgvError(`Unknown argument: --${rawName}`);\n }\n const def = spec[name]!;\n if (def.kind === 'boolean') {\n if (inlineValue !== undefined) {\n throw new ArgvError(`Argument --${rawName} does not take a value`);\n }\n flags[name] = true;\n i++;\n } else if (def.kind === 'string') {\n if (inlineValue !== undefined) {\n flags[name] = inlineValue;\n i++;\n } else {\n const next = argv[i + 1];\n if (next === undefined) {\n throw new ArgvError(`Argument --${rawName} requires a value`);\n }\n flags[name] = next;\n i += 2;\n }\n } else {\n // string[]\n const collected: string[] = [];\n if (inlineValue !== undefined) {\n collected.push(inlineValue);\n i++;\n } else {\n i++;\n }\n while (i < argv.length) {\n const peek = argv[i]!;\n if (peek === '--' || peek.startsWith('--')) break;\n collected.push(peek);\n i++;\n }\n flags[name] = collected;\n }\n } else {\n positional.push(token);\n i++;\n }\n }\n\n return { positional, flags };\n}\n","import { YouTubeTranscriptApi } from './api.js';\nimport { FormatterLoader, type FormatterType } from './formatters/index.js';\nimport { GenericProxyConfig } from './proxies/genericProxyConfig.js';\nimport type { ProxyConfig } from './proxies/proxyConfig.js';\nimport { WebshareProxyConfig } from './proxies/webshareProxyConfig.js';\nimport type { FetchedTranscript } from './transcripts/fetchedTranscript.js';\nimport type { TranscriptList } from './transcripts/transcriptList.js';\nimport { ArgvError, parseArgs } from './utils/argv.js';\n\nconst VERSION = '0.1.0';\n\nconst SPEC = {\n list_transcripts: { kind: 'boolean' as const, default: false },\n languages: { kind: 'string[]' as const, default: ['en'] },\n exclude_generated: { kind: 'boolean' as const, default: false },\n exclude_manually_created: { kind: 'boolean' as const, default: false },\n format: { kind: 'string' as const, default: 'pretty' },\n translate: { kind: 'string' as const, default: '' },\n webshare_proxy_username: { kind: 'string' as const, default: '' },\n webshare_proxy_password: { kind: 'string' as const, default: '' },\n http_proxy: { kind: 'string' as const, default: '' },\n https_proxy: { kind: 'string' as const, default: '' },\n version: { kind: 'boolean' as const, default: false },\n help: { kind: 'boolean' as const, default: false },\n};\n\nconst HELP_TEXT = `Usage: youtube-transcript [options] VIDEO_ID [VIDEO_ID ...]\n\nFetch transcripts/subtitles for one or more YouTube videos.\n\nOptions:\n --list-transcripts List available transcript languages instead of fetching.\n --languages CODE [CODE ...] Language codes in descending priority (default: en).\n --exclude-generated Skip auto-generated transcripts.\n --exclude-manually-created Skip manually created transcripts.\n --format FORMAT Output format: json, pretty, text, webvtt, srt (default: pretty).\n --translate CODE Translate to the given language code.\n --webshare-proxy-username U Webshare \"Proxy Username\".\n --webshare-proxy-password P Webshare \"Proxy Password\".\n --http-proxy URL HTTP proxy URL.\n --https-proxy URL HTTPS proxy URL.\n --version Print version and exit.\n --help Show this help message and exit.\n`;\n\nexport class YouTubeTranscriptCli {\n private readonly _argv: string[];\n\n constructor(argv: string[]) {\n this._argv = argv;\n }\n\n async run(): Promise<{ output: string; exitCode: number }> {\n let parsed;\n try {\n parsed = parseArgs(this._argv, SPEC);\n } catch (err) {\n if (err instanceof ArgvError) {\n return { output: err.message, exitCode: 2 };\n }\n throw err;\n }\n const flags = parsed.flags;\n\n if (flags['help'] === true) {\n return { output: HELP_TEXT, exitCode: 0 };\n }\n if (flags['version'] === true) {\n return { output: `youtube-transcript, version ${VERSION}`, exitCode: 0 };\n }\n\n if (parsed.positional.length === 0) {\n return {\n output: 'error: at least one VIDEO_ID is required\\n\\n' + HELP_TEXT,\n exitCode: 2,\n };\n }\n\n const videoIds = parsed.positional.map((id) => id.replace(/\\\\/g, ''));\n\n const excludeManually = flags['exclude_manually_created'] === true;\n const excludeGenerated = flags['exclude_generated'] === true;\n if (excludeManually && excludeGenerated) {\n return { output: '', exitCode: 0 };\n }\n\n let proxyConfig: ProxyConfig | undefined;\n const httpProxy = flags['http_proxy'] as string;\n const httpsProxy = flags['https_proxy'] as string;\n if (httpProxy !== '' || httpsProxy !== '') {\n proxyConfig = new GenericProxyConfig({\n httpUrl: httpProxy || undefined,\n httpsUrl: httpsProxy || undefined,\n });\n }\n\n const wsUser = flags['webshare_proxy_username'] as string;\n const wsPass = flags['webshare_proxy_password'] as string;\n if (wsUser !== '' || wsPass !== '') {\n proxyConfig = new WebshareProxyConfig({\n proxyUsername: wsUser,\n proxyPassword: wsPass,\n });\n }\n\n const api = new YouTubeTranscriptApi({ proxyConfig });\n\n const collected: Array<TranscriptList | FetchedTranscript> = [];\n const exceptions: string[] = [];\n let successCount = 0;\n\n for (const videoId of videoIds) {\n try {\n const list = await api.list(videoId);\n if (flags['list_transcripts'] === true) {\n collected.push(list);\n } else {\n const fetched = await this._fetchTranscript(\n list,\n flags['languages'] as string[],\n excludeManually,\n excludeGenerated,\n flags['translate'] as string,\n );\n collected.push(fetched);\n }\n successCount++;\n } catch (err) {\n exceptions.push(err instanceof Error ? err.toString() : String(err));\n }\n }\n\n const printSections: string[] = [...exceptions];\n if (collected.length > 0) {\n if (flags['list_transcripts'] === true) {\n for (const item of collected) {\n printSections.push(String(item));\n }\n } else {\n const formatter = new FormatterLoader().load(flags['format'] as FormatterType);\n printSections.push(\n formatter.formatTranscripts(collected as FetchedTranscript[]),\n );\n }\n }\n\n const output = printSections.join('\\n\\n');\n const exitCode = successCount === 0 && videoIds.length > 0 ? 1 : 0;\n return { output, exitCode };\n }\n\n private async _fetchTranscript(\n transcriptList: TranscriptList,\n languages: string[],\n excludeManually: boolean,\n excludeGenerated: boolean,\n translate: string,\n ): Promise<FetchedTranscript> {\n let transcript;\n if (excludeManually) {\n transcript = transcriptList.findGeneratedTranscript(languages);\n } else if (excludeGenerated) {\n transcript = transcriptList.findManuallyCreatedTranscript(languages);\n } else {\n transcript = transcriptList.findTranscript(languages);\n }\n if (translate !== '') {\n transcript = transcript.translate(translate);\n }\n return transcript.fetch();\n }\n}\n\nexport async function main(argv: string[] = process.argv.slice(2)): Promise<void> {\n const cli = new YouTubeTranscriptCli(argv);\n const { output, exitCode } = await cli.run();\n if (output) {\n process.stdout.write(output + '\\n');\n }\n process.exit(exitCode);\n}\n\n// Auto-run when executed directly (works under both ESM and CJS).\nconst isDirectRun = (() => {\n try {\n if (typeof process === 'undefined' || !process.argv[1]) return false;\n const entry = process.argv[1];\n return entry.endsWith('cli.js') || entry.endsWith('cli.cjs');\n } catch {\n return false;\n }\n})();\n\nif (isDirectRun) {\n void main();\n}\n"]}
|