Extension:VideoCache

MediaWiki extensions manual
VideoCache
Release status: beta
Implementation Tag , Special page
Description Extension to download and cache internet videos, and display on pages if they exist
Author(s) OpenTechStrategies
Latest version 0.1.2 (May 27th, 2022)
MediaWiki > 1.35.0
PHP > 7.3
Database changes No
License GNU General Public License 2.0 or later
Download https://code.librehq.com/ots/mediawiki/VideoCache/uploads/c53f53b3980fe2ac2e6c20581faae8c0/VideoCache-0.1.2.tar.gz
https://code.librehq.com/ots/mediawiki/VideoCache/-/blob/main/README.md

The VideoCache extension allows for the caching of online videos to the local directory using 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 edit

  • 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

Configuration edit

Parameters edit

  • $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 edit

MediaWiki API calls added:

videocache-add edit

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 edit

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 edit

  • url - The url of the video

Example edit

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

<ifvideocacheexists url="https://youtube.com/watch?v=XXX">
<span class="plainlinks">[{{fullurl:Special:VideoCacheDownload|url=https://youtube.com/watch?v=XXX"}}Download video from Cache]</span>
</ifvideocacheexists>

Special:VideoCacheDownload Special Page edit

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 edit

  • url - the url of the video that is cached

Internationalization edit

Currently only has support for English.