instagram-apis
Advanced tools
Comparing version 1.0.3 to 1.0.4
{ | ||
"name": "instagram-apis", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Insatgram library filled with useful Instagram API's", | ||
@@ -17,2 +17,3 @@ "main": "index.js", | ||
"axios": "^0.27.2", | ||
"get-video-duration": "^4.1.0", | ||
"randomstring": "^1.2.2", | ||
@@ -19,0 +20,0 @@ "readline-sync": "^1.4.10", |
@@ -336,3 +336,3 @@ const data = require("./_constants.js"); | ||
this.cookie.split("csrftoken=")[1].split(";")[0] | ||
}&video_result=&device_id=android-8cd32a1ba6669cbe&mutation_token=${context}&_uuid=${v4()}&upload_id=${ | ||
}&video_result=&device_id=android-d502d92d2de2995c&mutation_token=${context}&_uuid=${v4()}&upload_id=${ | ||
this.time | ||
@@ -339,0 +339,0 @@ }&offline_threading_id=${context}`; |
const axios = require("axios"); | ||
const newInboxAPIs = require("./newInboxAPIs.js"); | ||
const {generate} = require("randomstring"); | ||
const { v4 } = require("uuid"); | ||
const { getVideoDurationInSeconds } = require('get-video-duration'); | ||
module.exports = class mediaAPIs extends newInboxAPIs { | ||
@@ -69,2 +73,55 @@ initialize(headers) { | ||
} | ||
async uploadVideoToStory(url) { | ||
let name = new uploadVideoToStory(this.headers); | ||
await name.send(url); | ||
} | ||
} | ||
class uploadVideoToStory { | ||
constructor(headers) { | ||
this.upload_id = `1881${generate({charset: "numeric", length: 9})}` | ||
this.cookie = headers["Cookie"]; | ||
this.uuid = v4() | ||
this.path = `${generate({length: 32}).toLowerCase()}-0-4146567-lessO-${Date.now()}000` | ||
console.log(this.path) | ||
this.mainHeaders = { | ||
"Segment-Start-Offset": "0", | ||
"X-Instagram-Rupload-Params": "", | ||
"Segment-Type": "3", | ||
"Offset": "0", | ||
"User-Agent": "Instagram 177.0.0.30.119 Android", | ||
"Accept-Language": "en-US", | ||
"Host": "i.instagram.com", | ||
"X-FB-HTTP-Engine": "Liger", | ||
"Cookie": this.cookie, | ||
} | ||
} | ||
async getVideoDuration(url) { | ||
let duration = await getVideoDurationInSeconds(url); | ||
return parseInt(duration * 1000) | ||
} | ||
async getStream(url) { | ||
return new Promise((resolve, reject) => { | ||
request.get( | ||
{ | ||
uri: url, | ||
encoding: null, | ||
gzip: true, | ||
}, | ||
(err, resp, body) => { | ||
if (err) reject(err); | ||
else resolve(body); | ||
} | ||
); | ||
}); | ||
} | ||
async send(url) { | ||
this.mainHeaders["X-Instagram-Rupload-Params"] = `{"upload_media_height":"1280","extract_cover_frame":"1","xsharing_user_ids":"[]","upload_media_width":"720","upload_media_duration_ms":"${(await this.getVideoDuration(url))}","content_tags":"use_default_cover","upload_id":"${this.upload_id}","for_album":"1","retry_context":"{\"num_step_auto_retry\":0,\"num_reupload\":0,\"num_step_manual_retry\":0}","media_type":"2"}` | ||
await this.upload() | ||
} | ||
async upload() { | ||
let headers = {...this.mainHeaders}; | ||
headers["X_fb_video_waterfall_id"] = `1966${generate({charset: "numeric", length: 8})}_${generate({length: 12}).toUpperCase()}_Mixed_0` | ||
// console.log(headers) | ||
} | ||
} |
39948
830
6
+ Addedget-video-duration@^4.1.0
+ Added@ffprobe-installer/darwin-arm64@5.0.1(transitive)
+ Added@ffprobe-installer/darwin-x64@5.1.0(transitive)
+ Added@ffprobe-installer/ffprobe@1.4.2(transitive)
+ Added@ffprobe-installer/linux-arm@5.1.0(transitive)
+ Added@ffprobe-installer/linux-arm64@5.1.0(transitive)
+ Added@ffprobe-installer/linux-ia32@5.1.0(transitive)
+ Added@ffprobe-installer/linux-x64@5.1.0(transitive)
+ Added@ffprobe-installer/win32-ia32@5.1.0(transitive)
+ Added@ffprobe-installer/win32-x64@5.1.0(transitive)
+ Addedcross-spawn@7.0.3(transitive)
+ Addedexeca@5.1.1(transitive)
+ Addedget-stream@6.0.1(transitive)
+ Addedget-video-duration@4.1.0(transitive)
+ Addedhuman-signals@2.1.0(transitive)
+ Addedis-stream@2.0.1(transitive)
+ Addedisexe@2.0.0(transitive)
+ Addedmerge-stream@2.0.0(transitive)
+ Addedmimic-fn@2.1.0(transitive)
+ Addednpm-run-path@4.0.1(transitive)
+ Addedonetime@5.1.2(transitive)
+ Addedpath-key@3.1.1(transitive)
+ Addedshebang-command@2.0.0(transitive)
+ Addedshebang-regex@3.0.0(transitive)
+ Addedsignal-exit@3.0.7(transitive)
+ Addedstrip-final-newline@2.0.0(transitive)
+ Addedwhich@2.0.2(transitive)