Get the video file from a web link without the need to launch a Chrome browser

Currently, I am enrolled in a course that consists of around 150 videos.

Progress Update:

At the moment, there is no option to download these videos directly. To retrieve the URL for each video file, I have developed a script that I execute through the Console as shown below:

The platform where I am viewing these videos differs from the site where they are hosted (e.g., watching on LinkedIn Learning but videos are on Lynda).

console.log(("<h2>"+ document.title)+"</h2>"
+
"<a href=\""+document.getElementsByClassName("video-tech")[0].getAttribute("src")+"> click here </a>");
document.getElementsByClassName("video-next-button")[0].click();

An example output from the code above is:

<h2>Overview of QGIS features: Learning QGIS (2015)</h2>
<a href="https://files3.xxxxx.com/secure/courses/383524/VBR_MP4h264_main_SD/383524_01_01_XR15_Overview.mp4?V0lIWk4afWPs3ejN5lxsCi1SIkGKYcNR_F7ijKuQhDmS1sYUK7Ps5TYBcV-MHzdVTujT5p03HP10F_kqzhwhqi38fhOAPnNJz-dMyvA2-YIpBOI-wGtuOjItlVbRUDn6QUWpwe1sRoAl__IA1zmJn3gPvC7Fu926GViqVdLa3oLB0mxRGa7i> click here </a>

I have masked the domain name with 'xxxxx'.

This method allows me to obtain all video links without manually clicking next (exploring ways to automate this process using timeout techniques). Each link opens in Chrome as depicted below:

https://i.sstatic.net/9KeUj.png After clicking the three dots -> Download, I can save the video files individually.

Desired Outcome: Seeking a method to batch save all videos without the need to open each one separately.

Answer №1

Problem

When it comes to downloading and storing large binary files, there are certain requirements that need to be met:

  • The host server must have CORS support enabled.
  • Accessing the host's network must be done from the same site-origin.
  • Server-to-Server communication might also work.

If you attempted to download content from your localhost and it didn't work, it's likely because accessing the host's network is restricted unless CORS support is enabled on the server side.

Solution

In this scenario, the best workaround would be to either access the content from the same site-origin or use a Server-to-Server approach. Accessing the content from the same site-origin involves running the fetching/saving script directly in the browser, making the requests seem more legitimate to the server.

Instructions

  1. Visit the website where the files are hosted (e.g., ).
  2. Right-click on the webpage and choose 'Inspect' (Ctrl + Shift + I).
  3. Switch to the 'Console' tab in the Developer Tools to start coding.

Script

const downloadVideos = (videos, marker) => {
  const throttleTime = 10000;
  const domain = 'https://www.sample-videos.com';

  if (marker < videos.length) {
    console.log(`Downloading video ${videos[marker].name} @ marker:${marker}`);

    const anchorElement = document.createElement('a');

    anchorElement.setAttribute('href', `${domain}${videos[marker].src}`);
    anchorElement.setAttribute('download', videos[marker].name);
    document.body.appendChild(anchorElement);

    anchorElement.click();
    anchorElement.remove();

    marker += 1;
    setTimeout(downloadVideos, throttleTime, videos, marker);
  }
};

const videos = [
  { src: '/video123/mp4/480/big_buck_bunny_480p_30mb.mp4', name: 'video_480p.mp4' },
  { src: '/video123/mp4/720/big_buck_bunny_720p_1mb.mp4', name: 'video_720p.mp4' }
];

downloadVideos(videos, 0);

Happy Downloading!

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Disable or set input text to read-only in Internet Explorer 9 and earlier versions using JavaScript or jQuery

Can anyone offer any suggestions on how to accomplish this task? I attempted using JavaScript with the code below, but it did not yield the desired results. element.readOnly="true"; element.readonly="readonly"; element.disabled="disabled"; I also tried ...

Setting up an express server to host my optimized webpack production website

Recently, I have been involved in a project using Angular 2 and Webpack. The project was based on a template that already included webpack configurations for both development and production servers. Here is an overview of the setup: webpack.config.js: / ...

What is the best way to retrieve a value by using the data.get() method?

I am currently facing an issue with retrieving the value of a textarea that I have dynamically added to a fieldset in my form. When I attempt to submit the form, the code below is executed: function handleSubmit(e) { e.preventDefault(); console.log( ...

Ways to verify the functionality of a webpage once it has been loaded on my local machine's browser

I manage a website that is currently hosted on a server and being used by thousands of visitors. The site is created using Java and soy template technology. I am looking to test the frontend rendering and JavaScript files. Can this be done directly from my ...

The JavaScript value of the button text once it has been modified

We have a website feature where the button text changes dynamically. Here are the elements before the button text change: <button _ngcontent-wex-c70="" class="btn btn-wait buy font-family-title height-70 pp-sun-ins"><labe ...

Unable to create properties for a class that is being exported

When attempting to instantiate an exported class, I am encountering the following error: TypeError: Cannot set property '_db' of undefined This is how I am creating and exporting the class: const mongodb = require('mongodb').MongoC ...

What is the best way to download a file without interference from automated

I am currently working on automating tests for some websites using WebDriver, TestNG, and Java code. I have encountered a challenge with downloading files. Specifically, I am trying to download a file from the following link: http://www.labmultis.info ...

Master the art of fetching response data from an API and implementing a function to process the data and generate desired outputs using Node.js and JavaScript

Being new to node.js, javascript, and vue, I attempted to create a Currency Converter by fetching data from an API for exchange rates and performing calculations in a function. Despite successfully obtaining the exchange rates from the selected country in ...

The NicEditor is malfunctioning due to a ReferenceError with the variable bkLib

Encountering an issue with my NicEditor. When using a simple HTML page like this: <html> <head> <script src="http://js.nicedit.com/nicEdit-latest.js" type="text/javascript"></script> <script type="text/javascript">bkLib.onDom ...

Sorting by alphabetical order using Vue.js and Axios

I am currently in need of assistance with filtering my data based on brand name and then further refining the results by alphabetical order using the "product.name" property. Provided below are the axios functions I am using for this task. export default { ...

Steps for unloading or replacing a JQuery script when the useragent is identified as IE6

I've encountered a challenge. I created a script using jQuery that causes an input field to shake if the user enters incorrect values: $('#input-name').addClass('input-bad').effect('shake',{ direction: ' ...

Tips for displaying the number of selected values in a select box label (e.g. Choose an Option)

I am currently using the jQuery multiselect API in my application to allow users to select multiple values. However, I am facing an issue where I need to fetch all the selected values when a button next to the multiselect box is clicked. Unfortunately, I h ...

Having trouble with Vue component registration repeatedly failing

Currently, I am working on a front-end project using [THIS VUE TEMPLATE][https://www.creative-tim.com/product/vue-material-dashboard-pro] The issue I am facing involves trying to register a component locally and encountering the following error: "1 ...

Working with external data in D3.js involves loading and manipulating datasets efficiently

As a newcomer to D3.js, I have been exploring various tutorials and exercises to familiarize myself with it. My primary goal with D3 is to load external data, typically in JSON format, and create interactive charts based on that data. You can find the bas ...

The functionality of "#button_1" remains unchanged despite using .click() or .hover() methods

Seems like I made a beginner's error - the #button_1 ID seems to be immune to the jQuery effects of click() or hover(). If someone could spare a moment to check out my JSFiddle, it would be incredibly helpful. It's likely something quite simple ...

Discovering nested documents in MongoDB using JavaScript

How to find nested data in MongoDB with the following collection: { "_id": { "$oid": "585b998297f53460d5f760e6" }, "newspaper": { "playerID": "57bffe76b6a70d6e2a3855b7", "playerUsername": "dennis", "player_newspaper": "{\"ID\":\" ...

dynamically inserting new data fields and calculating cumulative total

I'm looking to find a way to calculate the total sum of dynamically added fields and have the result displayed on the page. However, I seem to have hit a roadblock along the way. Here is the code that I'm currently examining and trying to unders ...

What is the process for configuring NextJS to recognize and handle multiple dynamic routes?

Utilizing NextJS for dynamic page creation, I have a file called [video].tsx This file generates dynamic pages with the following code: const Video = (props) => { const router = useRouter() const { video } = router.query const videoData = GeneralVi ...

Utilizing jQuery's then() method to display HTML and JSON outputs from printing operations

Currently, I am in the process of mastering jquery deferreds. When working with html on jsfiddle, I receive an object that contains two lines when printed within the then() statement: "success" and the html returned by the ajax request. For instance, upo ...

What is the process for displaying the following text after deleting the particle text?

Recently diving into the world of vanilla JS and WebGL content, I managed to create a particle text effect that distorts on mouse hover. These particles are interconnected with lines, as shown in the code snippet below. const canvas = document.getElementBy ...