0

When I try to fetch MediaSource object via blob link or send GET XMLHttpRequest I'm getting the error net::ERR_FILE_NOT_FOUND. This happened for youtube or instagram MediaSource links. eg

var xhr = new XMLHttpRequest;
xhr.open('get', url);
xhr.responseType = 'arraybuffer';
xhr.onload = function () {
  some_Further_CallBack(xhr.response);
};
xhr.send();

I'm completelly stuck, please say me what I'm doing wrong.

godloky
  • 37
  • 6

2 Answers2

2

The blob: URL when created from a MediaSource can not be fetched from that URL. Note that even when it's created from a Blob, it's not the same Blob object that you fetch.

The best is to keep your MediaSource instance available in a variable, but in cases you can't (e.g because you're not the author of the page), you can add some hooks on the URL methods to save the original object and retrieve it later as exposed in this answer of mine. But note that you'd need this script to be ran BEFORE the page's use of URL.creatObjectURL(), which means that in your case you will probably need an user-script to inject it as soon as possible.

Kaiido
  • 123,334
  • 13
  • 219
  • 285
  • I have done that already, and tried to apply same methods to the mediasource instance, with the same results. Do you know how the media source can be processed further in order to get data from it? – godloky Dec 20 '22 at 22:02
  • 1
    Once you have the `MediaSource` you can get the `MediaSource` objects it contains by checking its `.sourceBuffers` property. However from this you still won't get "the data". For this you'd also need to hook onto `MediaSource.prototype.appendBuffer` to store the passed `ArrayBuffer` instances in a way you can retrieve them later. But that out of scope for this question. – Kaiido Dec 20 '22 at 22:53
1

Try get error after send

https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/error_event

But i think is not possible get content from youtube by XMLHttpRequest