New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

twitter-downloader

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

twitter-downloader - npm Package Compare versions

Comparing version 1.1.5 to 1.1.6

lib/contants/index.d.ts

3

lib/utils/getAuthorization.d.ts

@@ -1,1 +0,2 @@

export declare const getAuthorization: () => Promise<any>;
export declare const getGuestTokenAuthorization: () => Promise<any>;
export declare const getTwitterAuthorization: () => Promise<any>;

@@ -6,8 +6,13 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.getAuthorization = void 0;
exports.getTwitterAuthorization = exports.getGuestTokenAuthorization = void 0;
const axios_1 = __importDefault(require("axios"));
const getAuthorization = async () => {
const getGuestTokenAuthorization = async () => {
const { data } = await axios_1.default.get("https://pastebin.com/raw/nz3ApKQM");
return data;
};
exports.getAuthorization = getAuthorization;
exports.getGuestTokenAuthorization = getGuestTokenAuthorization;
const getTwitterAuthorization = async () => {
const { data } = await axios_1.default.get("https://pastebin.com/raw/Bu7XFnpE");
return data;
};
exports.getTwitterAuthorization = getTwitterAuthorization;

@@ -14,3 +14,3 @@ "use strict";

headers: {
Authorization: await (0, getAuthorization_1.getAuthorization)(),
Authorization: await (0, getAuthorization_1.getGuestTokenAuthorization)(),
},

@@ -17,0 +17,0 @@ });

import { Twitter } from "../types/twitter";
type Config = {
authorization: string;
cookie: string;
};
import { Config } from "../types/config";
export declare const TwitterDL: (url: string, config?: Config) => Promise<Twitter>;
export {};

@@ -9,27 +9,3 @@ "use strict";

const index_1 = require("./index");
const _twitterapi = `https://twitter.com/i/api/graphql/DJS3BdhUhcaEpZ7B7irJDg/TweetResultByRestId`;
const variables = (id) => {
return { tweetId: id, withCommunity: false, includePromotedContent: false, withVoice: false };
};
const features = {
creator_subscriptions_tweet_preview_api_enabled: true,
tweetypie_unmention_optimization_enabled: true,
responsive_web_edit_tweet_api_enabled: true,
graphql_is_translatable_rweb_tweet_is_translatable_enabled: true,
view_counts_everywhere_api_enabled: true,
longform_notetweets_consumption_enabled: true,
responsive_web_twitter_article_tweet_consumption_enabled: false,
tweet_awards_web_tipping_enabled: false,
freedom_of_speech_not_reach_fetch_enabled: true,
standardized_nudges_misinfo: true,
tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled: true,
longform_notetweets_rich_text_read_enabled: true,
longform_notetweets_inline_media_enabled: true,
responsive_web_graphql_exclude_directive_enabled: true,
verified_phone_label_enabled: false,
responsive_web_media_download_video_enabled: false,
responsive_web_graphql_skip_user_profile_image_extensions_enabled: false,
responsive_web_graphql_timeline_navigation_enabled: true,
responsive_web_enhance_cards_enabled: false,
};
const contants_1 = require("../contants");
const millsToMinutesAndSeconds = (millis) => {

@@ -40,11 +16,19 @@ const minutes = Math.floor(millis / 60000);

};
const TwitterDL = (url, config) => new Promise(async (resolve, reject) => {
const _twitterapi = `https://twitter.com/i/api/graphql`;
const _tweetresultbyrestid = "/TweetResultByRestId";
const _id = "/DJS3BdhUhcaEpZ7B7irJDg";
const TwitterDL = (url, config) => new Promise(async (resolve) => {
const id = url.match(/\/([\d]+)/);
const regex = /^(https?:\/\/)?(www\.)?(m\.)?twitter\.com\/\w+/;
if (!regex.test(url))
return reject("Invalid twitter url!");
return resolve({ status: "error", message: "Invalid URL!" });
if (!id)
return reject("There was an error getting twitter id. Make sure your twitter url is correct!");
return resolve({
status: "error",
message: "There was an error getting twitter id. Make sure your twitter url is correct!",
});
const guest_token = await (0, index_1.getGuestToken)();
const csrf_token = config?.cookie ? config.cookie.match(/(?:^|; )ct0=([^;]*)/) : "";
const csrf_token = config?.cookie
? config.cookie.match(/(?:^|; )ct0=([^;]*)/)
: "";
if (!guest_token)

@@ -55,10 +39,12 @@ return resolve({

});
(0, axios_1.default)(_twitterapi, {
(0, axios_1.default)(_twitterapi + _id + _tweetresultbyrestid, {
method: "GET",
params: {
variables: JSON.stringify(variables(id[1])),
features: JSON.stringify(features),
variables: JSON.stringify((0, contants_1.variables)(id[1])),
features: JSON.stringify(contants_1.features),
},
headers: {
Authorization: config?.authorization ? config.authorization : await (0, index_1.getAuthorization)(),
Authorization: config?.authorization
? config.authorization
: await (0, index_1.getTwitterAuthorization)(),
Cookie: config?.cookie ? config.cookie : "",

@@ -80,6 +66,7 @@ "x-csrf-token": csrf_token ? csrf_token[1] : "",

status: "error",
message: "This tweet contains sensitive content!",
message: "This tweet contains sensitive content! Please use cookies to avoid errors!",
});
}
const result = data.data.tweetResult.result.__typename === "TweetWithVisibilityResults"
const result = data.data.tweetResult.result.__typename ===
"TweetWithVisibilityResults"
? data.data.tweetResult.result.tweet

@@ -114,9 +101,16 @@ : data.data.tweetResult.result;

if (v.type === "photo") {
return { type: v.type, image: v.media_url_https, expandedUrl: v.expanded_url };
return {
type: v.type,
image: v.media_url_https,
expandedUrl: v.expanded_url,
};
}
else {
const isGif = v.type === "animated_gif";
const videos = v.video_info.variants
.filter((video) => video.content_type === "video/mp4")
.map((variants) => {
let quality = variants.url.match(/\/([\d]+x[\d]+)\//)[1];
let quality = isGif
? `${v.original_info.width}x${v.original_info.height}`
: variants.url.match(/\/([\d]+x[\d]+)\//)[1];
return {

@@ -123,0 +117,0 @@ bitrate: variants.bitrate,

{
"name": "twitter-downloader",
"version": "1.1.5",
"version": "1.1.6",
"description": "Scraper for download Media from Twitter",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -0,0 +0,0 @@ <h1 align="center">

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc