|
@@ -18,7 +18,6 @@ const url_1 = require("url");
|
|
const util_1 = require("util");
|
|
const util_1 = require("util");
|
|
const instagram_id_to_url_segment_1 = require("instagram-id-to-url-segment");
|
|
const instagram_id_to_url_segment_1 = require("instagram-id-to-url-segment");
|
|
Object.defineProperty(exports, "idToUrlSegment", { enumerable: true, get: function () { return instagram_id_to_url_segment_1.instagramIdToUrlSegment; } });
|
|
Object.defineProperty(exports, "idToUrlSegment", { enumerable: true, get: function () { return instagram_id_to_url_segment_1.instagramIdToUrlSegment; } });
|
|
-Object.defineProperty(exports, "urlSegmentToId", { enumerable: true, get: function () { return instagram_id_to_url_segment_1.urlSegmentToInstagramId; } });
|
|
|
|
const instagram_private_api_1 = require("instagram-private-api");
|
|
const instagram_private_api_1 = require("instagram-private-api");
|
|
const socks_proxy_agent_1 = require("socks-proxy-agent");
|
|
const socks_proxy_agent_1 = require("socks-proxy-agent");
|
|
const loggers_1 = require("./loggers");
|
|
const loggers_1 = require("./loggers");
|
|
@@ -45,6 +44,9 @@ const linkBuilder = (config) => {
|
|
return `https://www.instagram.com/p/${config.postUrlSegment}/`;
|
|
return `https://www.instagram.com/p/${config.postUrlSegment}/`;
|
|
};
|
|
};
|
|
exports.linkBuilder = linkBuilder;
|
|
exports.linkBuilder = linkBuilder;
|
|
|
|
+const urlSegmentToId = (urlSegment) => urlSegment.length <= 28 ?
|
|
|
|
+ instagram_id_to_url_segment_1.urlSegmentToInstagramId(urlSegment) : instagram_id_to_url_segment_1.urlSegmentToInstagramId(urlSegment.slice(0, -28));
|
|
|
|
+exports.urlSegmentToId = urlSegmentToId;
|
|
class SessionManager {
|
|
class SessionManager {
|
|
constructor(client, file, credentials, codeServicePort) {
|
|
constructor(client, file, credentials, codeServicePort) {
|
|
this.init = () => {
|
|
this.init = () => {
|
|
@@ -227,7 +229,7 @@ class default_1 {
|
|
next(),
|
|
next(),
|
|
]))(() => util_1.promisify(setTimeout)(2000).then(() => page.waitForSelector('article', { timeout: getTimeout() })))).then(handle => {
|
|
]))(() => util_1.promisify(setTimeout)(2000).then(() => page.waitForSelector('article', { timeout: getTimeout() })))).then(handle => {
|
|
const postHandler = () => {
|
|
const postHandler = () => {
|
|
- const toId = (href) => { var _a; return instagram_id_to_url_segment_1.urlSegmentToInstagramId(((_a = /\/p\/(.*)\/$/.exec(href)) !== null && _a !== void 0 ? _a : [, ''])[1]); };
|
|
|
|
|
|
+ const toId = (href) => { var _a; return urlSegmentToId(((_a = /\/p\/(.*)\/$/.exec(href)) !== null && _a !== void 0 ? _a : [, ''])[1]); };
|
|
if (targetId === '0') {
|
|
if (targetId === '0') {
|
|
return handle.$$eval('a', as => as.filter(a => !a.querySelector('[aria-label="IGTV"]'))[0].href).then(href => Number(toId(href)) > 0 ? [toId(href)] : []);
|
|
return handle.$$eval('a', as => as.filter(a => !a.querySelector('[aria-label="IGTV"]'))[0].href).then(href => Number(toId(href)) > 0 ? [toId(href)] : []);
|
|
}
|
|
}
|
|
@@ -272,7 +274,7 @@ class default_1 {
|
|
this.queryUser = (username) => this.client.user.searchExact(username)
|
|
this.queryUser = (username) => this.client.user.searchExact(username)
|
|
.then(user => `${user.username}:${user.pk}`);
|
|
.then(user => `${user.username}:${user.pk}`);
|
|
this.workOnMedia = (lazyMediaItems, sendMedia) => this.webshot(lazyMediaItems, sendMedia, this.webshotDelay);
|
|
this.workOnMedia = (lazyMediaItems, sendMedia) => this.webshot(lazyMediaItems, sendMedia, this.webshotDelay);
|
|
- this.urlSegmentToId = instagram_id_to_url_segment_1.urlSegmentToInstagramId;
|
|
|
|
|
|
+ this.urlSegmentToId = urlSegmentToId;
|
|
this.lazyGetMediaById = (id) => ({
|
|
this.lazyGetMediaById = (id) => ({
|
|
pk: id,
|
|
pk: id,
|
|
item: () => this.client.media.info(id).then(media => {
|
|
item: () => this.client.media.info(id).then(media => {
|
|
@@ -281,7 +283,7 @@ class default_1 {
|
|
return mediaItem;
|
|
return mediaItem;
|
|
}),
|
|
}),
|
|
});
|
|
});
|
|
- this.getMedia = (segmentId, sender) => this.workOnMedia([this.lazyGetMediaById(instagram_id_to_url_segment_1.urlSegmentToInstagramId(segmentId))], sender);
|
|
|
|
|
|
+ this.getMedia = (segmentId, sender) => this.workOnMedia([this.lazyGetMediaById(urlSegmentToId(segmentId))], sender);
|
|
this.sendMedia = (source, ...to) => (msg, text, author) => {
|
|
this.sendMedia = (source, ...to) => (msg, text, author) => {
|
|
to.forEach(subscriber => {
|
|
to.forEach(subscriber => {
|
|
logger.info(`pushing data${source ? ` of ${source}` : ''} to ${JSON.stringify(subscriber)}`);
|
|
logger.info(`pushing data${source ? ` of ${source}` : ''} to ${JSON.stringify(subscriber)}`);
|
|
@@ -438,7 +440,7 @@ class default_1 {
|
|
}
|
|
}
|
|
return '找不到请求的媒体,它可能已被删除。';
|
|
return '找不到请求的媒体,它可能已被删除。';
|
|
};
|
|
};
|
|
- exports.getPostOwner = (segmentId) => this.client.media.info(instagram_id_to_url_segment_1.urlSegmentToInstagramId(segmentId))
|
|
|
|
|
|
+ exports.getPostOwner = (segmentId) => this.client.media.info(urlSegmentToId(segmentId))
|
|
.then(media => media.items[0].user)
|
|
.then(media => media.items[0].user)
|
|
.then(user => `${user.username}:${user.pk}`)
|
|
.then(user => `${user.username}:${user.pk}`)
|
|
.catch((err) => { throw Error(parseMediaError(err)); });
|
|
.catch((err) => { throw Error(parseMediaError(err)); });
|