Skip to content

Commit

Permalink
v2022.10.28 ☀️ Launch into the sun
Browse files Browse the repository at this point in the history
[instangram] Support for the latest backend version of instagram.
New versioning.
Fixed stories video detection. #23
Fixed wrong order capturing. #24
  • Loading branch information
saschaheim committed Oct 28, 2022
1 parent b84d8d7 commit b85b172
Show file tree
Hide file tree
Showing 15 changed files with 174 additions and 227 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# <img style="float: left; vertical-align: bottom; " width="35" src="https://upload.wikimedia.org/wikipedia/commons/4/4c/Typescript_logo_2020.svg"> [instantgram] v12.1.0 :rocket: Launch to the moon
![GitHub release](https://img.shields.io/badge/release-v12.1.0-green)
# <img style="float: left; vertical-align: bottom; " width="35" src="https://upload.wikimedia.org/wikipedia/commons/4/4c/Typescript_logo_2020.svg"> [instantgram] v2022.10.28 :rocket: Launch into the sun
![GitHub release](https://img.shields.io/badge/release-v2022.10.28-green)

![badge](https://img.shields.io/badge/for-instagram-yellow.svg?style=flat-square)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](http://standardjs.com/)
Expand Down Expand Up @@ -39,6 +39,10 @@ With this version we support all modern browsers that have ECMAScript 2015 (es6)
Read [CONTRIBUTING.md](CONTRIBUTING.md) for more information. :heart:

## Changelog
- v2022.10.28 - [instangram] Support for the latest backend version of instagram. \
New versioning.
Fixed stories video detection. #23
Fixed wrong order capturing. #24
- v12.1.0 - [instangram] Support for the latest backend version of instagram.
- v12.0.0 - [instangram] Rewrite of instantgram to support last backend of insta. \
Profile page bulk downloader dropped because insta deleted all api around them.
Expand Down
2 changes: 1 addition & 1 deletion dist/main.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions index.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions lang/de-de/index.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions lang/en-us/index.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions lang/es-ar/index.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions lang/pt-br/index.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "instantgram",
"version": "12.1.0",
"version": "2022.10.28",
"description": "A bookmarklet for download photos in Instagram",
"author": "Matheus Falcão and from 4.0.0 Sascha Heim",
"homepage": "https://thinkbig-company.github.io/instantgram/",
Expand Down
2 changes: 1 addition & 1 deletion src/_langs/partials/button.html

Large diffs are not rendered by default.

129 changes: 0 additions & 129 deletions src/helpers/getBlobVideoUrl.ts

This file was deleted.

65 changes: 65 additions & 0 deletions src/helpers/getVideoUrl.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import getPath from "../helpers/getPath"

async function getVideoUrl(el: HTMLVideoElement, callback: any) {
// No blob video but src return it
if (el.src && !el.src.startsWith("blob:")) {
callback(el.src)

return false
}

const instanceKey = Object.keys(el).find(key => key.includes('Instance') || key.includes('Fiber'))
const $react = el[instanceKey]

// Found mpd manifest, so extract our magic
if ($react.return.return.memoizedProps.manifest) {
var domManifestParser = new DOMParser().parseFromString($react.return.return.memoizedProps.manifest, "text/xml")
var s = Array.from(domManifestParser.querySelectorAll('Representation[mimeType="video/mp4"][FBQualityClass="hd"]')).map(function l(_e) {
var z, nope
return {
quality: _e.getAttribute("FBQualityClass"),
bandwidth: parseInt(_e.getAttribute("bandwidth")),
baseUrl: null === (nope = null === (z = _e.querySelector("BaseURL")) || void 0 === z ? void 0 : z.textContent) || void 0 === nope ? void 0 : nope.trim()
}
}).filter(function (e) {
return e.baseUrl
})

var lol
callback(s.sort(function compare(x, y) {
return "hd" === x.quality && "hd" !== y.quality ? -1 : "hd" !== x.quality && "hd" === y.quality ? 1 : y.bandwidth - x.bandwidth
}), null === (lol = s[0]) || void 0 === lol ? void 0 : lol.baseUrl)
} else {
let $videoURL: string | any[]
let $videoType: string

if ($react.return.return.memoizedProps.hdSrc) {
$videoURL = $react.return.return.memoizedProps.hdSrc
$videoType = 'hd'
} else if ($react.return.return.memoizedProps.sdSrc) {
$videoURL = $react.return.return.memoizedProps.sdSrc
$videoType = 'sd'
} else if ($react.return.return.memoizedProps.children[0].props.fallbackSrc) {
$videoURL = $react.return.return.memoizedProps.children[0].props.fallbackSrc
$videoType = 'fallback'
} else {
$videoURL = null
$videoType = null
}

if ($videoURL.length > 80) {
if ($videoType == 'fallback') {
/* Fix error network error since mai 2021 cannot download */
let fixedUrl = "https://scontent.cdninstagram.com" + getPath($react.return.return.memoizedProps.children[0].props.fallbackSrc, "unknown")
callback(fixedUrl)
} else {
callback($videoURL)
}
} else {
callback(null)
}
}

return false
}
export default getVideoUrl
98 changes: 32 additions & 66 deletions src/modules/MediaScanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { PostScanner } from "./PostScanner"
import { StoryScanner } from "./StoryScanner"
import { Modal } from "../components/Modal"
import { MediaType } from "../model/mediaType"
import getBlobVideoUrl from "../helpers/getBlobVideoUrl"
import getVideoUrl from "../helpers/getVideoUrl"
import getHighestResImg from "../helpers/getHighestResImg"
import getPath from "../helpers/getPath"
import localize from "../helpers/localize"
Expand Down Expand Up @@ -70,7 +70,7 @@ export class MediaScanner implements Module {
}

if (program.regexPostPath.test(program.path)) {
new PostScanner().execute(program, isModal, function (_scannerFound: boolean, foundMediaElem: any, foundMediaType: MediaType, _scannerProgram: Program) {
new PostScanner().execute(program, isModal, function (_scannerFound: boolean, foundMediaElem: any, foundMediaType: MediaType, _scannerProgram: Program) {
mediaObj.mediaEl = foundMediaElem
mediaObj.mediaType = foundMediaType
})
Expand Down Expand Up @@ -110,76 +110,42 @@ export class MediaScanner implements Module {
}

if (mediaURL != null && mediaURL.length > 10) {
if (mediaURL.indexOf("blob:") !== -1) {
const that = this
let that = this

getVideoUrl(mediaObj.mediaEl, function (callbackData: any) {
found = true
program.foundImage = false
program.foundVideo = true
program.foundByModule = that.getName()

this.modal.heading = [
`<h5>[instantgram] <span style="float:right">v${program.VERSION}</span></h5>`,
]
this.modal.content = [
"<p style='margin:0;text-align:center'>" +
"<img src='https://i.giphy.com/SolJ197tbbfTqcdbzq.gif' alt='Loading' />" +
"</p>",
"<h4 style='font-weight:bold;text-align:center'>" +
localize("modules.modal@isLoading") +
"<span id='loading_dot' style='position:fixed'></span></h4>",
]
this.modal.open()

setTimeout(function () {
//that.modal.close()

getBlobVideoUrl(mediaObj.mediaEl, $articles, selectedCarouselIndex,
function (scrapedBlobVideoUrl: string) {
//clearInterval(loadingDots)

if (scrapedBlobVideoUrl) {
that.modal.close()

/* Fix error network error since mai 2021 cannot download */
let _newVideoUrl = "https://scontent.cdninstagram.com" + getPath(scrapedBlobVideoUrl, "unknown")

callback(found, _newVideoUrl, program)
} else {
that.modal.heading = [
`<h5>[instantgram] <span style="float:right">v${program.VERSION}</span></h5>`,
]
that.modal.content = [
localize("index#program#blob@alert_cannotDownload"),
]
that.modal.contentStyle = "text-align:center"
that.modal.buttonList = [
{
active: true,
text: "Ok",
},
]
that.modal.open()

callback(found, null, program)
}
}
)
}, 500)
} else {
// Fix url timestamp error or signature mismatch
mediaURL = mediaURL.replace("amp", "&")

found = true
program.foundImage = false
program.foundVideo = true
program.foundByModule = this.getName()

/* Fix error network error since mai 2021 cannot download */
let _newVideoUrl = "https://scontent.cdninstagram.com" + getPath(mediaURL, "unknown")

callback(found, _newVideoUrl, program)
}
let videoURL
if (typeof callbackData === 'string' || callbackData instanceof String) {
videoURL = callbackData
} else {
videoURL = callbackData[0].baseUrl && callbackData[0].baseUrl.length > 80 ? callbackData[0].baseUrl : null
}

if (videoURL) {
callback(found, videoURL, program)
} else {
that.modal.heading = [
`<h5>[instantgram] <span style="float:right">v${program.VERSION}</span></h5>`,
]
that.modal.content = [
localize("index#program#blob@alert_cannotDownload"),
]
that.modal.contentStyle = "text-align:center"
that.modal.buttonList = [
{
active: true,
text: "Ok",
},
]
that.modal.open()

callback(found, null, program)
}
})
} else {
found = false
program.foundImage = false
Expand Down
Loading

0 comments on commit b85b172

Please sign in to comment.