I Tried Downloading A Video Using Internet Download Manager, But It Failed

I want to download this video - http://animax.mn:12000/?media=rencoded/op/one_piece503.mp4

Here is a link to a page with similar videos. I tried to download the video using Internet Download Manager, but it failed, as shown in this screenshot

Internet Download Manager Failed Screenshot

Is it possible to save this video for offline viewing? Please help me. Thanks.


Solution 1:


Note that the website in question (http://animax.mn) seems to be non-operational as of June 2021)


The issue you are likely encountering is that the site uses special cookies, which Internet Download Manager probably isn't sending. Particularly, these include a CSRF token to protect against cross-site request forgery attacks and a Laravel PHP Framework session ID. These need be transmitted with the request for the file or the request will be refused.

To download the video, you can:

  • See if there is an option to include these or otherwise add cookies to Internet Download Manager.

  • Use another tool that can download files as well as handle cookies (such as cURL).

Assuming Internet Download Manager doesn't support any additional options to help download this video, you can try the basic instructions for cURL given below.


Getting cURL

cURL can be downloaded from its official download page. The Windows builds are near the very bottom. The blue version numbers link to the appropriate files to download. The blue personal names typically lead elsewhere.

As a suggestion, you may wish to use one of the current (as of this writing) v7.59.0 builds by Viktor Szakats (either the Win32 or Win64 version, as appropriate).

Update:

The Viktor Szakats builds have apparently been supplanted by the official Windows builds of cURL (which are still recommended and available in 32-bit/64-bit versions).

Once downloaded, simply unzip the file and place the contents in a permanent folder of your choosing. To avoid having to use the full path to curl.exe every time you use cURL, you will likely want to register curl.exe in your Windows Path (curl.exe is located in the bin folder for the Szakats builds for the official Windows builds).

Getting The Cookies

You can likely use your browser to get the necessary CSRF token and Laravel session ID to use with cURL (or whichever program you choose) through the developer's console included with modern Chromium-style browsers (Firefox, Chrome, Opera, etc.). As an added benefit, by following the steps below, you can get your basic cURL command as well...

"Copy as cURL" Steps:

  1. Login to the website as normal.

  2. Go to a video page (such as one of the ones listed in this link from your question).

  3. Press F12 (or Ctrl+Shift+I in Opera) to open the developer's console and select the Network option on the right. For ease of use, I would also suggest you click the small Show in separate windows icon (on the far right) to separate the console from the main browser window.

ex. Network Option and Separate Console Developer's Console Network And Docking Options

  1. Reload the video page but do not close the console. The console will capture network traffic related to the page, including the HTTP GET request for e.g. http://animax.mn:12000/?media=rencoded/op/one_piece503.mp4 (which would appear as GET /?media=rencoded/op/one_piece503.mp4).

  2. There will be a large number of GET requests, so you will likely want to filter them with the Media sub-option. You can preview cookies by selecting the Cookies option of the GET request as well.

ex. Media Filtering and Cookie Preview Developer's Console Media Filter and Cookie Options

  1. Right-click the appropriate GET request and select the Copy as cURL menu option (likely Copy as cURL (cmd) in Chrome). Paste the resulting command into Notepad or similar (it will not be displayed beforehand).

ex. Copy As cURL - Firefox Developer's Console Copying GET Request As Curl

With the video links given, I didn't have any issue with GET requests appearing immediately. However, if the Media filter option is blank, you should use the console Clear (Trashcan) icon on the far left then press the "play" button of the media player in the main window (where the video appears normally). This should make any appropriate GET request(s) for the media file(s) in question appear.

Inspecting The cURL Request

The text you've copied should look similar to the following:

curl http://animax.mn:12000/?media=rencoded/op/one_piece001.mp4 -H "Host: animax.mn:12000" -H "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:54.0) Gecko/20100101 Firefox/54.0" -H "Accept: video/webm,video/ogg,video/;q=0.9,application/ogg;q=0.7,audio/;q=0.6,/;q=0.5" -H "Accept-Language: en-US,en;q=0.5" -H "Range: bytes=0-" -H "Cookie: XSRF-TOKEN=eyJpdiI6IkE0WlRudGtmdUlhQWRUTUFndkFPelE9PSIsInZhbHVlIjoiXC95dmFPeGdkWTN6QmZTamNXTUF0MFJOSitHWXdxOE1kRHRQeGVHWURmbVRuWG4zU0lFSW5IZEVpcFwvYzlQandDeUd4cGlkUzVtZk1PaEs2dzRoaDlRUT09IiwibWFjIjoiMDdjNjNmYTFhOWM5MzhlYmFjNTk5ZmRmNzNiN2IxYTc2ZWJlOWM3MjVlZDM5YWY4ZDQxYTdmMjNjNzNjOWI3MCJ9; laravel_session=eyJpdiI6IjN0VTlEQStvdyt0NXdMeDdTaUhJOUE9PSIsInZhbHVlIjoibXhMQ1dLMFl3M0FUSTlIKzVxcjRqTnpncFFJRGhrZktCaThKeHZxRXRmU1M5VXFWSjR0bjJIKzRHWE1VWFpxNUp3QTNZSW1ZXC9vaW1DaEdGU0k2dCtRPT0iLCJtYWMiOiI0YzYxOTI3ZjRiZTYzZGNkZmZkZmY1YjhjOWMzZGJmM2I1N2EyMjE4ODU1ODkwMGRmYjFhOThjOWZlNmRiZDhkIn0"%"3D; wh-widget-cookie=1" -H "DNT: 1" -H "Connection: keep-alive"

If you need just the CSRF token and Laravel session ID, you can eliminate most of the copied command, leaving just e.g.:

"XSRF-TOKEN=eyJpdiI6IkE0WlRudGtmdUlhQWRUTUFndkFPelE9PSIsInZhbHVlIjoiXC95dmFPeGdkWTN6QmZTamNXTUF0MFJOSitHWXdxOE1kRHRQeGVHWURmbVRuWG4zU0lFSW5IZEVpcFwvYzlQandDeUd4cGlkUzVtZk1PaEs2dzRoaDlRUT09IiwibWFjIjoiMDdjNjNmYTFhOWM5MzhlYmFjNTk5ZmRmNzNiN2IxYTc2ZWJlOWM3MjVlZDM5YWY4ZDQxYTdmMjNjNzNjOWI3MCJ9; laravel_session=eyJpdiI6IjN0VTlEQStvdyt0NXdMeDdTaUhJOUE9PSIsInZhbHVlIjoibXhMQ1dLMFl3M0FUSTlIKzVxcjRqTnpncFFJRGhrZktCaThKeHZxRXRmU1M5VXFWSjR0bjJIKzRHWE1VWFpxNUp3QTNZSW1ZXC9vaW1DaEdGU0k2dCtRPT0iLCJtYWMiOiI0YzYxOTI3ZjRiZTYzZGNkZmZkZmY1YjhjOWMzZGJmM2I1N2EyMjE4ODU1ODkwMGRmYjFhOThjOWZlNmRiZDhkIn0"%"3D"

Note that you should be able to safely eliminate the ; wh-widget-cookie=1" portion at the end of of the cookies, as shown above (this last cookie doesn't seem necessary for connections via cURL). Be aware, however, and keep the double quotes surrounding the cookies unless you determine that they aren't actually needed.

Downloading With cURL

As is, the command you initially copied has (almost) all the data needed to make a request for e.g. http://animax.mn:12000/?media=rencoded/op/one_piece503.mp4. You just need to add the -O (captial oh) output option just after curl and the correct URL (as needed) e.g.:

curl -O "http://animax.mn:12000/?media=rencoded/op/one_piece503.mp4" -H "Host: animax.mn:12000" [...] -H "Connection: keep-alive"

(To be clear, the ellipses [...] are just my shorthand — you would include the full remaining text of the copied command, shown earlier).

You could then (hopefully) run this cURL command from the command line to download the video.

Shortening The Command

In this instance, the default cURL command has a lot of extraneous pieces. If you feel the need, the cURL command can be shortened to just e.g.:

curl -O http://animax.mn:12000/?media=rencoded/op/one_piece503.mp4 -r 0- --cookie "XSRF-TOKEN=eyJpdiI6IkE0WlRudGtmdUlhQWRUTUFndkFPelE9PSIsInZhbHVlIjoiXC95dmFPeGdkWTN6QmZTamNXTUF0MFJOSitHWXdxOE1kRHRQeGVHWURmbVRuWG4zU0lFSW5IZEVpcFwvYzlQandDeUd4cGlkUzVtZk1PaEs2dzRoaDlRUT09IiwibWFjIjoiMDdjNjNmYTFhOWM5MzhlYmFjNTk5ZmRmNzNiN2IxYTc2ZWJlOWM3MjVlZDM5YWY4ZDQxYTdmMjNjNzNjOWI3MCJ9; laravel_session=eyJpdiI6IjN0VTlEQStvdyt0NXdMeDdTaUhJOUE9PSIsInZhbHVlIjoibXhMQ1dLMFl3M0FUSTlIKzVxcjRqTnpncFFJRGhrZktCaThKeHZxRXRmU1M5VXFWSjR0bjJIKzRHWE1VWFpxNUp3QTNZSW1ZXC9vaW1DaEdGU0k2dCtRPT0iLCJtYWMiOiI0YzYxOTI3ZjRiZTYzZGNkZmZkZmY1YjhjOWMzZGJmM2I1N2EyMjE4ODU1ODkwMGRmYjFhOThjOWZlNmRiZDhkIn0"%"3D" -H "Connection: keep-alive"

As a quick point, -r 0- takes the place of -H "Range: bytes=0- (in this case, the Range: header is the only other component of the original URL needed by cURL besides the given cookies).

Notes

  • I encountered no errors regarding re-using the same cookies for multiple videos over the same session. However, note that logging out/logging in will change the cookies and you will have to perform the steps I outline to regather them each time you do so.

  • You may want to disable your anti-virus, etc. (temporarily) for downloads

  • It probably isn't necessary to keep the https://animax.mn browser window open but I would just so I could log out when finished (or possibly re-login). It seems unclear what the session handling criteria generally is for the site otherwise.

  • You can take (almost?) the same cookies from the initial login POST request, but it seemed like there may have been some small, unconfirmed issues with that (which is why I recommend taking them directly from the GET request).

  • You'll likely want to be careful with copying the cookies. They can be a bit unwieldy with normal cut/paste operations.


Optimism vs. Pessimism

"The optimist proclaims that we live in the best of all possible worlds; and the pessimist fears this is true."

Unfortunately, while testing this answer, I was unable to completely download any video (though partial downloads did work up to the point where they were broken). I suspect a poor network connection and (possibly) poor site design led to the aborted downloads (anecdotally, I encountered several PHP errors unrelated to cURL just browsing the site).

So your mileage with cURL and your chosen site may vary...