Extension:VideoCache

= Extension:VideoCache =

The VideoCache extension allows for the caching of online videos to the local directory using [yt-dlp](https://github.com/yt-dlp/yt-dlp). Cached files are added via the api, and can be retrieved on wiki pages.

The caching works purely based on the file system, so that multiple wikis can use the same cache.

Installation

 * Install yt-dlp, either as directed above, or through your package manager.
 * NOTE: Make sure your system has PHP 7.3+
 * Download and place the file(s) in a directory called VideoCache in your extensions/ folder
 * Add the following line to your LocalSettings.php

wfLoadExtension('VideoCache');


 * Configure as required

Parameters

 * $wgVideoCacheYtdlpLocation - The location of the yt-dlp program, defaults to /bin/yt-dlp
 * $wgVideoCacheLocation - the location of where the files should be cached queries. Defaults to /opt/VideoCache/.  'Note: the mediawiki user (such as apache) needs to have write permissions to this directory, and it needs to be created!

API
MediaWiki API calls added;

videocache-add
Add a video to the cache.

Parameters:


 * url - the url of the video, such as youtube.com/v=XXX. Can be any url that yt-dlp recognizes.
 * title - an optional title for the video, for when an end user downloads it from the cache. This defaults to the title as recognized by yt-dlp.

ifvideocacheexists hook
VideoCache provides a hook for wiki pages if there is a cached version of the video available. In the case that it does, whatever wikitext are inside the tags will be rendered.

Parameters

 * url - The url of the video

Example
The following is a simple way to provide a link to the cache if it exists

 [Download video from Cache]

Special:VideoCacheDownload Special Page
Use to download the cached video. It is downloaded with "inline" content disposition, to force a download to the user, rather than viewing inline.

Parameters

 * url - the url of the video that is cached

Internationalization
Currently only has support for English.