Download the PHP package mrmysql/youtube-transcript without Composer

On this page you can find all versions of the php package mrmysql/youtube-transcript. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package youtube-transcript

YouTube Transcript

YouTube Transcript is a PHP library designed to fetch transcripts for YouTube videos. It allows you to retrieve captions in multiple languages, including auto-generated captions, and provides functionality to translate transcripts into other available languages. Inspired by jdepoix/youtube-transcript-api. I've generated this readme using one of these fancy [A]utocompletion [I]nstruments, so it might be incorrect somewhere, but overall looks good.

CI codecov

Features

Requirements

Installation

To include this library in your project, use Composer:

Usage

1. Initialize the Transcript Fetcher

To begin, you need to set up an HTTP client and a request factory that implements the PSR-18 and PSR-17 interfaces, respectively. These dependencies are required by the TranscriptListFetcher class.

2. Fetch the Transcript List

You can fetch the transcript list for a given YouTube video ID:

3. Retrieve and Display Transcripts

You can iterate over the available transcripts and display them:

4. Fetch a Specific Transcript

To fetch a transcript in a specific language:

You can also take all available locale codes directly from the list:

5. Translate a Transcript

If translation is available, you can translate the transcript to another language:

6. Format a Transcript

Formatters turn the array returned by fetch() into a string in a given format, ready to be written to a file. They live in the MrMySQL\YoutubeTranscript\Formatter namespace:

Formatter Name Output
JsonFormatter json JSON, with Unicode and slashes unescaped
PrettyPrintFormatter pretty A readable PHP array literal (like var_export(), in short [] syntax)
TextFormatter text Plain text without timestamps, one cue per line
SrtFormatter srt SubRip subtitles (.srt)
WebVttFormatter webvtt WebVTT subtitles (.vtt)

In the SRT and WebVTT output, cues are ordered by start time and each cue ends when the next cue of the same transcript starts, so cues within a transcript never overlap (cues of different transcripts merged by formatTranscripts() can). Text is made safe for each format: blank lines inside a cue are removed, cues without visible text are skipped, --> becomes -> in SRT, and &, < and > are escaped in WebVTT. Formatting tags kept by fetch(true) are mapped to the format's own (<strong> → <b>, <em> → <i>), and tags the format doesn't support are removed, keeping their text.

JsonFormatter takes extra JSON_* flags, which are added to its defaults:

formatTranscripts() formats several transcripts at once, e.g. two languages. JSON and the pretty printer return a list of transcripts, text separates them with two blank lines, and SRT and WebVTT merge all cues into one file ordered by start time, which players show as dual subtitles:

To choose the format at runtime, e.g. from a CLI option, use FormatterLoader. It throws UnknownFormatterException for a name it doesn't know:

To add your own format, implement FormatterInterface (formatTranscript() and formatTranscripts(), both returning a string). For another timed subtitle format, extend the abstract TextBasedFormatter, which SrtFormatter and WebVttFormatter are built on. The bundled formatters themselves are final.

Note: Cookie-based authentication is currently not supported due to recent changes in the YouTube API. Age-restricted videos and some protected content cannot be accessed until a new authentication method is implemented.

Exception Handling

This library comes with a set of custom exceptions to handle different scenarios:

Before these were added, unplayable videos were reported as TranscriptsDisabledException. If YouTube still returns caption tracks for a video it reports as not playable, the transcripts are returned as usual.

Example:


All versions of youtube-transcript with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
psr/http-client Version ^1.0
psr/http-factory Version ^1.1
psr/log Version ^1.0 || ^2.0 || ^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mrmysql/youtube-transcript contains the following files

Loading the files please wait ...