There have been multiple accounts created with the sole purpose of posting advertisement posts or replies containing unsolicited advertising.

Accounts which solely post advertisements, or persistently post them may be terminated.

Script to extract m3u8 file from URL

Hello! I’d like to write a script to download videos from streamingcommunity.estate from a given video URL, and to do this I need the m3u8 file url. Currently I manually go to the network tab to search for it, but I’d like the script to do this automatically. Do you know of a way to achieve this? Bash or Python if possible, otherwise any other method will do fine. Thanks in advance!

free ,

How did u go op? I tried to get stream video and failed in my methods. 😥

tubbadu OP ,

hi, sorry for the late reply! I finally wrote this nodejs script:


<span style="font-weight:bold;color:#a71d5d;">const </span><span style="color:#323232;">puppeteer </span><span style="font-weight:bold;color:#a71d5d;">= </span><span style="color:#323232;">require(</span><span style="color:#183691;">'puppeteer'</span><span style="color:#323232;">);
</span><span style="color:#323232;">
</span><span style="font-style:italic;color:#969896;">// This is where we'll put the code to get around the tests.
</span><span style="color:#323232;">
</span><span style="color:#323232;">
</span><span style="color:#323232;">
</span><span style="font-weight:bold;color:#a71d5d;">function </span><span style="font-weight:bold;color:#795da3;">findPlaylistUrl</span><span style="color:#323232;">(networkUrls) {
</span><span style="color:#323232;">  </span><span style="font-weight:bold;color:#a71d5d;">for </span><span style="color:#323232;">(</span><span style="font-weight:bold;color:#a71d5d;">const </span><span style="color:#323232;">url </span><span style="font-weight:bold;color:#a71d5d;">of </span><span style="color:#323232;">networkUrls) {
</span><span style="color:#323232;">    </span><span style="font-weight:bold;color:#a71d5d;">if </span><span style="color:#323232;">(url.startsWith(</span><span style="color:#183691;">'https://vixcloud.co/playlist'</span><span style="color:#323232;">)) {
</span><span style="color:#323232;">      </span><span style="font-weight:bold;color:#a71d5d;">return </span><span style="color:#323232;">url;
</span><span style="color:#323232;">    }
</span><span style="color:#323232;">  }
</span><span style="color:#323232;">  </span><span style="font-weight:bold;color:#a71d5d;">return </span><span style="color:#183691;">''</span><span style="color:#323232;">; </span><span style="font-style:italic;color:#969896;">// Return an empty string if no matching URL is found
</span><span style="color:#323232;">}
</span><span style="color:#323232;">
</span><span style="color:#323232;">(</span><span style="font-weight:bold;color:#a71d5d;">async </span><span style="color:#323232;">() </span><span style="font-weight:bold;color:#a71d5d;">=> </span><span style="color:#323232;">{
</span><span style="color:#323232;">  </span><span style="font-style:italic;color:#969896;">// Check if URL argument is provided
</span><span style="color:#323232;">  </span><span style="font-weight:bold;color:#a71d5d;">if </span><span style="color:#323232;">(</span><span style="color:#0086b3;">process</span><span style="color:#323232;">.</span><span style="color:#0086b3;">argv</span><span style="color:#323232;">.length </span><span style="font-weight:bold;color:#a71d5d;"><= </span><span style="color:#0086b3;">2</span><span style="color:#323232;">) {
</span><span style="color:#323232;">    </span><span style="color:#795da3;">console</span><span style="color:#323232;">.</span><span style="color:#0086b3;">error</span><span style="color:#323232;">(</span><span style="color:#183691;">'Usage: node get_network_urls.js <URL>'</span><span style="color:#323232;">);
</span><span style="color:#323232;">    </span><span style="color:#0086b3;">process</span><span style="color:#323232;">.</span><span style="color:#0086b3;">exit</span><span style="color:#323232;">(</span><span style="color:#0086b3;">1</span><span style="color:#323232;">);
</span><span style="color:#323232;">  }
</span><span style="color:#323232;">
</span><span style="color:#323232;">  </span><span style="font-weight:bold;color:#a71d5d;">const </span><span style="color:#323232;">url </span><span style="font-weight:bold;color:#a71d5d;">= </span><span style="color:#0086b3;">process</span><span style="color:#323232;">.</span><span style="color:#0086b3;">argv</span><span style="color:#323232;">[</span><span style="color:#0086b3;">2</span><span style="color:#323232;">];
</span><span style="color:#323232;">
</span><span style="color:#323232;">  </span><span style="font-style:italic;color:#969896;">// Launch a headless browser
</span><span style="color:#323232;">  </span><span style="font-weight:bold;color:#a71d5d;">const </span><span style="color:#323232;">browser </span><span style="font-weight:bold;color:#a71d5d;">= </span><span style="color:#323232;">await puppeteer.launch({ headless: </span><span style="color:#183691;">'true' </span><span style="color:#323232;">});
</span><span style="color:#323232;">  </span><span style="font-weight:bold;color:#a71d5d;">const </span><span style="color:#323232;">page </span><span style="font-weight:bold;color:#a71d5d;">= </span><span style="color:#323232;">await browser.newPage();
</span><span style="color:#323232;">
</span><span style="color:#323232;">  </span><span style="font-style:italic;color:#969896;">// Enable request interception
</span><span style="color:#323232;">  </span><span style="font-weight:bold;color:#a71d5d;">await </span><span style="color:#323232;">page.setRequestInterception(</span><span style="color:#0086b3;">true</span><span style="color:#323232;">);
</span><span style="color:#323232;">
</span><span style="color:#323232;">  </span><span style="font-style:italic;color:#969896;">// Capture network requests
</span><span style="color:#323232;">  </span><span style="font-weight:bold;color:#a71d5d;">const </span><span style="color:#323232;">networkUrls </span><span style="font-weight:bold;color:#a71d5d;">= </span><span style="color:#323232;">[];
</span><span style="color:#323232;">  page.on(</span><span style="color:#183691;">'request'</span><span style="color:#323232;">, (request) </span><span style="font-weight:bold;color:#a71d5d;">=> </span><span style="color:#323232;">{
</span><span style="color:#323232;">    networkUrls.</span><span style="color:#0086b3;">push</span><span style="color:#323232;">(request.url());
</span><span style="color:#323232;">    request.continue();
</span><span style="color:#323232;">  });
</span><span style="color:#323232;">
</span><span style="color:#323232;">  </span><span style="font-style:italic;color:#969896;">// Navigate to the URL
</span><span style="color:#323232;">  </span><span style="font-weight:bold;color:#a71d5d;">await </span><span style="color:#323232;">page.goto(url);
</span><span style="color:#323232;">
</span><span style="color:#323232;">  </span><span style="font-style:italic;color:#969896;">// Wait for a while to capture network requests (adjust as needed)
</span><span style="color:#323232;">  </span><span style="font-weight:bold;color:#a71d5d;">await </span><span style="color:#323232;">page.waitForTimeout(</span><span style="color:#0086b3;">5000</span><span style="color:#323232;">);
</span><span style="color:#323232;">
</span><span style="color:#323232;">  </span><span style="font-style:italic;color:#969896;">// Print the captured network URLs
</span><span style="color:#323232;">  </span><span style="color:#795da3;">console</span><span style="color:#323232;">.</span><span style="color:#0086b3;">log</span><span style="color:#323232;">(findPlaylistUrl(networkUrls));
</span><span style="color:#323232;">    
</span><span style="color:#323232;">  </span><span style="font-style:italic;color:#969896;">// Close the browser
</span><span style="color:#323232;">  </span><span style="font-weight:bold;color:#a71d5d;">await </span><span style="color:#323232;">browser.</span><span style="color:#0086b3;">close</span><span style="color:#323232;">();
</span><span style="color:#323232;">})();
</span>

the first argument passed to the script is the url of the webpage. The script uses the puppeteer module to “fake” a browser, in order to receive all the network calls and so on, and then will search through them for the m3u8 playlist. It is very specific and only works on this website, but it can be easily adapted for other websites as well

free ,

Thanks heaps for reply. Legend. After using chatgpt and bingchat I got the script cleaned up and working but unfortunately no output. 😥 I dont need the content, I just like to defeat these websites. Oh well. Dont want to bother you. My command was "node your-script.js streamingcommunity.express/watch/3330"

tubbadu OP ,

uhm that’s strange, I just tried executing it on your link and it worked. have you waited at least 5 seconds after running the script?

free ,

Thanks for reply, appreciate it. The thing is when i try your code it errors out. So I had to use bingchat or chatgpt to clean it up. Any chance you could upload your file somewhere please?

johnjamesautobahn ,

jDownloader might do this automatically if given the video url.

slugger ,

There is firefox addon that i just found which does this. It’s called: Extract video link. Maybe look at source code.

tubbadu OP ,

I’ll look into it, thanks!

ISOmorph , (edited )

youtube-dl does something similar (it works on a lot more than just youtube). AFAIK each site needs a slightly altered code. You could have a look at the source on their github.

It might be as easy as forking the project and creating your own extractor.py.

7Sea_Sailor ,

I sure hope they commit the work back into the main repo…

ISOmorph ,

I doubt they would be able to. I was interested and looked around a bit. There’s even a whole chapter in their documentation dedicated to adding extractors. First paragraph of that chapter is basically ‘‘do not add piracy websites’’

tubbadu OP ,

I actually use yd-dlp to download m3u8 playlists, but what I’m looking for is a way to extract the m3u8 file URL, so that I can give it to ytdlp to download the actual video

I’ll look into the extractor docs, seems interesting! Thanks!

  • All
  • Subscribed
  • Moderated
  • Favorites
  • [email protected]
  • random
  • lifeLocal
  • goranko
  • All magazines