@coflyn/mori 1.2.0 → 1.2.2
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/CHANGELOG.md +18 -0
- package/README.md +71 -91
- package/engine.js +251 -46
- package/index.js +174 -32
- package/package.json +3 -2
- package/translations/README-id.md +133 -0
- package/translations/README-zh-CN.md +133 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,24 @@ All notable changes to the Mori CLI (`@coflyn/mori`) will be documented in this
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.2.2] - 2026-11-17
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
- **Dynamic CLI Version Indicator**: Read CLI version dynamically from `package.json` instead of a hardcoded string, preventing stuck version labels and update notification loops.
|
|
12
|
+
|
|
13
|
+
## [1.2.1] - 2026-11-17
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
- **YouTube Shorts & Query Normalization**:
|
|
17
|
+
- Convert YouTube Shorts links (`/shorts/{id}`) to standard `/watch?v={id}` URLs before resolving.
|
|
18
|
+
- Distinguish between single videos and playlists when both `v=` and `list=` parameters exist in the URL.
|
|
19
|
+
- Fix converter download headers when redirected to `.shop` mirror domains.
|
|
20
|
+
- **Playlist & Multi-Track Album Downloads**:
|
|
21
|
+
- Automatically detect playlists and multi-track albums (YouTube, Spotify, Apple Music, Bandcamp).
|
|
22
|
+
- Add interactive prompt to download all tracks or select specific tracks.
|
|
23
|
+
- Save files with real track titles and index prefixes (`01. Artist - Title.mp3`) instead of generic playlist names.
|
|
24
|
+
- Support automatic full playlist download with `--yes` (`-y`).
|
|
25
|
+
|
|
8
26
|
## [1.2.0] - 2026-10-25
|
|
9
27
|
|
|
10
28
|
### Added
|
package/README.md
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
<h1 align="center">@coflyn/mori</h1>
|
|
3
3
|
<p align="center"><strong>Universal Media Downloader CLI</strong></p>
|
|
4
4
|
<p align="center"><em>Save anything, from anywhere. No watermarks. No tracking.</em></p>
|
|
5
|
+
<p align="center"><strong>English</strong> · <a href="translations/README-zh-CN.md">简体中文</a> · <a href="translations/README-id.md">Bahasa Indonesia</a></p>
|
|
5
6
|
</p>
|
|
6
7
|
|
|
7
8
|
<p align="center">
|
|
@@ -17,24 +18,27 @@
|
|
|
17
18
|
|
|
18
19
|
---
|
|
19
20
|
|
|
20
|
-
Command-line interface for **[Mori](https://github.com/coflyn/Mori)**. Download watermark-free videos,
|
|
21
|
+
Command-line interface for **[Mori](https://github.com/coflyn/Mori)**. Download watermark-free videos, photos, audio, full playlists, and compile photo galleries into PDF files across 27 platforms directly from your terminal.
|
|
21
22
|
|
|
22
|
-
##
|
|
23
|
+
## Quick Start
|
|
23
24
|
|
|
24
|
-
Run
|
|
25
|
+
Run directly without global installation:
|
|
25
26
|
|
|
26
27
|
```bash
|
|
27
28
|
# Interactive REPL mode
|
|
28
29
|
npx @coflyn/mori
|
|
29
30
|
|
|
30
|
-
# Download
|
|
31
|
-
npx @coflyn/mori https://www.tiktok.com/@user/video/123456789
|
|
31
|
+
# Download a link directly
|
|
32
|
+
npx @coflyn/mori "https://www.tiktok.com/@user/video/123456789"
|
|
32
33
|
|
|
33
34
|
# Download audio only (MP3)
|
|
34
|
-
npx @coflyn/mori https://youtu.be/dQw4w9WgXcQ -a
|
|
35
|
+
npx @coflyn/mori "https://youtu.be/dQw4w9WgXcQ" -a
|
|
35
36
|
|
|
36
|
-
#
|
|
37
|
-
npx @coflyn/mori https://www.
|
|
37
|
+
# Download an entire playlist or album automatically
|
|
38
|
+
npx @coflyn/mori "https://www.youtube.com/playlist?list=PLxxx" -y
|
|
39
|
+
|
|
40
|
+
# Compile photo carousel into a single PDF
|
|
41
|
+
npx @coflyn/mori "https://www.instagram.com/p/C_abc123/" -p
|
|
38
42
|
```
|
|
39
43
|
|
|
40
44
|
Or install globally:
|
|
@@ -46,32 +50,20 @@ mori
|
|
|
46
50
|
|
|
47
51
|
---
|
|
48
52
|
|
|
49
|
-
##
|
|
50
|
-
|
|
51
|
-
|
|
|
52
|
-
|
|
|
53
|
-
| **
|
|
54
|
-
| **
|
|
55
|
-
| **
|
|
56
|
-
| **
|
|
57
|
-
| **
|
|
58
|
-
| **
|
|
59
|
-
| **Pinterest** | Original full-resolution images, video pins |
|
|
60
|
-
| **Facebook** | Public reels & HD videos |
|
|
61
|
-
| **Threads** | Videos and photo carousels |
|
|
62
|
-
| **Reddit** | Videos with synced audio, multi-image galleries |
|
|
63
|
-
| **Bilibili** | High-definition DASH video & audio streams |
|
|
64
|
-
| **Douyin** | Watermark-free videos & photo carousels |
|
|
65
|
-
| **RedNote (Xiaohongshu)** | High-res photos and videos |
|
|
66
|
-
| **Pixiv** | Artwork galleries and animated Ugoira |
|
|
67
|
-
| **Bandcamp** | Individual songs and full discographies |
|
|
68
|
-
| **TeraBox** | Direct stream extraction |
|
|
69
|
-
| **Anime** | Interactive search & episode stream resolution (Otakudesu Sub Indo, Gogoanime Sub Eng) |
|
|
70
|
-
| **Comic / Manga** | Interactive chapter search, image extraction, and PDF compilation (Komikindo, Komiku, Asura Scans) |
|
|
53
|
+
## Supported Platforms
|
|
54
|
+
|
|
55
|
+
| Category | Platforms | Supported Media |
|
|
56
|
+
| :--- | :--- | :--- |
|
|
57
|
+
| **Social & Video** | TikTok, Douyin, YouTube, Instagram, Facebook, Twitter/X, Threads, Reddit, Bilibili, Doodstream | Videos without watermarks, 1080p streams, photo posts, stories, audio |
|
|
58
|
+
| **Music & Audio** | Spotify, YouTube, SoundCloud, Apple Music, Bandcamp | Single tracks, full albums, discographies, playlists (MP3 128–320 kbps) |
|
|
59
|
+
| **Images & Art** | Pinterest, Pixiv, RedNote (Xiaohongshu) | High-resolution images, original illustration galleries, Ugoira animations |
|
|
60
|
+
| **Cloud & File Hosts** | TeraBox, MediaFire, Sfile, Catbox, Pixeldrain, Krakenfiles, Google Drive | Direct stream resolution, batch links, multi-file collections |
|
|
61
|
+
| **Resolvers & Shorteners** | SafeLinkU, Sub2Unlock, Rekonise, Stargon / Link bypassers | Gateway bypass to final media destinations |
|
|
62
|
+
| **Anime & Manga** | Otakudesu, Gogoanime, Komikindo, Komiku, Asura Scans | In-CLI title search, episode stream extraction, comic chapter PDF compilation |
|
|
71
63
|
|
|
72
64
|
---
|
|
73
65
|
|
|
74
|
-
##
|
|
66
|
+
## CLI Options
|
|
75
67
|
|
|
76
68
|
```text
|
|
77
69
|
USAGE:
|
|
@@ -79,75 +71,63 @@ USAGE:
|
|
|
79
71
|
npx @coflyn/mori [URL] [OPTIONS]
|
|
80
72
|
|
|
81
73
|
OPTIONS:
|
|
82
|
-
-o, --output <dir>
|
|
83
|
-
-
|
|
84
|
-
-
|
|
85
|
-
-
|
|
86
|
-
-
|
|
87
|
-
-
|
|
88
|
-
-
|
|
89
|
-
-
|
|
90
|
-
-
|
|
91
|
-
-
|
|
74
|
+
-o, --output <dir> Download directory (default: ~/Downloads/Mori)
|
|
75
|
+
-e, --engine <auto|mori|scrapr> Scraper engine selector (default: auto)
|
|
76
|
+
-s, --server <1|2> Select server mirror (TikTok, IG, YouTube, X, Spotify)
|
|
77
|
+
-a, --audio Download audio stream only (MP3/M4A)
|
|
78
|
+
-p, --pdf Compile photo galleries into a single PDF document
|
|
79
|
+
-c, --clip Download link copied to system clipboard
|
|
80
|
+
-y, --yes Download without prompts (auto-selects best stream or all playlist tracks)
|
|
81
|
+
-i, --info Inspect media details and stream list without downloading
|
|
82
|
+
-u, --update Check for package updates and OTA scraper patches
|
|
83
|
+
-h, --help Show help and usage guide
|
|
84
|
+
-v, --version Show version number
|
|
92
85
|
```
|
|
93
86
|
|
|
94
87
|
---
|
|
95
88
|
|
|
96
|
-
##
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
|
107
|
-
|
|
|
108
|
-
| `/
|
|
109
|
-
| `/
|
|
110
|
-
| `/
|
|
111
|
-
| `/
|
|
112
|
-
| `/
|
|
113
|
-
| `/
|
|
114
|
-
| `/
|
|
115
|
-
| `/
|
|
116
|
-
| `/
|
|
117
|
-
| `/
|
|
118
|
-
| `/
|
|
119
|
-
| `/
|
|
120
|
-
| `/
|
|
121
|
-
| `/
|
|
122
|
-
| `/
|
|
123
|
-
| `/
|
|
124
|
-
| `/
|
|
125
|
-
| `/reset` | — | Factory reset Mori configuration, cached scrapers, and history |
|
|
126
|
-
| `/clear` | `/cls` | Clear terminal screen and reprint header |
|
|
127
|
-
| `/help` | `/?` | Display quick command reference guide |
|
|
128
|
-
| `/exit` | `/quit`, `/q` | Exit interactive CLI mode |
|
|
89
|
+
## Interactive Shell & Slash Commands
|
|
90
|
+
|
|
91
|
+
Running `mori` with no arguments starts the interactive prompt. Type a URL or title to start, or use `/` commands:
|
|
92
|
+
|
|
93
|
+
| Command | Aliases | Description |
|
|
94
|
+
| :--- | :--- | :--- |
|
|
95
|
+
| `/clip` | `/paste` | Read and download URL from system clipboard |
|
|
96
|
+
| `/audio [url]` | `/mp3` | Download audio stream only (MP3/M4A) |
|
|
97
|
+
| `/pdf [url]` | — | Compile photo carousel into a single PDF album |
|
|
98
|
+
| `/batch` | — | Download multiple links at once (space or newline separated) |
|
|
99
|
+
| `/play [num]` | — | Open downloaded file in your default system media player |
|
|
100
|
+
| `/history [num]` | — | View history, re-download an item, or clear (`/history clear`) |
|
|
101
|
+
| `/delete` | `/del`, `/rm` | Interactive multiselect deletion (remove from history or delete from disk) |
|
|
102
|
+
| `/open` | — | Open Mori download folder in Finder or File Explorer |
|
|
103
|
+
| `/dir [path]` | — | View or change default download directory |
|
|
104
|
+
| `/server` | — | Change default scraper server mirror |
|
|
105
|
+
| `/engine` | — | Switch between Mori Engine, Scrapr Engine, or Auto mode |
|
|
106
|
+
| `/rollback` | — | Revert scraper engine to an earlier commit or release |
|
|
107
|
+
| `/info [url]` | `/inspect` | Print stream details without downloading |
|
|
108
|
+
| `/retry` | `/again` | Re-run last processed download |
|
|
109
|
+
| `/ping [host]` | — | Ping network host to test connection (default: 1.1.1.1) |
|
|
110
|
+
| `/stats` | — | Show total downloads, storage used, and platform statistics |
|
|
111
|
+
| `/platforms` | `/platform` | List all 27 supported platforms |
|
|
112
|
+
| `/config` | — | Print active configuration, directory paths, and versions |
|
|
113
|
+
| `/update` | `/u` | Check for npm CLI updates and OTA scraper patches from GitHub |
|
|
114
|
+
| `/reset` | — | Reset Mori configuration and history to defaults |
|
|
115
|
+
| `/clear` | `/cls` | Clear terminal screen |
|
|
116
|
+
| `/help` | `/?` | Display commands reference |
|
|
117
|
+
| `/exit` | `/quit`, `/q` | Exit CLI |
|
|
129
118
|
|
|
130
119
|
---
|
|
131
120
|
|
|
132
|
-
##
|
|
133
|
-
|
|
134
|
-
- **
|
|
135
|
-
- **
|
|
136
|
-
- **
|
|
137
|
-
- **
|
|
138
|
-
- **Single-Row In-Place Updates**: Dynamic in-place terminal spinner without spamming new lines for every photo.
|
|
139
|
-
- **Instant Photo-to-PDF**: Combine multi-image posts and photo carousels into a single, clean PDF file (`-p` / `--pdf`).
|
|
140
|
-
- **Integrated Terminal Player**: Launch and listen/watch downloaded videos and audio directly via `/play <num>`.
|
|
141
|
-
- **History & Disk Sync Deletion**: Keep track of downloaded files, re-download past items, or delete files from disk and history via `/delete <num>`.
|
|
142
|
-
- **Clipboard Detection**: One-command downloads from your clipboard (`-c` / `--clip` or `/clip`).
|
|
143
|
-
- **Dual-Server Redundancy**: Seamlessly switch between primary and mirror servers for platforms like TikTok, Instagram, YouTube, X, and Spotify.
|
|
144
|
-
- **Over-The-Air (OTA) Hot-Patching**: Scrapers update dynamically via GitHub when upstream platform APIs change, without waiting for an NPM package release.
|
|
145
|
-
- **Built-in Network Diagnostics**: Check connection latency and packet loss to download servers using `/ping`.
|
|
146
|
-
- **100% Local & Private**: No analytics, no accounts, and no data telemetry. Configuration and history are stored locally in `~/.mori`.
|
|
121
|
+
## Technical Details
|
|
122
|
+
|
|
123
|
+
- **Dual-Engine Architecture**: Mori uses an internal core scraper bundle and can fall back to the standalone Scrapr engine when upstream sites change their layouts.
|
|
124
|
+
- **OTA Patching**: Scraper logic can update via GitHub commits without waiting for a new npm release. Run `/update` or `/rollback` to manage versions.
|
|
125
|
+
- **Playlist & Album Queue**: Pasting a YouTube playlist, Spotify album, or Apple Music collection shows track numbers and titles, letting you download everything sequentially or pick individual tracks.
|
|
126
|
+
- **Local Storage**: Configuration and history stay on your machine in `~/.mori`. No analytics or telemetry.
|
|
147
127
|
|
|
148
128
|
---
|
|
149
129
|
|
|
150
|
-
##
|
|
130
|
+
## License
|
|
151
131
|
|
|
152
|
-
Licensed under the [GNU General Public License v3.0](https://github.com/coflyn/Mori/blob/main/LICENSE).
|
|
132
|
+
Licensed under the [GNU General Public License v3.0](https://github.com/coflyn/Mori/blob/main/LICENSE).
|
|
153
133
|
Part of the **[Mori](https://github.com/coflyn/Mori)** project.
|
package/engine.js
CHANGED
|
@@ -58,7 +58,13 @@ function serializeData(obj) {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
function cleanUrl(u) {
|
|
61
|
-
|
|
61
|
+
if (!u) return "";
|
|
62
|
+
const clean = u.split("?")[0];
|
|
63
|
+
const shortsMatch = clean.match(/(?:youtube\.com\/shorts\/|youtu\.be\/)([^"&?/\s]{11})/i);
|
|
64
|
+
if (shortsMatch) {
|
|
65
|
+
return `https://www.youtube.com/watch?v=${shortsMatch[1]}`;
|
|
66
|
+
}
|
|
67
|
+
return clean;
|
|
62
68
|
}
|
|
63
69
|
|
|
64
70
|
const SAFARI_MOBILE_UA = CHROME_MOBILE_UA;
|
|
@@ -1362,21 +1368,30 @@ export async function scrapeWithMori(url, platform, serverPreference = "auto") {
|
|
|
1362
1368
|
break;
|
|
1363
1369
|
}
|
|
1364
1370
|
case "youtube": {
|
|
1371
|
+
const videoMatch = url.match(
|
|
1372
|
+
/(?:youtube\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?|shorts|live)\/|.*[?&]v=)|youtu\.be\/)([^"&?\/\s]{11})/i,
|
|
1373
|
+
);
|
|
1374
|
+
const isPlaylist =
|
|
1375
|
+
url.includes("list=") && (!videoMatch?.[1] || url.includes("/playlist"));
|
|
1376
|
+
const targetUrl =
|
|
1377
|
+
!isPlaylist && videoMatch?.[1]
|
|
1378
|
+
? `https://www.youtube.com/watch?v=${videoMatch[1]}`
|
|
1379
|
+
: url;
|
|
1365
1380
|
if (srv === "server2") {
|
|
1366
1381
|
scrapers.setYouTubeSource("mobi");
|
|
1367
|
-
res = await scrapers.scrapeYouTube(
|
|
1382
|
+
res = await scrapers.scrapeYouTube(targetUrl);
|
|
1368
1383
|
usedServer = "ytmp3.mobi";
|
|
1369
1384
|
} else if (srv === "server1") {
|
|
1370
1385
|
scrapers.setYouTubeSource("gg");
|
|
1371
|
-
res = await scrapers.scrapeYouTube(
|
|
1386
|
+
res = await scrapers.scrapeYouTube(targetUrl);
|
|
1372
1387
|
usedServer = "ytmp3.gg";
|
|
1373
1388
|
} else {
|
|
1374
1389
|
scrapers.setYouTubeSource("gg");
|
|
1375
|
-
res = await scrapers.scrapeYouTube(
|
|
1390
|
+
res = await scrapers.scrapeYouTube(targetUrl);
|
|
1376
1391
|
usedServer = "ytmp3.gg";
|
|
1377
1392
|
if (!res?.status) {
|
|
1378
1393
|
scrapers.setYouTubeSource("mobi");
|
|
1379
|
-
res = await scrapers.scrapeYouTube(
|
|
1394
|
+
res = await scrapers.scrapeYouTube(targetUrl);
|
|
1380
1395
|
usedServer = "ytmp3.mobi";
|
|
1381
1396
|
}
|
|
1382
1397
|
}
|
|
@@ -1574,17 +1589,26 @@ export async function scrapeWithScrapr(
|
|
|
1574
1589
|
break;
|
|
1575
1590
|
}
|
|
1576
1591
|
case "youtube": {
|
|
1592
|
+
const videoMatch = url.match(
|
|
1593
|
+
/(?:youtube\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?|shorts|live)\/|.*[?&]v=)|youtu\.be\/)([^"&?\/\s]{11})/i,
|
|
1594
|
+
);
|
|
1595
|
+
const isPlaylist =
|
|
1596
|
+
url.includes("list=") && (!videoMatch?.[1] || url.includes("/playlist"));
|
|
1597
|
+
const targetUrl =
|
|
1598
|
+
!isPlaylist && videoMatch?.[1]
|
|
1599
|
+
? `https://www.youtube.com/watch?v=${videoMatch[1]}`
|
|
1600
|
+
: url;
|
|
1577
1601
|
if (srv === "ytmp3gg" || srv === "server1") {
|
|
1578
|
-
res = await scrapr.youtube.ytmp3gg(
|
|
1602
|
+
res = await scrapr.youtube.ytmp3gg(targetUrl);
|
|
1579
1603
|
usedServer = "ytmp3.gg";
|
|
1580
1604
|
} else if (srv === "ytmp3" || srv === "server2") {
|
|
1581
|
-
res = await scrapr.youtube.ytmp3(
|
|
1605
|
+
res = await scrapr.youtube.ytmp3(targetUrl);
|
|
1582
1606
|
usedServer = "ytmp3";
|
|
1583
1607
|
} else {
|
|
1584
|
-
res = await scrapr.youtube.ytmp3gg(
|
|
1608
|
+
res = await scrapr.youtube.ytmp3gg(targetUrl);
|
|
1585
1609
|
usedServer = "ytmp3.gg";
|
|
1586
1610
|
if (!res?.status) {
|
|
1587
|
-
res = await scrapr.youtube.ytmp3(
|
|
1611
|
+
res = await scrapr.youtube.ytmp3(targetUrl);
|
|
1588
1612
|
usedServer = "ytmp3";
|
|
1589
1613
|
}
|
|
1590
1614
|
}
|
|
@@ -1977,50 +2001,231 @@ export async function resolveUrl(url, onStatus) {
|
|
|
1977
2001
|
return foundLink;
|
|
1978
2002
|
}
|
|
1979
2003
|
|
|
1980
|
-
if (
|
|
2004
|
+
if (
|
|
2005
|
+
url.startsWith("spotidown_resolve:") ||
|
|
2006
|
+
url.startsWith("soundloaders_resolve:")
|
|
2007
|
+
) {
|
|
1981
2008
|
if (onStatus) onStatus("Resolving Spotify direct track...");
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
2009
|
+
function createMultipartBody(fields) {
|
|
2010
|
+
const boundary =
|
|
2011
|
+
"----WebKitFormBoundary" + Math.random().toString(36).substring(2);
|
|
2012
|
+
let body = "";
|
|
2013
|
+
for (const [k, v] of Object.entries(fields)) {
|
|
2014
|
+
if (v !== undefined && v !== null) {
|
|
2015
|
+
body += `--${boundary}\r\nContent-Disposition: form-data; name="${k}"\r\n\r\n${v}\r\n`;
|
|
2016
|
+
}
|
|
2017
|
+
}
|
|
2018
|
+
body += `--${boundary}--\r\n`;
|
|
2019
|
+
return {
|
|
2020
|
+
body,
|
|
2021
|
+
contentType: `multipart/form-data; boundary=${boundary}`,
|
|
2022
|
+
};
|
|
2023
|
+
}
|
|
1994
2024
|
|
|
1995
|
-
const
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
let
|
|
2003
|
-
|
|
2025
|
+
const isSoundloaders = url.startsWith("soundloaders_resolve:");
|
|
2026
|
+
const parts = url
|
|
2027
|
+
.replace("spotidown_resolve:", "")
|
|
2028
|
+
.replace("soundloaders_resolve:", "")
|
|
2029
|
+
.split("|||");
|
|
2030
|
+
let dataVal = parts[0] || "";
|
|
2031
|
+
let tokenVal = parts[1] || "";
|
|
2032
|
+
let baseVal = parts[2] ? decodeURIComponent(parts[2]) : "";
|
|
2033
|
+
let cookiesStr = parts[3] ? decodeURIComponent(parts[3]) : "";
|
|
2034
|
+
|
|
2035
|
+
if (dataVal.includes("=") && (!tokenVal || !tokenVal.startsWith("http"))) {
|
|
2004
2036
|
try {
|
|
2005
|
-
|
|
2037
|
+
const sp = new URLSearchParams(dataVal);
|
|
2038
|
+
if (sp.has("data")) dataVal = sp.get("data") || "";
|
|
2039
|
+
if (sp.has("token")) tokenVal = sp.get("token") || "";
|
|
2040
|
+
if (sp.has("base")) baseVal = sp.get("base") || "";
|
|
2041
|
+
if (parts[1]) cookiesStr = decodeURIComponent(parts[1]);
|
|
2006
2042
|
} catch (_) {}
|
|
2007
2043
|
}
|
|
2008
|
-
|
|
2009
|
-
const parser = new DOMParser();
|
|
2010
|
-
const doc = parser.parseFromString(dlHtml, "text/html");
|
|
2044
|
+
|
|
2011
2045
|
let foundLink = "";
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2046
|
+
|
|
2047
|
+
// 1. If Soundloaders, try Spotimate first (if it doesn't fail with turnstile token)
|
|
2048
|
+
if (isSoundloaders && !tokenVal.startsWith("bccpF:")) {
|
|
2049
|
+
try {
|
|
2050
|
+
if (!cookiesStr) {
|
|
2051
|
+
try {
|
|
2052
|
+
const rHome = await scraperFetch({
|
|
2053
|
+
url: "https://spotimate.app/en1",
|
|
2054
|
+
headers: { "User-Agent": CHROME_UA },
|
|
2055
|
+
rawResponse: true,
|
|
2056
|
+
});
|
|
2057
|
+
let freshCookies = getCookiesFromHeaders(rHome.headers) || "";
|
|
2058
|
+
const rVerify = await scraperFetch({
|
|
2059
|
+
url: "https://spotimate.app/api/userverify",
|
|
2060
|
+
method: "POST",
|
|
2061
|
+
data: "url=" + encodeURIComponent(baseVal || "https://open.spotify.com"),
|
|
2062
|
+
headers: {
|
|
2063
|
+
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
|
|
2064
|
+
"User-Agent": CHROME_UA,
|
|
2065
|
+
Referer: "https://spotimate.app/en1",
|
|
2066
|
+
Origin: "https://spotimate.app",
|
|
2067
|
+
...(freshCookies ? { Cookie: freshCookies } : {}),
|
|
2068
|
+
},
|
|
2069
|
+
rawResponse: true,
|
|
2070
|
+
});
|
|
2071
|
+
const vCookies = getCookiesFromHeaders(rVerify.headers);
|
|
2072
|
+
if (vCookies) freshCookies = freshCookies ? `${freshCookies}; ${vCookies}` : vCookies;
|
|
2073
|
+
if (freshCookies) cookiesStr = freshCookies;
|
|
2074
|
+
} catch (_) {}
|
|
2075
|
+
}
|
|
2076
|
+
|
|
2077
|
+
const mp = createMultipartBody({
|
|
2078
|
+
data: dataVal,
|
|
2079
|
+
token: tokenVal,
|
|
2080
|
+
track_token: tokenVal,
|
|
2081
|
+
...(baseVal ? { base: baseVal } : {}),
|
|
2082
|
+
});
|
|
2083
|
+
const slHeaders = {
|
|
2084
|
+
"Content-Type": mp.contentType,
|
|
2085
|
+
"User-Agent": CHROME_UA,
|
|
2086
|
+
Referer: "https://spotimate.app/en1",
|
|
2087
|
+
Origin: "https://spotimate.app",
|
|
2088
|
+
};
|
|
2089
|
+
if (cookiesStr) slHeaders["Cookie"] = cookiesStr;
|
|
2090
|
+
|
|
2091
|
+
const res = await scraperFetch({
|
|
2092
|
+
url: "https://spotimate.app/action/track",
|
|
2093
|
+
method: "POST",
|
|
2094
|
+
headers: slHeaders,
|
|
2095
|
+
data: mp.body,
|
|
2096
|
+
rawResponse: true,
|
|
2097
|
+
});
|
|
2098
|
+
let dd = res?.data ?? res;
|
|
2099
|
+
if (typeof dd === "string") {
|
|
2100
|
+
try {
|
|
2101
|
+
dd = JSON.parse(dd);
|
|
2102
|
+
} catch (_) {}
|
|
2103
|
+
}
|
|
2104
|
+
let dlHtml = (typeof dd === "object" ? dd?.html || dd?.data : dd) || "";
|
|
2105
|
+
const parser = new DOMParser();
|
|
2106
|
+
const doc = parser.parseFromString(dlHtml, "text/html");
|
|
2107
|
+
doc.querySelectorAll("a").forEach((a) => {
|
|
2108
|
+
const href = a.getAttribute("href")?.trim();
|
|
2109
|
+
const text = a.textContent.trim();
|
|
2110
|
+
if (
|
|
2111
|
+
href &&
|
|
2112
|
+
href.startsWith("http") &&
|
|
2113
|
+
!href.includes("tunecable.com") &&
|
|
2114
|
+
!href.includes("premium") &&
|
|
2115
|
+
!text.toLowerCase().includes("cover") &&
|
|
2116
|
+
!href.includes("scdn.co") &&
|
|
2117
|
+
text !== "Download Another Song"
|
|
2118
|
+
) {
|
|
2119
|
+
if (!foundLink) foundLink = href;
|
|
2120
|
+
}
|
|
2121
|
+
});
|
|
2122
|
+
if (!foundLink) {
|
|
2123
|
+
const match =
|
|
2124
|
+
dlHtml.match(
|
|
2125
|
+
/href=["'](https:\/\/(?:dl\.spotimate\.app|dl\.soundloaders\.app)[^"']+)["']/,
|
|
2126
|
+
) ||
|
|
2127
|
+
dlHtml.match(
|
|
2128
|
+
/href=["'](https:\/\/[^"']*(?:cdnv1|\/v1\?token=)[^"']+)["']/,
|
|
2129
|
+
);
|
|
2130
|
+
if (match && match[1]) {
|
|
2131
|
+
foundLink = match[1];
|
|
2132
|
+
}
|
|
2133
|
+
}
|
|
2134
|
+
} catch (_) {}
|
|
2135
|
+
}
|
|
2136
|
+
|
|
2137
|
+
// 2. If SpotiDown or Spotimate fallback needed:
|
|
2138
|
+
if (!foundLink && baseVal) {
|
|
2139
|
+
let spData = dataVal;
|
|
2140
|
+
let spToken = tokenVal;
|
|
2141
|
+
let spBase = baseVal;
|
|
2142
|
+
let spCookies = cookiesStr;
|
|
2143
|
+
|
|
2144
|
+
// If came from Soundloaders, we need genuine SpotiDown tokens
|
|
2145
|
+
if (isSoundloaders || !spData || !spToken || spToken.startsWith("bccpF:")) {
|
|
2146
|
+
try {
|
|
2147
|
+
const rSession = await scraperFetch({
|
|
2148
|
+
url: "https://spotidown.app/action",
|
|
2149
|
+
method: "POST",
|
|
2150
|
+
data: `url=${encodeURIComponent(baseVal)}&g-recaptcha-response=dummy_token`,
|
|
2151
|
+
headers: {
|
|
2152
|
+
"Content-Type":
|
|
2153
|
+
"application/x-www-form-urlencoded; charset=UTF-8",
|
|
2154
|
+
"User-Agent": CHROME_UA,
|
|
2155
|
+
"X-Requested-With": "XMLHttpRequest",
|
|
2156
|
+
Origin: "https://spotidown.app",
|
|
2157
|
+
Referer: "https://spotidown.app/",
|
|
2158
|
+
},
|
|
2159
|
+
rawResponse: true,
|
|
2160
|
+
});
|
|
2161
|
+
const freshCookies = getCookiesFromHeaders(rSession.headers) || "";
|
|
2162
|
+
if (freshCookies) spCookies = freshCookies;
|
|
2163
|
+
let rData = rSession?.data;
|
|
2164
|
+
if (typeof rData === "string") {
|
|
2165
|
+
try {
|
|
2166
|
+
rData = JSON.parse(rData);
|
|
2167
|
+
} catch (_) {}
|
|
2168
|
+
}
|
|
2169
|
+
const html = rData?.data || rData?.html || "";
|
|
2170
|
+
const parser = new DOMParser();
|
|
2171
|
+
const doc = parser.parseFromString(html, "text/html");
|
|
2172
|
+
const form = doc.querySelector('form[name="submitspurl"]');
|
|
2173
|
+
if (form) {
|
|
2174
|
+
spData = form.querySelector('input[name="data"]')?.value || "";
|
|
2175
|
+
spToken = form.querySelector('input[name="token"]')?.value || "";
|
|
2176
|
+
spBase = form.querySelector('input[name="base"]')?.value || baseVal;
|
|
2177
|
+
}
|
|
2178
|
+
} catch (_) {}
|
|
2022
2179
|
}
|
|
2023
|
-
|
|
2180
|
+
|
|
2181
|
+
if (spData && spToken) {
|
|
2182
|
+
const mp = createMultipartBody({
|
|
2183
|
+
data: spData,
|
|
2184
|
+
base: spBase,
|
|
2185
|
+
token: spToken,
|
|
2186
|
+
});
|
|
2187
|
+
|
|
2188
|
+
const reqHeaders = {
|
|
2189
|
+
"Content-Type": mp.contentType,
|
|
2190
|
+
"User-Agent": CHROME_UA,
|
|
2191
|
+
"X-Requested-With": "XMLHttpRequest",
|
|
2192
|
+
Referer: "https://spotidown.app/",
|
|
2193
|
+
Origin: "https://spotidown.app",
|
|
2194
|
+
};
|
|
2195
|
+
if (spCookies) reqHeaders["Cookie"] = spCookies;
|
|
2196
|
+
|
|
2197
|
+
const res = await scraperFetch({
|
|
2198
|
+
url: "https://spotidown.app/action/track",
|
|
2199
|
+
method: "POST",
|
|
2200
|
+
headers: reqHeaders,
|
|
2201
|
+
data: mp.body,
|
|
2202
|
+
rawResponse: true,
|
|
2203
|
+
});
|
|
2204
|
+
let dd = res?.data ?? res;
|
|
2205
|
+
if (typeof dd === "string") {
|
|
2206
|
+
try {
|
|
2207
|
+
dd = JSON.parse(dd);
|
|
2208
|
+
} catch (_) {}
|
|
2209
|
+
}
|
|
2210
|
+
let dlHtml = (typeof dd === "object" ? dd?.data || dd?.html : dd) || "";
|
|
2211
|
+
const parser = new DOMParser();
|
|
2212
|
+
const doc = parser.parseFromString(dlHtml, "text/html");
|
|
2213
|
+
doc.querySelectorAll("a").forEach((a) => {
|
|
2214
|
+
const href = a.getAttribute("href");
|
|
2215
|
+
const text = a.textContent.trim();
|
|
2216
|
+
if (
|
|
2217
|
+
href &&
|
|
2218
|
+
href.startsWith("http") &&
|
|
2219
|
+
!href.includes("premium.html") &&
|
|
2220
|
+
!href.includes("ko-fi.com") &&
|
|
2221
|
+
text !== "Download Another Song"
|
|
2222
|
+
) {
|
|
2223
|
+
if (!foundLink) foundLink = href;
|
|
2224
|
+
}
|
|
2225
|
+
});
|
|
2226
|
+
}
|
|
2227
|
+
}
|
|
2228
|
+
|
|
2024
2229
|
if (!foundLink) throw new Error("Could not resolve Spotify download link.");
|
|
2025
2230
|
return foundLink;
|
|
2026
2231
|
}
|
package/index.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import fs from "fs";
|
|
4
4
|
import os from "os";
|
|
5
5
|
import path from "path";
|
|
6
|
+
import { fileURLToPath } from "url";
|
|
6
7
|
import { parseArgs } from "node:util";
|
|
7
8
|
import * as p from "@clack/prompts";
|
|
8
9
|
import pc from "picocolors";
|
|
@@ -53,7 +54,14 @@ import {
|
|
|
53
54
|
downloadScraprEngineVersion,
|
|
54
55
|
} from "./engine.js";
|
|
55
56
|
|
|
56
|
-
const
|
|
57
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
58
|
+
let APP_VERSION = "1.2.2";
|
|
59
|
+
try {
|
|
60
|
+
const pkg = JSON.parse(
|
|
61
|
+
fs.readFileSync(path.join(__dirname, "package.json"), "utf8"),
|
|
62
|
+
);
|
|
63
|
+
if (pkg.version) APP_VERSION = pkg.version;
|
|
64
|
+
} catch (_) {}
|
|
57
65
|
|
|
58
66
|
function isNewerVersion(latest, current) {
|
|
59
67
|
if (!latest || !current) return false;
|
|
@@ -127,6 +135,22 @@ function truncateText(str, max = 72) {
|
|
|
127
135
|
}
|
|
128
136
|
|
|
129
137
|
function formatStreamItem(d, i, allDownloads = []) {
|
|
138
|
+
const cleanTrack = (d.title || d.type || "")
|
|
139
|
+
.replace(/\s*\[(MP3|MP4|JPG|PNG|WEBP|COVER)\]/gi, "")
|
|
140
|
+
.trim();
|
|
141
|
+
|
|
142
|
+
const isGeneric =
|
|
143
|
+
!cleanTrack ||
|
|
144
|
+
/^(mp3|audio|music|photo|image|video|link|default)$/i.test(cleanTrack) ||
|
|
145
|
+
/^\d+p$/i.test(cleanTrack);
|
|
146
|
+
|
|
147
|
+
if (!isGeneric && (/^\d+\.\s+/.test(cleanTrack) || d.title)) {
|
|
148
|
+
return {
|
|
149
|
+
label: d.title || cleanTrack,
|
|
150
|
+
hint: (d.type || "").toLowerCase().includes("mp4") ? "video" : "audio",
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
|
|
130
154
|
const typeStr = (d.type || "").toLowerCase();
|
|
131
155
|
const qualityStr = (d.quality || "").trim();
|
|
132
156
|
|
|
@@ -390,10 +414,24 @@ async function processDownloadItem({ item, meta, outputDir, index, total }) {
|
|
|
390
414
|
? "jpg"
|
|
391
415
|
: "mp4");
|
|
392
416
|
|
|
417
|
+
const cleanTrack = (item.title || item.type || "")
|
|
418
|
+
.replace(/\s*\[(MP3|MP4|JPG|PNG|WEBP|COVER)\]/gi, "")
|
|
419
|
+
.trim();
|
|
420
|
+
const isGenericTrack =
|
|
421
|
+
!cleanTrack ||
|
|
422
|
+
/^(mp3|audio|music|photo|image|video|link|default)$/i.test(cleanTrack) ||
|
|
423
|
+
/^\d+p$/i.test(cleanTrack);
|
|
424
|
+
|
|
425
|
+
const trackTitle =
|
|
426
|
+
!isGenericTrack && (/^\d+\.\s+/.test(cleanTrack) || item.title)
|
|
427
|
+
? item.title || cleanTrack
|
|
428
|
+
: null;
|
|
429
|
+
|
|
393
430
|
let baseTitle = rawFilename
|
|
394
431
|
? path.basename(rawFilename, path.extname(rawFilename))
|
|
395
|
-
:
|
|
396
|
-
|
|
432
|
+
: trackTitle || meta.title || "Media";
|
|
433
|
+
|
|
434
|
+
if (total > 1 && !trackTitle) {
|
|
397
435
|
baseTitle = `${baseTitle}_${index + 1}`;
|
|
398
436
|
}
|
|
399
437
|
const filename = sanitizeFilename(baseTitle, ext);
|
|
@@ -445,7 +483,7 @@ async function processDownloadItem({ item, meta, outputDir, index, total }) {
|
|
|
445
483
|
);
|
|
446
484
|
addToHistory({
|
|
447
485
|
url: meta.url || "",
|
|
448
|
-
title: meta.title || "Media",
|
|
486
|
+
title: trackTitle || meta.title || "Media",
|
|
449
487
|
platform: meta.platform || "unknown",
|
|
450
488
|
filename: path.basename(destPath),
|
|
451
489
|
path: destPath,
|
|
@@ -636,37 +674,102 @@ async function handleScrapeAndDownload(targetUrl, options) {
|
|
|
636
674
|
return false;
|
|
637
675
|
}
|
|
638
676
|
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
)
|
|
677
|
+
const isPlaylistOrAlbum =
|
|
678
|
+
media.type === "playlist" ||
|
|
679
|
+
media.type === "album" ||
|
|
680
|
+
/playlist|album/i.test(targetUrl || "") ||
|
|
681
|
+
/playlist|album/i.test(media.sourceUrl || "") ||
|
|
682
|
+
/playlist|album/i.test(media.originalUrl || "") ||
|
|
683
|
+
(typeof media.title === "string" &&
|
|
684
|
+
/\((Playlist|Album)\)/i.test(media.title));
|
|
685
|
+
|
|
686
|
+
const hasTrackNumbers = downloads.some((dl) =>
|
|
687
|
+
/^\d+\.\s+/.test((dl.type || dl.title || "").trim()),
|
|
688
|
+
);
|
|
647
689
|
|
|
648
|
-
|
|
649
|
-
|
|
690
|
+
const isPlaylistCollection =
|
|
691
|
+
(isPlaylistOrAlbum || hasTrackNumbers) && downloads.length > 1;
|
|
692
|
+
|
|
693
|
+
if (isPlaylistCollection) {
|
|
694
|
+
const audioTracks = downloads.filter(
|
|
695
|
+
(d) =>
|
|
696
|
+
!d.type?.toLowerCase().includes("cover") &&
|
|
697
|
+
!d.type?.toLowerCase().includes("photo"),
|
|
650
698
|
);
|
|
699
|
+
const candidateTracks = audioTracks.length > 0 ? audioTracks : downloads;
|
|
651
700
|
|
|
652
|
-
|
|
653
|
-
item: audioItem,
|
|
654
|
-
meta: media,
|
|
655
|
-
outputDir,
|
|
656
|
-
index: 0,
|
|
657
|
-
total: 1,
|
|
658
|
-
});
|
|
659
|
-
return true;
|
|
660
|
-
}
|
|
701
|
+
let itemsToDownload = candidateTracks;
|
|
661
702
|
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
703
|
+
if (!options.yes) {
|
|
704
|
+
const choice = await p.select({
|
|
705
|
+
message: `Playlist / Album detected (${candidateTracks.length} tracks):`,
|
|
706
|
+
options: [
|
|
707
|
+
{
|
|
708
|
+
value: "all",
|
|
709
|
+
label: `Download All (${candidateTracks.length} tracks)`,
|
|
710
|
+
},
|
|
711
|
+
{
|
|
712
|
+
value: "custom",
|
|
713
|
+
label: "Select specific tracks...",
|
|
714
|
+
},
|
|
715
|
+
{
|
|
716
|
+
value: "cancel",
|
|
717
|
+
label: pc.dim("Cancel"),
|
|
718
|
+
},
|
|
719
|
+
],
|
|
720
|
+
});
|
|
721
|
+
|
|
722
|
+
if (p.isCancel(choice) || choice === "cancel") {
|
|
723
|
+
p.cancel("Cancelled.");
|
|
724
|
+
return false;
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
if (choice === "custom") {
|
|
728
|
+
const selectedIndices = await p.multiselect({
|
|
729
|
+
message: "Select tracks to download:",
|
|
730
|
+
options: candidateTracks.map((d, i) => {
|
|
731
|
+
const item = formatStreamItem(d, i, candidateTracks);
|
|
732
|
+
return {
|
|
733
|
+
value: i,
|
|
734
|
+
label: item.label,
|
|
735
|
+
};
|
|
736
|
+
}),
|
|
737
|
+
required: true,
|
|
738
|
+
});
|
|
739
|
+
|
|
740
|
+
if (p.isCancel(selectedIndices)) {
|
|
741
|
+
p.cancel("Cancelled.");
|
|
742
|
+
return false;
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
itemsToDownload = selectedIndices.map((idx) => candidateTracks[idx]);
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
p.log.info(
|
|
750
|
+
`${pc.bold("● Playlist Queue:")} Downloading ${itemsToDownload.length} track(s)...`,
|
|
751
|
+
);
|
|
752
|
+
|
|
753
|
+
let successCount = 0;
|
|
754
|
+
for (let i = 0; i < itemsToDownload.length; i++) {
|
|
755
|
+
const item = itemsToDownload[i];
|
|
756
|
+
const streamInfo = formatStreamItem(item, i, itemsToDownload);
|
|
757
|
+
p.log.step(
|
|
758
|
+
`${pc.bold(`[${i + 1}/${itemsToDownload.length}]`)} ${streamInfo.label}`,
|
|
759
|
+
);
|
|
760
|
+
const ok = await processDownloadItem({
|
|
761
|
+
item,
|
|
762
|
+
meta: media,
|
|
763
|
+
outputDir,
|
|
764
|
+
index: i,
|
|
765
|
+
total: itemsToDownload.length,
|
|
766
|
+
});
|
|
767
|
+
if (ok) successCount++;
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
p.log.success(
|
|
771
|
+
`${pc.bold("✔ Playlist completed:")} [${successCount}/${itemsToDownload.length}] tracks saved to ${pc.dim(outputDir)}`,
|
|
772
|
+
);
|
|
670
773
|
return true;
|
|
671
774
|
}
|
|
672
775
|
|
|
@@ -726,7 +829,11 @@ async function handleScrapeAndDownload(targetUrl, options) {
|
|
|
726
829
|
let downloadAudioAlso = false;
|
|
727
830
|
|
|
728
831
|
if (!albumFormat) {
|
|
729
|
-
|
|
832
|
+
if (options.yes) {
|
|
833
|
+
albumFormat = "all";
|
|
834
|
+
downloadAudioAlso = audioDownloads.length > 0;
|
|
835
|
+
} else {
|
|
836
|
+
const albumOptions = [
|
|
730
837
|
{
|
|
731
838
|
value: "all",
|
|
732
839
|
label: `Download All (${photoDownloads.length} individual images)`,
|
|
@@ -827,6 +934,7 @@ async function handleScrapeAndDownload(targetUrl, options) {
|
|
|
827
934
|
albumFormat = "all";
|
|
828
935
|
}
|
|
829
936
|
}
|
|
937
|
+
}
|
|
830
938
|
|
|
831
939
|
if (albumFormat === "pdf") {
|
|
832
940
|
const s = p.spinner();
|
|
@@ -990,6 +1098,40 @@ async function handleScrapeAndDownload(targetUrl, options) {
|
|
|
990
1098
|
|
|
991
1099
|
return true;
|
|
992
1100
|
} else {
|
|
1101
|
+
if (options.audio) {
|
|
1102
|
+
const audioItem =
|
|
1103
|
+
downloads.find(
|
|
1104
|
+
(d) =>
|
|
1105
|
+
d.type?.toLowerCase().includes("mp3") ||
|
|
1106
|
+
d.type?.toLowerCase().includes("audio") ||
|
|
1107
|
+
d.type?.toLowerCase().includes("music"),
|
|
1108
|
+
) || downloads[0];
|
|
1109
|
+
|
|
1110
|
+
p.log.message(
|
|
1111
|
+
`${pc.bold("● Audio Stream:")} ${pc.white(audioItem.type || "MP3")}`,
|
|
1112
|
+
);
|
|
1113
|
+
|
|
1114
|
+
await processDownloadItem({
|
|
1115
|
+
item: audioItem,
|
|
1116
|
+
meta: media,
|
|
1117
|
+
outputDir,
|
|
1118
|
+
index: 0,
|
|
1119
|
+
total: 1,
|
|
1120
|
+
});
|
|
1121
|
+
return true;
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
if (options.yes) {
|
|
1125
|
+
await processDownloadItem({
|
|
1126
|
+
item: downloads[0],
|
|
1127
|
+
meta: media,
|
|
1128
|
+
outputDir,
|
|
1129
|
+
index: 0,
|
|
1130
|
+
total: 1,
|
|
1131
|
+
});
|
|
1132
|
+
return true;
|
|
1133
|
+
}
|
|
1134
|
+
|
|
993
1135
|
let selectedItem = downloads[0];
|
|
994
1136
|
|
|
995
1137
|
if (downloads.length > 1) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coflyn/mori",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "Universal media downloader CLI. Save anything, from anywhere. No watermarks. No tracking.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
"engine.js",
|
|
14
14
|
"README.md",
|
|
15
15
|
"CHANGELOG.md",
|
|
16
|
-
"LICENSE"
|
|
16
|
+
"LICENSE",
|
|
17
|
+
"translations"
|
|
17
18
|
],
|
|
18
19
|
"engines": {
|
|
19
20
|
"node": ">=18.0.0"
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<h1 align="center">@coflyn/mori</h1>
|
|
3
|
+
<p align="center"><strong>CLI Downloader Media Universal</strong></p>
|
|
4
|
+
<p align="center"><em>Download media apa saja, dari mana saja. Tanpa watermark. Tanpa pelacak.</em></p>
|
|
5
|
+
<p align="center"><a href="../README.md">English</a> · <a href="README-zh-CN.md">简体中文</a> · <strong>Bahasa Indonesia</strong></p>
|
|
6
|
+
</p>
|
|
7
|
+
|
|
8
|
+
<p align="center">
|
|
9
|
+
<a href="https://www.npmjs.com/package/@coflyn/mori"><img src="https://img.shields.io/npm/v/@coflyn/mori?style=flat-square&color=blue" alt="Versi NPM"></a>
|
|
10
|
+
<a href="https://www.npmjs.com/package/@coflyn/mori"><img src="https://img.shields.io/npm/dm/@coflyn/mori?style=flat-square&color=green" alt="Total Download NPM"></a>
|
|
11
|
+
<a href="https://github.com/coflyn/Mori"><img src="https://img.shields.io/badge/License-GPL--3.0-blue?style=flat-square" alt="Lisensi"></a>
|
|
12
|
+
<a href="https://github.com/coflyn/Mori"><img src="https://img.shields.io/badge/GitHub-coflyn%2FMori-black?style=flat-square&logo=github" alt="GitHub"></a>
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
<p align="center">
|
|
16
|
+
<img src="https://raw.githubusercontent.com/coflyn/Mori/main/assets/cli.webp" width="90%" alt="Pratinjau Mori CLI">
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
Antarmuka baris perintah (CLI) untuk **[Mori](https://github.com/coflyn/Mori)**. Download video tanpa watermark, foto beresolusi penuh, audio, seluruh isi playlist, serta satukan galeri foto menjadi file PDF dari 27 platform langsung lewat terminal.
|
|
22
|
+
|
|
23
|
+
## Cara Pakai Cepat
|
|
24
|
+
|
|
25
|
+
Jalankan langsung tanpa perlu install global lewat `npx`:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# Mode interaktif (REPL)
|
|
29
|
+
npx @coflyn/mori
|
|
30
|
+
|
|
31
|
+
# Download link langsung
|
|
32
|
+
npx @coflyn/mori "https://www.tiktok.com/@user/video/123456789"
|
|
33
|
+
|
|
34
|
+
# Download audio saja (MP3)
|
|
35
|
+
npx @coflyn/mori "https://youtu.be/dQw4w9WgXcQ" -a
|
|
36
|
+
|
|
37
|
+
# Download semua lagu di playlist atau album sekaligus
|
|
38
|
+
npx @coflyn/mori "https://www.youtube.com/playlist?list=PLxxx" -y
|
|
39
|
+
|
|
40
|
+
# Kompilasi postingan multi-foto menjadi satu file PDF
|
|
41
|
+
npx @coflyn/mori "https://www.instagram.com/p/C_abc123/" -p
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Atau pasang secara global di perangkat:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
npm install -g @coflyn/mori
|
|
48
|
+
mori
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Platform yang Didukung
|
|
54
|
+
|
|
55
|
+
| Kategori | Platform | Format yang Didukung |
|
|
56
|
+
| :--- | :--- | :--- |
|
|
57
|
+
| **Media Sosial & Video** | TikTok, Douyin, YouTube, Instagram, Facebook, Twitter/X, Threads, Reddit, Bilibili, Doodstream | Video bebas watermark, stream 1080p, postingan foto/slide, story, audio |
|
|
58
|
+
| **Musik & Audio** | Spotify, YouTube, SoundCloud, Apple Music, Bandcamp | Single track, album penuh, diskografi, playlist (MP3 128–320 kbps) |
|
|
59
|
+
| **Gambar & Ilustrasi** | Pinterest, Pixiv, RedNote (Xiaohongshu) | Gambar resolusi asli, galeri ilustrasi, animasi Ugoira |
|
|
60
|
+
| **Cloud & File Hosting** | TeraBox, MediaFire, Sfile, Catbox, Pixeldrain, Krakenfiles, Google Drive | Resolusi link langsung, batch link, album koleksi banyak file |
|
|
61
|
+
| **Shortener & Resolver** | SafeLinkU, Sub2Unlock, Rekonise, Stargon / Link bypasser | Bypass gateway menuju link file asli |
|
|
62
|
+
| **Anime & Manga** | Otakudesu, Gogoanime, Komikindo, Komiku, Asura Scans | Pencarian judul langsung dari CLI, stream episode, kompilasi chapter komik ke PDF |
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Opsi Perintah (Flags)
|
|
67
|
+
|
|
68
|
+
```text
|
|
69
|
+
PENGGUNAAN:
|
|
70
|
+
mori [URL] [OPSI]
|
|
71
|
+
npx @coflyn/mori [URL] [OPSI]
|
|
72
|
+
|
|
73
|
+
OPSI:
|
|
74
|
+
-o, --output <folder> Tentukan folder download (default: ~/Downloads/Mori)
|
|
75
|
+
-e, --engine <auto|mori|scrapr> Pilih engine scraper (default: auto)
|
|
76
|
+
-s, --server <1|2> Pilih mirror server (TikTok, IG, YouTube, X, Spotify)
|
|
77
|
+
-a, --audio Ambil stream audio saja (MP3/M4A)
|
|
78
|
+
-p, --pdf Kompilasi postingan multi-foto jadi 1 file PDF
|
|
79
|
+
-c, --clip Ambil dan download link dari clipboard sistem
|
|
80
|
+
-y, --yes Download otomatis tanpa konfirmasi (ambil kualitas terbaik atau seluruh playlist)
|
|
81
|
+
-i, --info Lihat metadata dan daftar stream tanpa mendownload
|
|
82
|
+
-u, --update Cek pembaruan paket dan patch OTA scraper
|
|
83
|
+
-h, --help Buka panduan bantuan
|
|
84
|
+
-v, --version Tampilkan nomor versi
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Shell Interaktif & Perintah Slash
|
|
90
|
+
|
|
91
|
+
Menjalankan `mori` tanpa argumen akan membuka antarmuka terminal interaktif. Masukkan link atau judul anime/komik untuk mulai, atau gunakan perintah berawalan `/`:
|
|
92
|
+
|
|
93
|
+
| Perintah | Alias | Penjelasan |
|
|
94
|
+
| :--- | :--- | :--- |
|
|
95
|
+
| `/clip` | `/paste` | Ambil dan download link yang ada di clipboard |
|
|
96
|
+
| `/audio [url]` | `/mp3` | Download stream audio saja (MP3/M4A) |
|
|
97
|
+
| `/pdf [url]` | — | Gabungkan galeri foto menjadi satu file PDF |
|
|
98
|
+
| `/batch` | — | Download banyak tautan sekaligus (dipisah spasi atau baris baru) |
|
|
99
|
+
| `/play [nomor]` | — | Putar file hasil download di pemutar media bawaan komputer |
|
|
100
|
+
| `/history [nomor]` | — | Lihat riwayat download, download ulang, atau hapus riwayat (`/history clear`) |
|
|
101
|
+
| `/delete` | `/del`, `/rm` | Hapus riwayat download secara interaktif (bisa sekalian hapus file di disk) |
|
|
102
|
+
| `/open` | — | Buka folder hasil download di Finder atau File Explorer |
|
|
103
|
+
| `/dir [path]` | — | Cek atau ubah lokasi folder download default |
|
|
104
|
+
| `/server` | — | Ganti server mirror scraper default |
|
|
105
|
+
| `/engine` | — | Ganti mode engine (Mori Engine, Scrapr Engine, atau Auto) |
|
|
106
|
+
| `/rollback` | — | Kembalikan engine scraper ke versi atau commit sebelumnya |
|
|
107
|
+
| `/info [url]` | `/inspect` | Tampilkan detail stream tanpa mendownload file |
|
|
108
|
+
| `/retry` | `/again` | Download ulang link yang terakhir diproses |
|
|
109
|
+
| `/ping [host]` | — | Uji latensi jaringan dan paket hilang (default: 1.1.1.1) |
|
|
110
|
+
| `/stats` | — | Tampilkan statistik download, kuota disk terpakai, dan ringkasan per platform |
|
|
111
|
+
| `/platforms` | `/platform` | Tampilkan daftar 27 platform yang didukung |
|
|
112
|
+
| `/config` | — | Lihat konfigurasi aktif, lokasi penyimpanan, dan versi engine |
|
|
113
|
+
| `/update` | `/u` | Cek pembaruan CLI di npm dan patch OTA scraper dari GitHub |
|
|
114
|
+
| `/reset` | — | Kembalikan pengaturan dan riwayat Mori ke setelan awal |
|
|
115
|
+
| `/clear` | `/cls` | Bersihkan layar terminal |
|
|
116
|
+
| `/help` | `/?` | Tampilkan ringkasan perintah |
|
|
117
|
+
| `/exit` | `/quit`, `/q` | Keluar dari CLI |
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## Detail Teknis
|
|
122
|
+
|
|
123
|
+
- **Arsitektur Dual-Engine**: Mori memakai modul scraper internal dan otomatis beralih ke engine Scrapr jika struktur halaman platform target berubah.
|
|
124
|
+
- **Pembaruan OTA (Over-The-Air)**: Logika scraper bisa diperbarui lewat commit GitHub tanpa harus menunggu rilis paket baru di npm. Gunakan `/update` atau `/rollback` untuk mengatur versi.
|
|
125
|
+
- **Antrean Playlist & Album**: Menempelkan playlist YouTube, album Spotify, atau daftar lagu Apple Music akan memunculkan nomor serta judul lagu asli. Kamu bisa memilih download semua secara berurutan atau hanya lagu tertentu.
|
|
126
|
+
- **Penyimpanan Lokal**: Seluruh konfigurasi dan riwayat download tersimpan di perangkat kamu (`~/.mori`). Tidak ada telemetri maupun analitik.
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## Lisensi
|
|
131
|
+
|
|
132
|
+
Didistribusikan di bawah [Lisensi GNU General Public License v3.0](https://github.com/coflyn/Mori/blob/main/LICENSE).
|
|
133
|
+
Bagian dari proyek **[Mori](https://github.com/coflyn/Mori)**.
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<h1 align="center">@coflyn/mori</h1>
|
|
3
|
+
<p align="center"><strong>通用多媒体下载 CLI</strong></p>
|
|
4
|
+
<p align="center"><em>随处保存,想下就下。无水印,无追踪。</em></p>
|
|
5
|
+
<p align="center"><a href="../README.md">English</a> · <strong>简体中文</strong> · <a href="README-id.md">Bahasa Indonesia</a></p>
|
|
6
|
+
</p>
|
|
7
|
+
|
|
8
|
+
<p align="center">
|
|
9
|
+
<a href="https://www.npmjs.com/package/@coflyn/mori"><img src="https://img.shields.io/npm/v/@coflyn/mori?style=flat-square&color=blue" alt="NPM 版本"></a>
|
|
10
|
+
<a href="https://www.npmjs.com/package/@coflyn/mori"><img src="https://img.shields.io/npm/dm/@coflyn/mori?style=flat-square&color=green" alt="NPM 下载量"></a>
|
|
11
|
+
<a href="https://github.com/coflyn/Mori"><img src="https://img.shields.io/badge/License-GPL--3.0-blue?style=flat-square" alt="开源协议"></a>
|
|
12
|
+
<a href="https://github.com/coflyn/Mori"><img src="https://img.shields.io/badge/GitHub-coflyn%2FMori-black?style=flat-square&logo=github" alt="GitHub"></a>
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
<p align="center">
|
|
16
|
+
<img src="https://raw.githubusercontent.com/coflyn/Mori/main/assets/cli.webp" width="90%" alt="Mori CLI 预览">
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
**[Mori](https://github.com/coflyn/Mori)** 命令行工具。直接在终端中从 27 个主流平台下载无水印视频、高清原图、音频、整张播放列表,或将图集拼合编译为单份 PDF 文档。
|
|
22
|
+
|
|
23
|
+
## 快速上手
|
|
24
|
+
|
|
25
|
+
通过 `npx` 直接运行,无需全局安装:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# 启动交互式终端模式 (REPL)
|
|
29
|
+
npx @coflyn/mori
|
|
30
|
+
|
|
31
|
+
# 直接下载指定链接
|
|
32
|
+
npx @coflyn/mori "https://www.tiktok.com/@user/video/123456789"
|
|
33
|
+
|
|
34
|
+
# 仅提取音频 (MP3)
|
|
35
|
+
npx @coflyn/mori "https://youtu.be/dQw4w9WgXcQ" -a
|
|
36
|
+
|
|
37
|
+
# 自动下载整张播放列表或专辑
|
|
38
|
+
npx @coflyn/mori "https://www.youtube.com/playlist?list=PLxxx" -y
|
|
39
|
+
|
|
40
|
+
# 将多图贴文合并为单份 PDF
|
|
41
|
+
npx @coflyn/mori "https://www.instagram.com/p/C_abc123/" -p
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
或者进行全局安装:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
npm install -g @coflyn/mori
|
|
48
|
+
mori
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## 支持的平台
|
|
54
|
+
|
|
55
|
+
| 分类 | 平台 | 支持的内容 |
|
|
56
|
+
| :--- | :--- | :--- |
|
|
57
|
+
| **社交与视频** | TikTok, 抖音, YouTube, Instagram, Facebook, Twitter/X, Threads, Reddit, 哔哩哔哩, Doodstream | 无水印视频、1080p 画质流、图片贴文、快拍、原声音频 |
|
|
58
|
+
| **音乐与音频** | Spotify, YouTube, SoundCloud, Apple Music, Bandcamp | 单曲、整张专辑、全集唱片、歌单播放列表 (MP3 128–320 kbps) |
|
|
59
|
+
| **插画与图集** | Pinterest, Pixiv, 小红书 (RedNote) | 高清原图、插画画廊、动图 Ugoira |
|
|
60
|
+
| **网盘与文件存储** | TeraBox, MediaFire, Sfile, Catbox, Pixeldrain, Krakenfiles, Google 云端硬盘 | 直链解析、批量下载、多文件合集 |
|
|
61
|
+
| **短链与跳板解析** | SafeLinkU, Sub2Unlock, Rekonise, Stargon / 网页跳转解析器 | 绕过中转页直接获取目标资源 |
|
|
62
|
+
| **动漫与漫画** | Otakudesu, Gogoanime, Komikindo, Komiku, Asura Scans | 终端内搜索番剧漫画、剧集流媒体解析、漫画章节导出 PDF |
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## 命令行参数 (Options)
|
|
67
|
+
|
|
68
|
+
```text
|
|
69
|
+
用法:
|
|
70
|
+
mori [URL] [参数]
|
|
71
|
+
npx @coflyn/mori [URL] [参数]
|
|
72
|
+
|
|
73
|
+
参数:
|
|
74
|
+
-o, --output <目录> 自定义下载目录 (默认: ~/Downloads/Mori)
|
|
75
|
+
-e, --engine <auto|mori|scrapr> 解析引擎选择 (默认: auto)
|
|
76
|
+
-s, --server <1|2> 选择服务器镜像 (TikTok, IG, YouTube, X, Spotify)
|
|
77
|
+
-a, --audio 仅提取并下载音频流 (MP3/M4A)
|
|
78
|
+
-p, --pdf 将多图贴文合并编译为单份 PDF 电子书
|
|
79
|
+
-c, --clip 自动读取系统剪贴板中的链接并开始下载
|
|
80
|
+
-y, --yes 无需确认直接下载 (自动选择最佳画质或下载整份播放列表)
|
|
81
|
+
-i, --info 仅查看媒体详情与可用画质流,不执行下载
|
|
82
|
+
-u, --update 检查包更新及 OTA 爬虫热补丁
|
|
83
|
+
-h, --help 显示帮助与使用指南
|
|
84
|
+
-v, --version 显示版本号
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## 交互模式与斜杠命令
|
|
90
|
+
|
|
91
|
+
不带任何参数运行 `mori` 将进入交互式 Shell。输入链接或搜索词开始,或使用 `/` 开头的内置命令:
|
|
92
|
+
|
|
93
|
+
| 命令 | 别名 | 功能说明 |
|
|
94
|
+
| :--- | :--- | :--- |
|
|
95
|
+
| `/clip` | `/paste` | 读取系统剪贴板并下载其中的多媒体链接 |
|
|
96
|
+
| `/audio [url]` | `/mp3` | 仅提取并下载音频流 (MP3/M4A) |
|
|
97
|
+
| `/pdf [url]` | — | 将图片画廊或贴文合并为单份 PDF |
|
|
98
|
+
| `/batch` | — | 批量下载多个链接 (空格或换行分隔) |
|
|
99
|
+
| `/play [序号]` | — | 在系统默认播放器中打开并播放已下载的音视频 |
|
|
100
|
+
| `/history [序号]` | — | 查看下载历史、重新下载或清空历史 (`/history clear`) |
|
|
101
|
+
| `/delete` | `/del`, `/rm` | 交互式多选删除 (可选择仅移除历史记录或同时删除本地文件) |
|
|
102
|
+
| `/open` | — | 在访达 (Finder) 或文件资源管理器中打开下载目录 |
|
|
103
|
+
| `/dir [路径]` | — | 查看或永久修改默认下载目录 |
|
|
104
|
+
| `/server` | — | 切换默认爬虫镜像服务器 |
|
|
105
|
+
| `/engine` | — | 在 Mori 引擎、Scrapr 引擎或自动模式间切换 |
|
|
106
|
+
| `/rollback` | — | 将解析引擎回滚至指定历史提交或版本 |
|
|
107
|
+
| `/info [url]` | `/inspect` | 打印媒体详细参数与流列表,不执行下载 |
|
|
108
|
+
| `/retry` | `/again` | 重新下载上次处理的链接 |
|
|
109
|
+
| `/ping [主机]` | — | 测试网络延迟与丢包率 (默认: 1.1.1.1) |
|
|
110
|
+
| `/stats` | — | 查看已下载文件总数、磁盘占用及各平台统计 |
|
|
111
|
+
| `/platforms` | `/platform` | 列出全部 27 个支持的平台与服务 |
|
|
112
|
+
| `/config` | — | 查看当前配置、存储路径与版本号 |
|
|
113
|
+
| `/update` | `/u` | 检查 npm 模块更新及来自 GitHub 的 OTA 爬虫补丁 |
|
|
114
|
+
| `/reset` | — | 将所有配置与下载历史恢复至出厂默认状态 |
|
|
115
|
+
| `/clear` | `/cls` | 清屏并重新打印终端标识 |
|
|
116
|
+
| `/help` | `/?` | 显示命令参考手册 |
|
|
117
|
+
| `/exit` | `/quit`, `/q` | 退出交互模式 |
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## 技术细节
|
|
122
|
+
|
|
123
|
+
- **双引擎架构**: 优先使用轻量内置解析核心;当目标网站页面改版时,自动回退到独立的 Scrapr 引擎。
|
|
124
|
+
- **OTA 热补丁机制**: 当平台接口变动时,解析逻辑可直接通过 GitHub 提交在线更新,无需等待发布新的 npm 版本。使用 `/update` 或 `/rollback` 随时管理引擎版本。
|
|
125
|
+
- **播放列表与专辑队列**: 粘贴 YouTube 播放列表、Spotify 专辑或 Apple Music 歌单时,终端将完整识别曲目编号与歌名,支持整单顺序下载或选择指定歌曲。
|
|
126
|
+
- **纯本地存储**: 配置文件与下载历史均保存在本地 `~/.mori` 中,不含任何追踪代码与数据埋点。
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## 开源协议
|
|
131
|
+
|
|
132
|
+
遵循 [GNU General Public License v3.0](https://github.com/coflyn/Mori/blob/main/LICENSE) 开源协议。
|
|
133
|
+
属于 **[Mori](https://github.com/coflyn/Mori)** 项目的一部分。
|