I've unfortunately found a very severe bug in this library.
This is very serious. It's a silent bug, which means lots of you don't even know you have been receiving bad media replies from Instagram due to this library and the way Instagram handles media delivery.
Instagram's API may only return low/standard-resolution videos/media when using this library. No HD.
The reason: They check the user-agent for specific device models. And this library sends BAD device models.
I tested this by requesting getUserFeed() on a timeline with HD videos. I edited the User-Agent to various strings until I found what makes Instagram deliver HD video.
Here's an example of a bad user agent:
Instagram 10.8.0 Android (18/4.3; 320dpi; 720x1280; Lenovo; S820_AMX_ROW; Lenovo S820; qcom; en_US)
The part they check is: "S820_AMX_ROW" (which seems to be a model summary/identifier for the device). They do not care about ANY of the other info in the line (editing the other info doesn't affect HD delivery).
If the part I pointed at isn't a "HD capable" (in Instagram's eyes) device, then they send you only non-HD media. They won't even list any HD alternatives. Because they think you device can't handle it.
This can be checked by making requests such as getUserFeed(), and looking at the video_versions arrays on profiles that have HD videos. If you've been given a bad random device model by this library, you'll only get SD videos.
This is super bad. It means the random device selection in this library (a good security feature) is destroying HD quality for random users.
Any ideas how we can fix this?
Perhaps make a new device list with just modern 2016+ Android Tablets (no phones), all with HD screens. Then they will perhaps deliver HD URLs for all of those devices. But each device ID would need individual testing to be sure it gets HD.
Or perhaps always identify as a specific model with HD capability...
I have done more testing: This situation only affects video files. Not photos (jpgs). Not video thumbnails (jpg). Just videos (mp4s).
So bad device IDs = no HD video links in video_versions. Every video will be delivered only as SD. Bad problem. But everything else is unaffected, thankfully.
Okay the solution will be:
Keep about 5 user agents representing MODERN devices (popular ones made in 2016+) that fit the criteria above.
Here's a known GOOD agent:
Instagram 10.8.0 Android (23/6.0.1; 640dpi; 1440x2560; samsung; SM-G935F; hero2lte; samsungexynos8890; en_US)
Here's a known BAD agent:
Instagram 10.8.0 Android (18/4.3; 320dpi; 720x1280; Lenovo; S820_AMX_ROW; Lenovo S820; qcom; en_US)
And again, the part Instagram actually checks is the MODEL (5th field), in other words "SM-G935F" and "S820_AMX_ROW".
Any takers? I'm just putting this research here. I have no time to do it.
Do you have a list of 'good' devices?
Yes, I implemented a list here: https://github.com/mgp25/Instagram-API/blob/master/src/Devices/GoodDevices.php
And tests here: https://github.com/mgp25/Instagram-API/blob/master/devtools/checkDevices.php
Good luck and have fun porting it to Node!
@SteveJobzniak Whether this data can affect the quality of the uploading video?
I don't know about upload, but I doubt that the device matters during file-uploads.
But it definitely affects the quality of downloading videos. You only get bad (low quality) download URLs if you have a bad device.
Most helpful comment
I have done more testing: This situation only affects video files. Not photos (jpgs). Not video thumbnails (jpg). Just videos (mp4s).
So bad device IDs = no HD video links in video_versions. Every video will be delivered only as SD. Bad problem. But everything else is unaffected, thankfully.