igdownloader / InstagramDownloader

Firefox and Chrome Extention which creates an download button for instagram images and videos and videos
https://huiibuh.github.io/InstagramDownloader/
790 stars 151 forks source link

It seems that Instagram started throttling video downloading speed since two days ago. #196

Closed LilHayah closed 3 years ago

LilHayah commented 3 years ago

Since two days ago, whenever I tried to download any short or long videos from instagram, the downloading speed was surprisingly slow (40kb/s at most).

At first, I thought it was my network problem. But after I checked everything and found the loading speed was as fast as usual, I just realized that the downloading speed might be throttled no matter you download by an extension or grab the url from that "?__a=1" page)

Is there anyway we can just save the loaded video from browser cache instead of downloading again from the url? Or can we figure out any other workaround? I can't imagine how much time it would take to download an hour-long saved live.

Nissemus commented 3 years ago

I can confirm this problem in Firefox and Chrome. There is also a delay of a few seconds up to several minutes for the Save dialog appearing, depending on how long the video is.

kevinc130 commented 3 years ago

HMM. To combat this is there any way to bulk download from url. ( since the only the individual videos are downloading at around 40 kb/s. )

HuiiBuh commented 3 years ago

I am sorry, but there is nothing I can do to prevent instagram from throttling your download

rayronvictor commented 3 years ago

Hi. What is possible to do is to change the user agent to curl/7.54.

This works here:

$ curl -o video.mp4 VIDEO_URL

Unfortunately, due to a bug in chromium the fetch below will not work:

fetch(VIDEO_URL, {
  headers: {
    'User-Agent': 'curl/7.54'
  }
})

But it looks like in Firefox it will work https://bugzilla.mozilla.org/show_bug.cgi?id=1188932

HuiiBuh commented 3 years ago

@rayronvictor Did you try to set the user agent? I think Instagram checks the referrer which would be the extension and slows down the download because of that.

rayronvictor commented 3 years ago

@HuiiBuh I don't tried yet with fetch, but with curl if you change the user agent from the default curl/7.54 to something the browser use (add -A "Mozilla etc..." to curl command) the download slows down.

This occurs because now Instagram use range requests for video resources. May be this is related to the client support for range requests and not to user agent. But is not related to referer header because if you open the video url in a new tab the download is slow down too.

HuiiBuh commented 3 years ago

@rayronvictor Thanks for your explanation and your investigation. This sounds really promising

rayronvictor commented 3 years ago

@HuiiBuh, I tested on Firefox and worked with:

fetch('https://scontent.cdninstagram.com/v/t50.2886-16/10000000_210748647400973_8000148629428104423_n.mp4?_nc_ht=instagram.fnat1-1.fna.fbcdn.net&_nc_cat=105&_nc_ohc=BpezrlE49oUAX-64ojX&edm=AABBvjUBAAAA&ccb=7-4&oe=60B82936&oh=a57c4d1bda1578ffbb9946c1f6a6bc58&_nc_sid=83d603', {
  headers: {
    'User-Agent': 'curl/7.64.1'
  }
})

11s for 150MB

Captura de Tela 2021-06-01 às 10 51 59

For Chrome, declarativeNetRequest can be used to change the http request headers. Something like this, but I not tested:

{
  "id": 10,
  "priority": 2,
  "action": {
    "type": "modifyHeaders",
    "requestHeaders": [
      { "header": "User-Agent", "operation": "set", "value": "curl/7.64.1" },
    ]
  },
  "condition": { "domain": ["cdninstagram.com", "fbcdn.net"] }
},
rayronvictor commented 3 years ago

I submitted a PR https://github.com/HuiiBuh/InstagramDownloader/issues/196