downthemall / anticontainer

DownThemAll! AntiContainer (Extension to a Firefox, Seamonkey extension)
Mozilla Public License 2.0
93 stars 41 forks source link

instagram #105

Closed yAydAy closed 8 years ago

yAydAy commented 8 years ago

So far as I can tell, the Instagram plugin no longer works. Instagram now also features higher quality images since the previous plugin was developed. In most cases now with Instagram the highest quality image is accessible by slightly manipulating the URL. A URL like: https://scontent-atl3-1.cdninstagram.com/hphotos-xpa1/t51.2885-15/s640x640/sh0.08/e35/1515638_984503554958283_720115891_n.jpg ...may be manipulated into a higher quality image by removing sections of the URL: https://scontent-atl3-1.cdninstagram.com/hphotos-xpa1/1515638_984503554958283_720115891_n.jpg This image stems from within the page of the following link: https://www.instagram.com/p/_4hlQ9K89T/ Some Instagram links now also include a "?taken-by=" section: https://www.instagram.com/p/_4hlQ9K89T/?taken-by=kateupton

Can this preference for the highest quality image be reflected in a potential new plugin for Instagram?

MegaScience commented 8 years ago

I wrote this up when Instagram added video support and have been using it since. You could use it as an alternative until the default one is updated:

{
    "type": "expander",
    "ns": "http://www.instagram.com/",
    "author": "MegaScience",
    "prefix": "instagram.com (Image/Video Expander)",
    "match": "^https?://(?:[\\w\\d]+\\.)?(?:instagram\\.com|instagr\\.am)/p/",
    "static": true,
    "finder": "property=\"og:(?:video|image)\" content=\"(.+?)\"",
    "generator": "{1}"
}
yAydAy commented 8 years ago

This works perfectly for downloading content from Instagram. It only needs a way for the content to be modified to their highest quality. Is there any way to add that to the script?

For example: https://www.instagram.com/p/BAk18cbuUFK/ You can see, the image inside this page appears as 1080x1080 here: https://scontent-lhr3-1.cdninstagram.com/hphotos-xap1/t51.2885-15/s1080x1080/e35/12523554_1671341519781189_473130418_n.jpg If you remove everything past "hphotos-xap1" and until the final slash, you are left with an image over twice the size: https://scontent-lhr3-1.cdninstagram.com/hphotos-xap1/12523554_1671341519781189_473130418_n.jpg

MegaScience commented 8 years ago

@yAydAy Well that complicates this a little, but I've adjusted it. I tested what was required in the URLs for images and videos, and determined that currently Instagram only requires the cache domain, "/hphotos/", and the filename. This trims it down that far. The regular expression is a bit complicated, but I'm hoping it is futureproofed against most format changes they might commit:

{
    "type": "expander",
    "ns": "http://www.instagram.com/",
    "author": "MegaScience",
    "prefix": "instagram.com (Image/Video Expander)",
    "match": "^https?://(?:[\\w\\d]+\\.)?(?:instagram\\.com|instagr\\.am)/p/",
    "static": true,
    "finder": "property=\"og:(?:video|image)\" content=\"(.+?)\\.com\/.*?\/((?:[\\d]+_){3}[\\w]\\.[\\w\\d]+)(?:\\?.+?)?\"",
    "generator": "{1}.com/hphotos/{2}"
}

Problems I ran into: Originally, I found I could remove even "/hphotos/", but later determined this to be the server allowing me to see them after viewing other variations. Also, some files don't include "/hphotos/" but removing the other parts broke the URL. It still works if I add it, so I made sure not to require it but add it after.

Edit: Noticed it wasn't working and checked. Simple fix: They added a ? cache parameter to the URL, so now I'm matching that optionally.

nmaier commented 8 years ago

@MegaScience Can you do a Pull Request please?