diff --git a/src/lib/utils/body.js b/src/lib/utils/body.js index 32ebdf0..3137a6d 100644 --- a/src/lib/utils/body.js +++ b/src/lib/utils/body.js @@ -8,10 +8,13 @@ function selectExtractor(text) { const sharedDataString = "window._sharedData = " const preloaderString = "PolarisQueryPreloaderCache" const iWebString = "web_profile_info" + const rssbridgeCacheString = "window._rssbridgeCache = "; if (text.includes(sharedDataString)) { log(`"${sharedDataString}" detected, using shared data extractor`, 'DEBUG') return extractSharedData(text) + } else if (text.includes(rssbridgeCacheString)) { + return extractRSSBridgeData(text) } else if (text.includes(preloaderString)) { log(`"${preloaderString}" detected, using preloader extractor`, 'DEBUG') return extractPreloader(text) @@ -19,10 +22,34 @@ function selectExtractor(text) { log(`"${iWebString}" detected, using iWeb extractor`, 'DEBUG') return extractIWeb(text) } else { throw constants.symbols.extractor_results.NO_SHARED_DATA } } +/** + * @param {string} text + * @returns {{status: symbol, value: any}} + */ +function extractRSSBridgeData(text) { + const parser = new Parser(text) + const index = parser.seek("window._rssbridgeCache = ", {moveToMatch: true, useEnd: true}) + if (index === -1) { + throw constants.symbols.extractor_results.NO_SHARED_DATA + } + parser.store() + const end = parser.seek(";") + parser.restore() + const sharedDataString = parser.slice(end - parser.cursor) + const sharedData = JSON.parse(sharedDataString) + // check for alternate form of age restrictions + if (sharedData.data && sharedData.data.HttpGatedContentPage) { + // ideally extracting the age should be done here, but for the web ui it doesn't matter + throw constants.symbols.extractor_results.AGE_RESTRICTED + } + return sharedData.data.user +} + /** * @param {string} text * @returns {{status: symbol, value: any}} diff --git a/src/lib/utils/torswitcher.js b/src/lib/utils/torswitcher.js index 850b22d..e578bbc 100644 --- a/src/lib/utils/torswitcher.js +++ b/src/lib/utils/torswitcher.js @@ -28,7 +28,9 @@ class TorSwitcher { if (this.torManager && constants.tor.for[type]) { return this.torManager.request(url, test) } else { - return request(url).check(test) + return request("https://feed.eugenemolotov.ru/?action=instagram-shared-data&url=" + url).check(test) } } }