// ==UserScript== | |
// @name get_m3u8 | |
// @namespace francetvinfo | |
// @include http://www.francetvinfo.fr/* | |
// @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) | |
{ | |
alert(json.videos[1].url); | |
} | |
window._jsonp_loader_callback_request_2 = function(json) | |
{ | |
alert(json.videos[5].url); | |
} | |
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 = "http://sivideo.webservices.francetelevisions.fr/tools/getInfosOeuvre/v2/?idDiffusion=" + id + "&catalogue=Info-web&callback=_jsonp_loader_callback_request_1"; | |
document.getElementsByTagName("head")[0].appendChild(script); | |
} 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 = "http://sivideo.webservices.francetelevisions.fr/tools/getInfosOeuvre/v2/?idDiffusion=" + id + "&catalogue=Pluzz&callback=_jsonp_loader_callback_request_2"; | |
document.getElementsByTagName("head")[0].appendChild(script); | |
} | |
} | |
} | |
get_m3u8(); |
This comment has been minimized.
This comment has been minimized.
@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 francetvinfo.fr website. 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 https://www.francetvinfo.fr/replay-jt/france-3/12-13/jt-de-12-13-du-jeudi-11-octobre-2018_2950395.html and then pass the ID (189835310 in this case) in the API URL like https://sivideo.webservices.francetelevisions.fr/tools/getInfosOeuvre/v2/?idDiffusion=189835310&catalogue=Info-web&callback=_jsonp_loader_callback_request_0 to be able to parse the JSON data and get the M3U8 URL. |
This comment has been minimized.
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?