Skip to content

Instantly share code, notes, and snippets.

@uahim
Last active June 20, 2024 15:15
Show Gist options
  • Save uahim/dc82bbedd3b5e6c999af39ab5d45c643 to your computer and use it in GitHub Desktop.
Save uahim/dc82bbedd3b5e6c999af39ab5d45c643 to your computer and use it in GitHub Desktop.
get stream url - 0.1.8 updated June 2024 to account for css changes
// ==UserScript==
// @name arte stream url
// @namespace http://tampermonkey.net/
// @version 0.1.7
// @description get arte m3u8 stream url
// @author You
// @match https://www.arte.tv/de/videos/*
// @match https://www.arte.tv/fr/videos/*
// ==/UserScript==
// this UserJavaScript provides a simple way to get the m3u8 to feed into VLC or any other player capable of playing streams.
// though it's probably best to get the url or download videos via yt-dlp or addons such as The Stream Detector for Firefox
// https://addons.mozilla.org/en-US/firefox/addon/hls-stream-detector/
var loc = window.location.pathname.split('/');
var lang = loc[1];
var id = loc[3];
var name = loc[4];
var url = "";
var api_base = " https://api.arte.tv/api/player/v2/config/" + lang + "/";
var download_url = api_base + id;
var filmtitle = document.querySelector('meta[property="og:title"]').content;
[" | ARTE Concert"," | ARTE"," - Komplette Sendung"," - Programm in voller Länge"," - Film in voller Länge"," - Regarder le film complet"," - Regarder l’émission complète"].forEach((item) => { filmtitle = filmtitle.replace(item, "") });
filmtitle = filmtitle.replace(/ /g, "_").replace(/[^a-z0-9 \.,_-]/gim, "").replace("_-_","-");
window.onload = function () {
var para = document.createElement("a");
para.setAttribute('id', 'dwnl');
para.setAttribute('style', 'font-weight: bold');
para.setAttribute('style', 'color: white');
para.setAttribute('class', ' ds-adi73s');
var node = document.createElement("span");
node.setAttribute('class', ' ds-12ek84r');
node.innerText = "Stream URL";
para.appendChild(node);
if (document.getElementsByClassName(' ds-rymcfw')[0]) {
document.getElementsByClassName(' ds-rymcfw')[0].insertBefore(para, null);
} else if (document.getElementsByClassName(' ds-z8l0xl')[0]) {
document.getElementsByClassName(' ds-z8l0xl')[0].insertBefore(para, null);
}
var getJSON = function(url, callback) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'json';
xhr.onload = function() {
var status = xhr.status;
if (status == 200) {
callback(null, xhr.response);
} else {
callback(status);
}
};
xhr.send();
};
getJSON(download_url, function(err, data) {
if (err != null) {
console.error(err);
} else {
url = data.data.attributes.streams[0].url;
}
});
document.getElementById('dwnl').addEventListener("click", function(){
var test = prompt("stream URL (OK for ffmpeg command or cancel)", url);
if (test !== null) {
prompt("ffmpeg command", 'ffmpeg -referer "' + location.href + '" -user_agent "' + window.navigator.userAgent + '" -i "' + url + '" -c copy -bsf:a aac_adtstoasc "' + filmtitle + '.mp4"');
}
});
};
@uahim
Copy link
Author

uahim commented Jun 24, 2022

@jeanpierrebertola try now ? v 0.1.5.1
tested with violentmonkey in a fairly recent opera on windows

@jeanpierrebertola
Copy link

image

@jeanpierrebertola
Copy link

It's your new version but it still not working in opera 88.0.4412.53 last version !
thank you

@jeanpierrebertola
Copy link

Sorry it's work thank you so much ++++++

@jeanpierrebertola
Copy link

in fact you need to click here
image
in the black part at the left and stream appear .
thank you for your job

@uahim
Copy link
Author

uahim commented Jun 24, 2022

weird... looks like this here
Clipboard02

could you check 0.1.5.2 and tell me if that's better?

@jeanpierrebertola
Copy link

jeanpierrebertola commented Jun 24, 2022 via email

@jeanpierrebertola
Copy link

jeanpierrebertola commented Jun 24, 2022 via email

@jeanpierrebertola
Copy link

Perfect +++
Merci

@MMHShen
Copy link

MMHShen commented Jul 3, 2022

Hi, uahim
Thank you for your sharing, is it possible to get url from " https://www.arte.tv/de/arte-concert/ "?
This script seems only work on "https://www.arte.tv/de/videos/"

Thank you!

@uahim
Copy link
Author

uahim commented Jul 3, 2022

@MMHShen yes, it should work for concerts too, try now (v0.1.5.3)

@MMHShen
Copy link

MMHShen commented Jul 10, 2022

@MMHShen yes, it should work for concerts too, try now (v0.1.5.3)

Hi, uahim,
Its work now,
Thank yoy!

@osvivant
Copy link

Hi, uahim

It doesn't work since yesterday, would you kindly have a look? many thanks.

@uahim
Copy link
Author

uahim commented Jun 25, 2023

@osvivant try now - 0.1.5.4 should be working

@osvivant
Copy link

Thanks uahim! works flawless now:)

@uahim
Copy link
Author

uahim commented Jun 26, 2023

0.1.5.6 fixes arte concert, sorry

@osvivant
Copy link

:) thanks!!!!!

@uahim
Copy link
Author

uahim commented Nov 20, 2023

0.1.6: updated November 2023 to account for markup changes on arte.tv

@jeanpierrebertola
Copy link

thank you but to record with VLC is problematic.
something block
possible to read but not to record
Thank

@uahim
Copy link
Author

uahim commented Nov 25, 2023

@jeanpierrebertola for downloading, it's recommended to use yt-dlp or at least ffmpeg, here's a guide for beginners:
https://www.rapidseedbox.com/blog/yt-dlp-complete-guide

@jeanpierrebertola
Copy link

thank you ++++++

@osvivant
Copy link

osvivant commented May 3, 2024

Hi, it stopped to work these days. Would you please have a look? thank you very much.

ex:
https://www.arte.tv/fr/videos/116710-062-A/le-dessous-des-images/

@uahim
Copy link
Author

uahim commented May 3, 2024

@osvivant try now

@osvivant
Copy link

osvivant commented May 3, 2024

thanks, it works!

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