@media-downloaders/v2 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.old/index old.js +439 -0
- package/.old/index old2.js +528 -0
- package/.old/index.js +277 -0
- package/.old/old.js +513 -0
- package/.old/package.json +38 -0
- package/README.md +133 -0
- package/index.js +641 -0
- package/instagramcakkatrok.js +25 -0
- package/instagramcustom.js +27 -0
- package/package.json +40 -0
- package/tiktokcustom.js +114 -0
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@media-downloaders/v2",
|
|
3
|
+
"version": "2.0.1",
|
|
4
|
+
"description": "download videos from URLs and autocrop (Instagram, YouTube, TikTok, X, etc.) to send directly to Discord or other!",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/md-mostakim-islam-sagor/media-downloader.git"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"discord",
|
|
15
|
+
"media",
|
|
16
|
+
"download",
|
|
17
|
+
"downloader",
|
|
18
|
+
"instagram",
|
|
19
|
+
"tiktok",
|
|
20
|
+
"youtube",
|
|
21
|
+
"video"
|
|
22
|
+
],
|
|
23
|
+
"author": "MOSTAKIM",
|
|
24
|
+
"license": "ISC",
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/md-mostakim-islam-sagor/media-downloader/issues"
|
|
27
|
+
},
|
|
28
|
+
"homepage": "https://github.com/md-mostakim-islam-sagor/media-downloader#readme",
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"ab-downloader": "^1.0.1",
|
|
31
|
+
"axios": "^1.6.2",
|
|
32
|
+
"btch-downloader": "^6.0.22",
|
|
33
|
+
"cakkatrok-instagram-downloader": "^2.0.2",
|
|
34
|
+
"cheerio": "^1.1.2",
|
|
35
|
+
"ffmpeg-ffprobe-static": "^6.1.1-rc.5",
|
|
36
|
+
"fluent-ffmpeg": "^2.1.3",
|
|
37
|
+
"twitter-downloader": "^1.1.8",
|
|
38
|
+
"ytdl-core": "npm:@distube/ytdl-core@^4.16.9"
|
|
39
|
+
}
|
|
40
|
+
}
|
package/tiktokcustom.js
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
const axios = require('axios');
|
|
2
|
+
|
|
3
|
+
function extractTikTokVideoId(input) {
|
|
4
|
+
if (!input || typeof input !== 'string') return null;
|
|
5
|
+
|
|
6
|
+
const trimmed = input.trim();
|
|
7
|
+
|
|
8
|
+
if (/^\d{5,}$/.test(trimmed)) return trimmed;
|
|
9
|
+
|
|
10
|
+
const match1 = trimmed.match(/\/video\/(\d{5,})/);
|
|
11
|
+
if (match1 && match1[1]) return match1[1];
|
|
12
|
+
|
|
13
|
+
const match2 = trimmed.match(/[?&]item_id=(\d{5,})/);
|
|
14
|
+
if (match2 && match2[1]) return match2[1];
|
|
15
|
+
|
|
16
|
+
const match3 = trimmed.match(/(\d{10,})/);
|
|
17
|
+
if (match3 && match3[1]) return match3[1];
|
|
18
|
+
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function findFirstMediaUrl(value) {
|
|
23
|
+
if (!value) return null;
|
|
24
|
+
if (typeof value === 'string') {
|
|
25
|
+
if (/^https?:\/\//i.test(value)) return value;
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
if (Array.isArray(value)) {
|
|
29
|
+
for (const v of value) {
|
|
30
|
+
const found = findFirstMediaUrl(v);
|
|
31
|
+
if (found) return found;
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
if (typeof value === 'object') {
|
|
36
|
+
const candidates = [
|
|
37
|
+
value.url,
|
|
38
|
+
value.play,
|
|
39
|
+
value.playUrl,
|
|
40
|
+
value.play_url,
|
|
41
|
+
value.download,
|
|
42
|
+
value.downloadUrl,
|
|
43
|
+
value.download_url,
|
|
44
|
+
value.video,
|
|
45
|
+
value.videoUrl,
|
|
46
|
+
value.video_url,
|
|
47
|
+
value.wmplay,
|
|
48
|
+
value.wmPlay,
|
|
49
|
+
value.hdplay,
|
|
50
|
+
value.hdPlay,
|
|
51
|
+
value.hd
|
|
52
|
+
];
|
|
53
|
+
|
|
54
|
+
for (const c of candidates) {
|
|
55
|
+
const found = findFirstMediaUrl(c);
|
|
56
|
+
if (found) return found;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
for (const key of Object.keys(value)) {
|
|
60
|
+
const found = findFirstMediaUrl(value[key]);
|
|
61
|
+
if (found) return found;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
module.exports = async function tiktokCustom(tiktokUrlOrId) {
|
|
68
|
+
try {
|
|
69
|
+
const id = extractTikTokVideoId(tiktokUrlOrId);
|
|
70
|
+
if (!id) throw new Error('Invalid TikTok URL/ID');
|
|
71
|
+
|
|
72
|
+
const apiUrl = `https://api.twitterpicker.com/tiktok/mediav2?id=${encodeURIComponent(id)}`;
|
|
73
|
+
|
|
74
|
+
const headers = {
|
|
75
|
+
'accept': '*/*',
|
|
76
|
+
'accept-language': 'fr-FR,fr;q=0.6',
|
|
77
|
+
'origin': 'https://tiktokdownloader.com',
|
|
78
|
+
'priority': 'u=1, i',
|
|
79
|
+
'sec-ch-ua': '"Not(A:Brand";v="8", "Chromium";v="144", "Brave";v="144"',
|
|
80
|
+
'sec-ch-ua-mobile': '?0',
|
|
81
|
+
'sec-ch-ua-platform': '"Windows"',
|
|
82
|
+
'sec-fetch-dest': 'empty',
|
|
83
|
+
'sec-fetch-mode': 'cors',
|
|
84
|
+
'sec-fetch-site': 'cross-site',
|
|
85
|
+
'sec-gpc': '1',
|
|
86
|
+
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36'
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const response = await axios.get(apiUrl, { headers, timeout: 15000 });
|
|
90
|
+
const data = response && response.data ? response.data : null;
|
|
91
|
+
if (!data) throw new Error('No response from twitterpicker');
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
// Prefer no-watermark video URL when available
|
|
96
|
+
if (data.video_no_watermark && typeof data.video_no_watermark === 'object') {
|
|
97
|
+
const directNoWm = data.video_no_watermark.url;
|
|
98
|
+
if (typeof directNoWm === 'string' && /^https?:\/\//i.test(directNoWm)) return directNoWm;
|
|
99
|
+
|
|
100
|
+
if (Array.isArray(data.video_no_watermark_alternatives)) {
|
|
101
|
+
for (const alt of data.video_no_watermark_alternatives) {
|
|
102
|
+
if (alt && typeof alt.url === 'string' && /^https?:\/\//i.test(alt.url)) return alt.url;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const mediaUrl = findFirstMediaUrl(data);
|
|
108
|
+
if (!mediaUrl) throw new Error('Media URL not found');
|
|
109
|
+
|
|
110
|
+
return mediaUrl;
|
|
111
|
+
} catch (err) {
|
|
112
|
+
throw new Error(`tiktokCustom failed: ${err.message}`);
|
|
113
|
+
}
|
|
114
|
+
};
|