Pomeranian working on an iPad Photo by Cookie the Pom

The Yle Areena player back in the day required user to install Flash Player plugin on their browser – and some older media on it still do! But even today the Yle Areena’s HTML5 player is still not probably your favourite media player, so let’s play it in mpv!


First things we need are python3 (it is the new decade 2020 after all), python3-pip and ffmpeg if you haven’t installed them already. These should be in your distributions repositories. Then, using pip3, you can install yle-dl:

# pip3 install --upgrade yle-dl

As the yle-dl page says, certain videos require additional dependencies, but these are likely to be the old ones that still require Flash Player. All the other dependencies should be automatically installed by pip, apart from python3, python3-pip and ffmpeg obviously.

yle-dl is not included in the well known youtube-dl, because yle-dl is licenced under GPLv3 while youtube-dl is in public domain.

Piping from yle-dl to mpv

To make things easy, we can write a really simple script like this:

/usr/local/bin/yle-dl --pipe $YLEURL | /usr/bin/mpv --cache=yes -

Passing an URL to this script starts downloading the video using yle-dl and then simply piping this video to your favourite video player – you can replace mpv with something else if you like. Modify the paths mentioned here to your system equivalents. Set this script as executable and put it in your PATH. Now you can stream Yle Areena videos from the command-line!

The Firefox addon

For this thing to work in the browser, we need this addon. I’ve chosen this one as it is quick and easy to modify to work with yle-dl. Aften installing this, as the installation instructions say, download ff2mpv.py somewhere on your computer and ff2mpv.json into ~/.mozilla/native-messaging-hosts/. Then modify the path ff2mpv.json to point to the correct path to your ff2mpv.py.


Looking at the code in this python script, the first half is the one we are interested in modifying. It passes url to mpv which works well with youtube-dl to play many videos found in the Internet. We want this script to check if the url is an Yle Areena URL. For this we use the the fnmatch library:

# beginning of the ff2mpv.py with the rest of the import lines
import fnmatch

Next we write a simple ifelse to the main function to check if the url is an Yle Areena URL, pass it to the yle-stream, while keeping it functional for youtube-dl supported URLs:

# ff2mpv.py
def main():
    message = get_message()
    url = message.get("url")
    if fnmatch.fnmatch(url, 'https://areena.yle.fi/*'):
        args = ["yle-stream", url]
        args = ["mpv", "--no-terminal", "--", url]

Then just save the file and the addon should work with Yle Areena videos in the same way it works with youtube-dl supported sites! Just in case I can paste here the whole file – it is not a large one after all:

#!/usr/bin/env python3

import sys
import struct
import json
import fnmatch
from subprocess import Popen, DEVNULL

def main():
    message = get_message()
    url = message.get("url")
    if fnmatch.fnmatch(url, 'https://areena.yle.fi/*'):
        args = ["yle-stream", url]
        args = ["mpv", "--no-terminal", "--", url]
    Popen(args, stdin=DEVNULL, stdout=DEVNULL, stderr=DEVNULL)
    # Need to respond something to avoid "Error: An unexpected error occurred"
    # in Browser Console.

# https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Native_messaging#App_side
def get_message():
    raw_length = sys.stdin.buffer.read(4)
    if not raw_length:
        return {}
    length = struct.unpack("@I", raw_length)[0]
    message = sys.stdin.buffer.read(length).decode("utf-8")
    return json.loads(message)

def send_message(message):
    content = json.dumps(message).encode("utf-8")
    length = struct.pack("@I", len(content))

if __name__ == "__main__":

Enjoy content on Yle Areena!

Back to Top