Skip to content

Instantly share code, notes, and snippets.

Last active December 7, 2020 14:23
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Get M3U8 streaming URL from France TV info replay website
// ==UserScript==
// @name get_m3u8
// @namespace francetvinfo
// @include*
// @version 1
// @grant none
// ==/UserScript==
/* Using Content Script Injection (window.functionName) to make function available outside GreaseMonkey scope
Page reload is needed if using existing function _jsonp_loader_callback_request_0. */
window._jsonp_loader_callback_request_1 = function(json)
window._jsonp_loader_callback_request_2 = function(json)
function get_m3u8()
// replay
var el = document.getElementById("catchup");
if (el) {
var id = el.href.match(/video\/(.*)@/)[1];
var script = document.createElement("script");
script.src = "" + id + "&catalogue=Info-web&callback=_jsonp_loader_callback_request_1";
} else {
// live
var el = document.getElementById("en_direct_video");
if (el) {
var id = el.href.match(/video\/(.*)/)[1];
var script = document.createElement("script");
script.src = "" + id + "&catalogue=Pluzz&callback=_jsonp_loader_callback_request_2";
Copy link

Hi, I tried to execute using nodejs, but it's not possible because or window do not exist in nodejs. How to execute this script?

Copy link

baptx commented Dec 7, 2020

@gilmararaujo Hi, this is not a Node.js script but a script to use with a web browser addon like Greasemonkey (you can recognize the script type because of the file extension .user.js which is a userscript). It is possible that the script is no longer working and needs to be updated due to a change of website.
Here is more information that I gave on my website to another user interested in Node.js:

You can do a web scrapping script with Node.js also, the idea is the same, you have to get the video ID that is printed in the source code of a replay video like and then pass the ID (189835310 in this case) in the API URL like to be able to parse the JSON data and get the M3U8 URL.
The easiest way to get the M3U8 URL without script is just to open the browser console in Firefox for example, then click on the “Network” console tab and if you reload the replay page, you should see a M3U8 URL that you can copy and paste in a video player (it is displayed now because they switched to HTML5 player but I had to use the Greasemonkey script previously on a computer that did not have Flash Player installed).
Since you may have to use a web browser to find the video URL, it may be more convenient to directly get the M3U8 URL in the browser console instead of having to use a script in a command-line console but it depends of what you want to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment