mirror of
https://github.com/Alvin-Zilverstand/Twitter-X-Media-Batch-Downloader.git
synced 2026-11-24 07:13:11 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2ada5da9bf | ||
|
|
3fb8bda2ff | ||
|
|
b4dfb75f5b | ||
|
|
7e584aff2c |
No files matched your search
@@ -1,20 +1,35 @@
|
||||
# Twitter/X Media Batch Downloader
|
||||
|
||||
A GUI tool to download original-quality images and videos from Twitter/X accounts.
|
||||
|
||||

|
||||

|
||||

|
||||
<div align="left">
|
||||
<h1>Twitter/X Media Batch Downloader</h1>
|
||||
<p>
|
||||
Downloads original-quality images and videos from Twitter/X accounts.
|
||||
</p>
|
||||
<p>
|
||||
<a href="https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/stargazers"><img
|
||||
src="https://img.shields.io/github/stars/afkarxyz/Twitter-X-Media-Batch-Downloader?color=ffcb47&labelColor=black&logo=github&label=Stars" /></a><a
|
||||
href="https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases"><img
|
||||
src="https://img.shields.io/github/downloads/afkarxyz/Twitter-X-Media-Batch-Downloader/total?color=22c55e&labelColor=black&logo=github&label=Downloads" /></a><a
|
||||
href="https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases/latest"><img
|
||||
src="https://img.shields.io/github/v/release/afkarxyz/Twitter-X-Media-Batch-Downloader?color=8b5cf6&labelColor=black&logo=github&label=Latest%20Release" /></a><a
|
||||
href="https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases/latest"><img
|
||||
src="https://img.shields.io/badge/Windows-10%2B-369eff?labelColor=black&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI1MTIiIGhlaWdodD0iNTEyIiB2aWV3Qm94PSIwIDAgMjAgMjAiPjxwYXRoIGZpbGw9IiNmZmZmZmYiIGZpbGwtcnVsZT0iZXZlbm9kZCIgZD0iTTIwIDEwLjg3M1YyMEw4LjQ3OSAxOC41MzdsLjAwMS03LjY2NEgyMFptLTEzLjEyIDBsLS4wMDEgNy40NjFMMCAxNy40NjF2LTYuNTg4aDYuODhaTTIwIDkuMjczSDguNDhsLS4wMDEtNy44MUwyMCAwdjkuMjczWk02Ljg3OSAxLjY2NmwuMDAxIDcuNjA3SDBWMi41MzlsNi44NzktLjg3M1oiLz48L3N2Zz4=" /></a><a
|
||||
href="https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases/latest"><img
|
||||
src="https://img.shields.io/badge/macOS-10.13%2B-FFFFFF?labelColor=black&logo=apple&logoColor=white" /></a><a
|
||||
href="https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases/latest"><img
|
||||
src="https://img.shields.io/badge/Linux-Any-FCC624?labelColor=black&logo=linux&logoColor=white" /></a>
|
||||
<br />
|
||||
<br />
|
||||
<a href="https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases/latest" target="_blank"><img
|
||||
src="https://github.com/user-attachments/assets/cef7b7e6-5a64-497a-91fe-b6fb549f3b09" alt="Twitter/X Media Batch Downloader" /></a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
### [Download](https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases)
|
||||
|
||||

|
||||
|
||||
- If you're familiar with userscripts, install it [**here**](https://greasyfork.org/en/scripts/523157)
|
||||
|
||||
- To install the Chrome extension version, click [**here**](https://chromewebstore.google.com/detail/cboceolmgkoobpfjiojkigmihijfgmdo)
|
||||
|
||||
- Also available on the web at [**MediaBatchDL.com**](https://mediabatchdl.com)
|
||||
- Also available on the web at [**TwitterDL.app**](https://twitterdl.app)
|
||||
|
||||
## How to Obtain Auth Token
|
||||
|
||||
|
||||
+20
-1
@@ -341,10 +341,29 @@ func DownloadMediaWithMetadataProgressAndStatus(items []MediaItem, outputDir str
|
||||
|
||||
filenameIndexes := make(map[string]int, len(filenameCounts))
|
||||
tasks := make([]downloadTask, 0, len(pendingTasks))
|
||||
|
||||
for _, pending := range pendingTasks {
|
||||
key := filenameCollisionKey(pending.typeDir, pending.baseName, pending.ext)
|
||||
|
||||
filenameIndexes[key]++
|
||||
pending.task.outputPath = filepath.Join(pending.typeDir, formatDownloadFilename(pending.baseName, pending.ext, filenameCounts[key], filenameIndexes[key]))
|
||||
|
||||
filename := formatDownloadFilename(
|
||||
pending.baseName,
|
||||
pending.ext,
|
||||
filenameCounts[key],
|
||||
filenameIndexes[key],
|
||||
)
|
||||
|
||||
if options.SkipExistingFiles {
|
||||
canonicalPath := filepath.Join(pending.typeDir, formatDownloadFilename(pending.baseName, pending.ext, 1, 1))
|
||||
if exists, err := fileExists(canonicalPath); err == nil && exists {
|
||||
pending.task.outputPath = canonicalPath
|
||||
tasks = append(tasks, pending.task)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
pending.task.outputPath = filepath.Join(pending.typeDir, filename)
|
||||
tasks = append(tasks, pending.task)
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
func OpenFolderInExplorer(path string) error {
|
||||
os.WriteFile(filepath.Join(os.TempDir(), "openfolder.txt"), []byte(path), 0644)
|
||||
os.WriteFile(filepath.Join(os.TempDir(), "openfolder.txt"), []byte(path), 0644)
|
||||
info, err := os.Stat(path)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
+2
-3
@@ -698,11 +698,10 @@ func ExtractTimeline(req TimelineRequest) (*TwitterResponse, error) {
|
||||
}
|
||||
|
||||
includeText := req.IncludeText
|
||||
wantsRetweets := req.Retweets
|
||||
|
||||
timelineType := req.TimelineType
|
||||
if timelineType == "" {
|
||||
if includeText || wantsRetweets {
|
||||
if includeText {
|
||||
timelineType = "tweets"
|
||||
} else {
|
||||
timelineType = "media"
|
||||
@@ -725,7 +724,7 @@ func ExtractTimeline(req TimelineRequest) (*TwitterResponse, error) {
|
||||
args = append(args, "--limit", fmt.Sprintf("%d", req.BatchSize))
|
||||
}
|
||||
|
||||
if timelineType == "tweets" || timelineType == "timeline" {
|
||||
if timelineType == "tweets" || timelineType == "timeline" || timelineType == "media" {
|
||||
if req.Retweets {
|
||||
args = append(args, "--retweets", "include")
|
||||
} else {
|
||||
|
||||
@@ -441,7 +441,7 @@ function App() {
|
||||
}
|
||||
else {
|
||||
const batchSize = BATCH_SIZE;
|
||||
let timelineType = (settings.includeText || retweets) ? "tweets" : "media";
|
||||
let timelineType = settings.includeText ? "tweets" : "media";
|
||||
if (isBookmarks) {
|
||||
timelineType = "bookmarks";
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 45 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 44 KiB |
@@ -13,11 +13,16 @@ import { Spinner } from "@/components/ui/spinner";
|
||||
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu";
|
||||
import { Trash2, FileInput, FileOutput, Pencil, Tag, Shuffle, X, XCircle, Download, StopCircle, Globe, Lock, Bookmark, Heart, Image, Images, Video, Film, FileText, Filter, AlertCircle, MoreVertical, FileBraces, CloudBackup, Search, LayoutGrid, Grid3X3, List, ArrowUpDown, ArrowUp, FolderOpen, Users, MessageSquare } from "lucide-react";
|
||||
import { toastWithSound as toast } from "@/lib/toast-with-sound";
|
||||
import { getSettings, renderFolderTemplate } from "@/lib/settings";
|
||||
import { beginDownload, finishDownload, useDownloadState } from "@/lib/download-state";
|
||||
import { getSettings } from "@/lib/settings";
|
||||
import { openExternal } from "@/lib/utils";
|
||||
import { GetAllAccountsFromDB, GetAccountFromDB, DeleteAccountFromDB, SaveAccountToDB, ExportAccountJSON, ExportAccountsTXT, UpdateAccountGroup, GetAllGroups, DownloadMediaWithMetadata, StopDownload, CheckFoldersExist, OpenFolder, GetFolderPath, } from "../../wailsjs/go/main/App";
|
||||
import { EventsOn } from "../../wailsjs/runtime/runtime";
|
||||
import { main } from "../../wailsjs/go/models";
|
||||
interface DownloadProgress {
|
||||
current: number;
|
||||
total: number;
|
||||
percent: number;
|
||||
}
|
||||
function formatNumberWithComma(num: number): string {
|
||||
return num.toLocaleString();
|
||||
}
|
||||
@@ -88,31 +93,23 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
|
||||
const [editGroupName, setEditGroupName] = useState("");
|
||||
const [editGroupColor, setEditGroupColor] = useState("");
|
||||
const [clearAllDialogOpen, setClearAllDialogOpen] = useState(false);
|
||||
const [isDownloading, setIsDownloading] = useState(false);
|
||||
const [downloadingAccountId, setDownloadingAccountId] = useState<number | null>(null);
|
||||
const [downloadProgress, setDownloadProgress] = useState<DownloadProgress | null>(null);
|
||||
const [isBulkDownloading, setIsBulkDownloading] = useState(false);
|
||||
const [bulkDownloadCurrent, setBulkDownloadCurrent] = useState(0);
|
||||
const [bulkDownloadTotal, setBulkDownloadTotal] = useState(0);
|
||||
const stopBulkDownloadRef = useRef(false);
|
||||
const loadMoreRef = useRef<HTMLDivElement>(null);
|
||||
const [folderExistence, setFolderExistence] = useState<Map<number, boolean>>(new Map());
|
||||
const downloadState = useDownloadState();
|
||||
const anyDownloadActive = downloadState.active;
|
||||
const isDownloading = downloadState.active && (downloadState.scope === "database" || downloadState.scope === "database-bulk");
|
||||
const downloadingAccountId = isDownloading ? downloadState.accountId : null;
|
||||
const downloadProgress = isDownloading ? downloadState.progress : null;
|
||||
const getFolderNameForAccount = (username: string, accountName?: string) => {
|
||||
const getFolderNameForAccount = (username: string) => {
|
||||
if (username === "bookmarks") {
|
||||
return "My Bookmarks";
|
||||
}
|
||||
if (username === "likes") {
|
||||
return "My Likes";
|
||||
}
|
||||
const now = new Date();
|
||||
const date = `${now.getFullYear()}${String(now.getMonth() + 1).padStart(2, "0")}${String(now.getDate()).padStart(2, "0")}`;
|
||||
return renderFolderTemplate(getSettings().folderTemplate, {
|
||||
username,
|
||||
accountName: accountName || username,
|
||||
date,
|
||||
}) || username;
|
||||
return username;
|
||||
};
|
||||
const loadAccounts = useCallback(async () => {
|
||||
setLoading(true);
|
||||
@@ -150,6 +147,14 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
|
||||
scrollElement.addEventListener("scroll", handleScroll);
|
||||
return () => scrollElement.removeEventListener("scroll", handleScroll);
|
||||
}, []);
|
||||
useEffect(() => {
|
||||
const unsubscribe = EventsOn("download-progress", (progress: DownloadProgress) => {
|
||||
setDownloadProgress(progress);
|
||||
});
|
||||
return () => {
|
||||
unsubscribe();
|
||||
};
|
||||
}, []);
|
||||
const scrollToTop = () => {
|
||||
getContentScrollElement()?.scrollTo({ top: 0, behavior: "smooth" });
|
||||
};
|
||||
@@ -221,7 +226,7 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
|
||||
}, [accountViewMode, filterGroup, filterMediaType, privateAccounts, publicAccounts, deferredSearchQuery, sortOrder]);
|
||||
const visibleAccounts = useMemo(() => filteredAccounts.slice(0, visibleCount), [filteredAccounts, visibleCount]);
|
||||
const visibleAccountsKey = visibleAccounts
|
||||
.map((account) => `${account.id}:${account.username}:${account.name}`)
|
||||
.map((account) => `${account.id}:${account.username}`)
|
||||
.join("|");
|
||||
useEffect(() => {
|
||||
const basePath = currentDownloadPath;
|
||||
@@ -235,7 +240,7 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
|
||||
let active = true;
|
||||
const loadVisibleFolderExistence = async () => {
|
||||
try {
|
||||
const folderNames = visibleAccounts.map((account) => getFolderNameForAccount(account.username, account.name));
|
||||
const folderNames = visibleAccounts.map((account) => getFolderNameForAccount(account.username));
|
||||
const results = await CheckFoldersExist(basePath, folderNames);
|
||||
if (!active) {
|
||||
return;
|
||||
@@ -243,7 +248,7 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
|
||||
setFolderExistence((prev) => {
|
||||
const next = new Map(prev);
|
||||
for (const account of visibleAccounts) {
|
||||
next.set(account.id, results[getFolderNameForAccount(account.username, account.name)] ?? false);
|
||||
next.set(account.id, results[getFolderNameForAccount(account.username)] ?? false);
|
||||
}
|
||||
return next;
|
||||
});
|
||||
@@ -313,13 +318,26 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
|
||||
};
|
||||
const handleOpenFolder = async (account: AccountListItem) => {
|
||||
const settings = getSettings();
|
||||
const folderName = getFolderNameForAccount(account.username, account.name);
|
||||
const folderPath = await GetFolderPath(settings.downloadPath, folderName);
|
||||
const basePath = settings.downloadPath || "";
|
||||
if (!basePath) {
|
||||
toast.error("Download folder is not set");
|
||||
return;
|
||||
}
|
||||
let username = account.username || account.name || "";
|
||||
try {
|
||||
const responseJSON = await GetAccountFromDB(account.id);
|
||||
const data = JSON.parse(responseJSON);
|
||||
username = data.account_info?.name || username;
|
||||
}
|
||||
catch {
|
||||
}
|
||||
const folderName = getFolderNameForAccount(username);
|
||||
try {
|
||||
const folderPath = await GetFolderPath(basePath, folderName);
|
||||
await OpenFolder(folderPath);
|
||||
}
|
||||
catch (error) {
|
||||
console.error(`Failed to open folder for @${account.username}:`, error);
|
||||
console.error(`Failed to open folder for @${username}:`, error);
|
||||
toast.error("Failed to open folder");
|
||||
}
|
||||
};
|
||||
@@ -345,7 +363,9 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
|
||||
outputDir = `${settings.downloadPath}${separator}My Likes`;
|
||||
}
|
||||
const actualUsername = data.account_info?.name || username;
|
||||
beginDownload({ current: 0, total: timeline.length, percent: 0 }, { scope: "database", accountId: id });
|
||||
setIsDownloading(true);
|
||||
setDownloadingAccountId(id);
|
||||
setDownloadProgress({ current: 0, total: timeline.length, percent: 0 });
|
||||
const request = new main.DownloadMediaWithMetadataRequest({
|
||||
items: timeline.map((item: {
|
||||
url: string;
|
||||
@@ -354,7 +374,6 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
|
||||
type: string;
|
||||
original_filename?: string;
|
||||
author_username?: string;
|
||||
author_name?: string;
|
||||
}) => new main.MediaItemRequest({
|
||||
url: item.url,
|
||||
date: item.date,
|
||||
@@ -362,7 +381,6 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
|
||||
type: item.type,
|
||||
original_filename: item.original_filename || "",
|
||||
author_username: item.author_username || "",
|
||||
account_name: item.author_name || data.account_info?.nick || actualUsername,
|
||||
})),
|
||||
output_dir: outputDir,
|
||||
username: actualUsername,
|
||||
@@ -373,9 +391,6 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
|
||||
proxy: settings.proxy || "",
|
||||
filename_template: settings.filenameTemplate || "",
|
||||
folder_template: settings.folderTemplate || "",
|
||||
auto_convert_gifs: settings.autoConvertGifs,
|
||||
gif_quality: settings.gifQuality || "fast",
|
||||
gif_resolution: settings.gifResolution || "original",
|
||||
});
|
||||
const response = await DownloadMediaWithMetadata(request);
|
||||
if (response.cancelled) {
|
||||
@@ -412,14 +427,15 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
|
||||
toast.error(`Download failed: ${errorMsg}`);
|
||||
}
|
||||
finally {
|
||||
finishDownload();
|
||||
setIsDownloading(false);
|
||||
setDownloadingAccountId(null);
|
||||
setDownloadProgress(null);
|
||||
}
|
||||
};
|
||||
const handleStopDownload = async () => {
|
||||
try {
|
||||
const stopped = await StopDownload();
|
||||
if (stopped) {
|
||||
finishDownload();
|
||||
toast.info("Download stopped");
|
||||
}
|
||||
}
|
||||
@@ -451,7 +467,7 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
|
||||
if (!account)
|
||||
continue;
|
||||
setBulkDownloadCurrent(i + 1);
|
||||
beginDownload({ current: 0, total: 0, percent: 0 }, { scope: "database-bulk", accountId: id });
|
||||
setDownloadingAccountId(id);
|
||||
try {
|
||||
const responseJSON = await GetAccountFromDB(id);
|
||||
const data = JSON.parse(responseJSON);
|
||||
@@ -462,7 +478,7 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
|
||||
toast.info("Bulk download stopped");
|
||||
break;
|
||||
}
|
||||
beginDownload({ current: 0, total: timeline.length, percent: 0 }, { scope: "database-bulk", accountId: id });
|
||||
setDownloadProgress({ current: 0, total: timeline.length, percent: 0 });
|
||||
const isBookmarks = data.account_info?.nick === "My Bookmarks" || account.username === "bookmarks";
|
||||
const isLikes = data.account_info?.nick === "My Likes" || account.username === "likes";
|
||||
let outputDir = settings.downloadPath;
|
||||
@@ -482,7 +498,6 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
|
||||
tweet_id: string;
|
||||
type: string;
|
||||
author_username?: string;
|
||||
author_name?: string;
|
||||
original_filename?: string;
|
||||
}) => new main.MediaItemRequest({
|
||||
url: item.url,
|
||||
@@ -490,7 +505,6 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
|
||||
tweet_id: item.tweet_id,
|
||||
type: item.type,
|
||||
author_username: item.author_username || "",
|
||||
account_name: item.author_name || data.account_info?.nick || actualUsername,
|
||||
original_filename: item.original_filename || "",
|
||||
})),
|
||||
output_dir: outputDir,
|
||||
@@ -502,9 +516,6 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
|
||||
proxy: settings.proxy || "",
|
||||
filename_template: settings.filenameTemplate || "",
|
||||
folder_template: settings.folderTemplate || "",
|
||||
auto_convert_gifs: settings.autoConvertGifs,
|
||||
gif_quality: settings.gifQuality || "fast",
|
||||
gif_resolution: settings.gifResolution || "original",
|
||||
});
|
||||
const response = await DownloadMediaWithMetadata(request);
|
||||
if (response.cancelled) {
|
||||
@@ -523,7 +534,8 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
|
||||
}
|
||||
}
|
||||
setIsBulkDownloading(false);
|
||||
finishDownload();
|
||||
setDownloadingAccountId(null);
|
||||
setDownloadProgress(null);
|
||||
setBulkDownloadCurrent(0);
|
||||
setBulkDownloadTotal(0);
|
||||
if ((totalDownloaded > 0 || totalSkipped > 0) && !stopBulkDownloadRef.current) {
|
||||
@@ -820,7 +832,7 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
|
||||
<TooltipContent>Stop Bulk Download</TooltipContent>
|
||||
</Tooltip>) : (<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<Button variant="default" size="icon" onClick={handleBulkDownload} disabled={selectedIds.size === 0 || anyDownloadActive}>
|
||||
<Button variant="default" size="icon" onClick={handleBulkDownload} disabled={selectedIds.size === 0 || isDownloading}>
|
||||
<Download className="h-4 w-4"/>
|
||||
</Button>
|
||||
</TooltipTrigger>
|
||||
@@ -1048,10 +1060,10 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
|
||||
{formatNumberWithComma(account.total_media)} media
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex gap-1">
|
||||
<div className="flex gap-1" onClick={(e) => e.stopPropagation()}>
|
||||
{downloadingAccountId === account.id ? (<Button variant="outline" size="icon" className="h-8 w-8" onClick={handleStopDownload}>
|
||||
<StopCircle className="h-4 w-4 text-destructive"/>
|
||||
</Button>) : (<Button variant="default" size="icon" className="h-8 w-8" onClick={() => handleDownload(account.id, account.username)} disabled={anyDownloadActive}>
|
||||
</Button>) : (<Button variant="default" size="icon" className="h-8 w-8" onClick={() => handleDownload(account.id, account.username)} disabled={isDownloading}>
|
||||
<Download className="h-4 w-4"/>
|
||||
</Button>)}
|
||||
<Button variant="outline" size="icon" className="h-8 w-8" onClick={() => handleOpenFolder(account)} disabled={!folderExistence.get(account.id)}>
|
||||
@@ -1064,7 +1076,10 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end">
|
||||
{!isPrivateAccount(account.username) && (<DropdownMenuItem onClick={() => handleEditGroup(account)}>
|
||||
{!isPrivateAccount(account.username) && (<DropdownMenuItem onSelect={(event) => {
|
||||
event.preventDefault();
|
||||
handleEditGroup(account);
|
||||
}}>
|
||||
<Pencil className="h-4 w-4 mr-2"/>
|
||||
Edit Group
|
||||
</DropdownMenuItem>)}
|
||||
@@ -1142,10 +1157,10 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
|
||||
{formatNumberWithComma(account.total_media)} media
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex gap-1">
|
||||
<div className="flex gap-1" onClick={(e) => e.stopPropagation()}>
|
||||
{downloadingAccountId === account.id ? (<Button variant="outline" size="icon" className="h-7 w-7" onClick={handleStopDownload}>
|
||||
<StopCircle className="h-3 w-3 text-destructive"/>
|
||||
</Button>) : (<Button variant="default" size="icon" className="h-7 w-7" onClick={() => handleDownload(account.id, account.username)} disabled={anyDownloadActive}>
|
||||
</Button>) : (<Button variant="default" size="icon" className="h-7 w-7" onClick={() => handleDownload(account.id, account.username)} disabled={isDownloading}>
|
||||
<Download className="h-3 w-3"/>
|
||||
</Button>)}
|
||||
<Button variant="outline" size="icon" className="h-7 w-7" onClick={() => handleOpenFolder(account)} disabled={!folderExistence.get(account.id)}>
|
||||
@@ -1158,7 +1173,10 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end">
|
||||
{!isPrivateAccount(account.username) && (<DropdownMenuItem onClick={() => handleEditGroup(account)}>
|
||||
{!isPrivateAccount(account.username) && (<DropdownMenuItem onSelect={(event) => {
|
||||
event.preventDefault();
|
||||
handleEditGroup(account);
|
||||
}}>
|
||||
<Pencil className="h-4 w-4 mr-2"/>
|
||||
Edit Group
|
||||
</DropdownMenuItem>)}
|
||||
@@ -1253,7 +1271,7 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
|
||||
{account.last_fetched} {getRelativeTime(account.last_fetched)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="flex items-center gap-2" onClick={(e) => e.stopPropagation()}>
|
||||
{downloadingAccountId === account.id ? (<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<Button variant="outline" size="icon" onClick={handleStopDownload}>
|
||||
@@ -1263,7 +1281,7 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
|
||||
<TooltipContent>Stop Download</TooltipContent>
|
||||
</Tooltip>) : (<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<Button variant="default" size="icon" onClick={() => handleDownload(account.id, account.username)} disabled={anyDownloadActive}>
|
||||
<Button variant="default" size="icon" onClick={() => handleDownload(account.id, account.username)} disabled={isDownloading}>
|
||||
{isDownloading && downloadingAccountId === account.id ? (<Spinner className="h-4 w-4"/>) : (<Download className="h-4 w-4"/>)}
|
||||
</Button>
|
||||
</TooltipTrigger>
|
||||
@@ -1289,7 +1307,10 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
|
||||
<TooltipContent>More Options</TooltipContent>
|
||||
</Tooltip>
|
||||
<DropdownMenuContent align="end">
|
||||
{!isPrivateAccount(account.username) && (<DropdownMenuItem onClick={() => handleEditGroup(account)}>
|
||||
{!isPrivateAccount(account.username) && (<DropdownMenuItem onSelect={(event) => {
|
||||
event.preventDefault();
|
||||
handleEditGroup(account);
|
||||
}}>
|
||||
<Pencil className="h-4 w-4 mr-2"/>
|
||||
Edit Group
|
||||
</DropdownMenuItem>)}
|
||||
|
||||
@@ -11,7 +11,7 @@ import { toastWithSound as toast } from "@/lib/toast-with-sound";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { getSettings, updateSettings, VIDEO_QUALITIES, IMAGE_SIZES, AVATAR_SIZES, BANNER_SIZES, type VideoQuality, type ImageSize, type AvatarSize, type BannerSize } from "@/lib/settings";
|
||||
import { GetStoredAuthToken, SetStoredAuthToken } from "../../wailsjs/go/main/App";
|
||||
import { AlertCircle, Bookmark, CheckCircle, CloudDownload, Clock, Database, Eye, EyeOff, Globe, Heart, Hourglass, Info, Lock, RotateCcw, SlidersHorizontal, StopCircle, Trash2, User, Users, XCircle } from "lucide-react";
|
||||
import { AlertCircle, Bookmark, CheckCircle, Clipboard, CloudDownload, Clock, Database, Eye, EyeOff, Globe, Heart, Hourglass, Info, Lock, RotateCcw, SlidersHorizontal, StopCircle, Trash2, User, Users, XCircle } from "lucide-react";
|
||||
import { Spinner } from "@/components/ui/spinner";
|
||||
function formatNumberWithComma(num: number): string {
|
||||
return num.toLocaleString();
|
||||
@@ -207,6 +207,17 @@ export function SearchBar({ username, loading, onUsernameChange, onFetch, onStop
|
||||
onFetch(false, undefined, undefined, undefined, retweets, mode, privateType, authToken, false);
|
||||
});
|
||||
};
|
||||
const handleClipboardPaste = async () => {
|
||||
try {
|
||||
const clipboardText = (await navigator.clipboard.readText()).trim();
|
||||
if (clipboardText) {
|
||||
onUsernameChange(clipboardText);
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
console.error("Failed to read clipboard:", error);
|
||||
}
|
||||
};
|
||||
const handleResume = () => {
|
||||
if (onResume) {
|
||||
requireAuthToken((authToken) => {
|
||||
@@ -371,6 +382,10 @@ export function SearchBar({ username, loading, onUsernameChange, onFetch, onStop
|
||||
</button>)}
|
||||
</div>
|
||||
|
||||
<Button variant="outline" size="icon" className="shrink-0" aria-label="Paste from clipboard" onClick={() => void handleClipboardPaste()}>
|
||||
<Clipboard className="h-4 w-4"/>
|
||||
</Button>
|
||||
|
||||
<div className="flex items-center gap-2">
|
||||
{loading && (<Button variant="destructive" onClick={onStopFetch}>
|
||||
<StopCircle className="h-4 w-4"/>
|
||||
|
||||
@@ -1,16 +1,57 @@
|
||||
import { useState } from "react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||
import { CircleCheck, Copy } from "lucide-react";
|
||||
import { openExternal } from "@/lib/utils";
|
||||
import KofiLogo from "@/assets/ko-fi.gif";
|
||||
import KofiSvg from "@/assets/kofi_symbol.svg";
|
||||
import UsdtBarcode from "@/assets/usdt.jpg";
|
||||
const USDT_ADDRESS = "THnzAAwZgp2Sq5CAXLP2njQDhTvgZG9EWs";
|
||||
import UsdtTronQr from "@/assets/usdt.jpg";
|
||||
import UsdtEvmQr from "@/assets/usdt_evm.jpg";
|
||||
import UsdcEvmQr from "@/assets/usdc.jpg";
|
||||
type CryptoCoin = "usdt" | "usdc";
|
||||
type CryptoNetwork = "ethereum" | "bsc" | "polygon" | "base" | "tron";
|
||||
const EVM_ADDRESS = "0xB563a7F39770C151e2FacE26926081a00c5EF349";
|
||||
const TRON_ADDRESS = "THnzAAwZgp2Sq5CAXLP2njQDhTvgZG9EWs";
|
||||
const EVM_NETWORKS: Array<{
|
||||
value: CryptoNetwork;
|
||||
label: string;
|
||||
shortLabel: string;
|
||||
}> = [
|
||||
{ value: "bsc", label: "BNB Smart Chain (BEP20)", shortLabel: "BEP20" },
|
||||
{ value: "polygon", label: "Polygon", shortLabel: "Polygon" },
|
||||
{ value: "ethereum", label: "Ethereum (ERC20)", shortLabel: "ERC20" },
|
||||
{ value: "base", label: "Base", shortLabel: "Base" },
|
||||
];
|
||||
const USDT_NETWORKS: Array<{
|
||||
value: CryptoNetwork;
|
||||
label: string;
|
||||
shortLabel: string;
|
||||
}> = [
|
||||
{ value: "ethereum", label: "Ethereum (ERC20)", shortLabel: "ERC20" },
|
||||
{ value: "bsc", label: "BNB Smart Chain (BEP20)", shortLabel: "BEP20" },
|
||||
{ value: "tron", label: "Tron (TRC20)", shortLabel: "TRC20" },
|
||||
{ value: "polygon", label: "Polygon", shortLabel: "Polygon" },
|
||||
];
|
||||
export function SupportPage() {
|
||||
const [copiedUsdt, setCopiedUsdt] = useState(false);
|
||||
const [selectedCoin, setSelectedCoin] = useState<CryptoCoin>("usdt");
|
||||
const [selectedNetwork, setSelectedNetwork] = useState<CryptoNetwork>("tron");
|
||||
const [copiedAddress, setCopiedAddress] = useState(false);
|
||||
const networkOptions = selectedCoin === "usdt" ? USDT_NETWORKS : EVM_NETWORKS;
|
||||
const activeNetwork = networkOptions.find((network) => network.value === selectedNetwork) || EVM_NETWORKS[0];
|
||||
const isTron = selectedNetwork === "tron";
|
||||
const cryptoAddress = isTron ? TRON_ADDRESS : EVM_ADDRESS;
|
||||
const cryptoQr = isTron ? UsdtTronQr : selectedCoin === "usdt" ? UsdtEvmQr : UsdcEvmQr;
|
||||
const handleCoinChange = (coin: CryptoCoin) => {
|
||||
setSelectedCoin(coin);
|
||||
setCopiedAddress(false);
|
||||
const nextNetworks = coin === "usdt" ? USDT_NETWORKS : EVM_NETWORKS;
|
||||
if (!nextNetworks.some((network) => network.value === selectedNetwork)) {
|
||||
setSelectedNetwork("ethereum");
|
||||
}
|
||||
};
|
||||
return (<div className="flex min-h-[70vh] items-center justify-center p-4">
|
||||
<div className="flex w-full max-w-3xl flex-col items-stretch rounded-xl border bg-card shadow-sm md:flex-row">
|
||||
<div className="flex flex-1 flex-col items-center justify-between space-y-6 border-b p-6 md:border-r md:border-b-0">
|
||||
<div className="flex min-w-0 flex-1 basis-0 flex-col items-center justify-between space-y-6 border-b p-6 md:border-r md:border-b-0">
|
||||
<div className="flex flex-col items-center space-y-4">
|
||||
<div className="relative flex h-32 w-full items-center justify-center">
|
||||
<img src={KofiLogo} className="pointer-events-none absolute w-72" alt="Ko-fi"/>
|
||||
@@ -20,35 +61,59 @@ export function SupportPage() {
|
||||
Enjoying the project? You can support ongoing development by buying me a coffee.
|
||||
</p>
|
||||
</div>
|
||||
<Button className="h-10 w-full gap-2 bg-[#72a4f2] text-sm font-semibold text-white hover:bg-[#5f8cd6]" onClick={() => openExternal("https://ko-fi.com/afkarxyz")}>
|
||||
<img src={KofiSvg} className="h-5 w-5 shrink-0" alt="" aria-hidden="true"/>
|
||||
<Button className="h-9 w-4/5 gap-2 bg-[#72a4f2] text-sm font-semibold text-white hover:bg-[#5f8cd6]" onClick={() => openExternal("https://ko-fi.com/afkarxyz")}>
|
||||
<img src={KofiSvg} className="h-6 w-6 shrink-0" alt="" aria-hidden="true"/>
|
||||
Support me on Ko-fi
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-1 flex-col items-center justify-between space-y-6 p-6">
|
||||
<div className="flex w-full flex-col items-center space-y-4">
|
||||
<div className="flex min-w-0 flex-1 basis-0 flex-col items-center justify-between space-y-4 p-6">
|
||||
<div className="flex w-full flex-col items-center space-y-3">
|
||||
<div className="flex h-32 items-center justify-center">
|
||||
<div className="rounded-xl border bg-white p-2 shadow-sm">
|
||||
<img src={UsdtBarcode} className="h-24 w-24 object-contain" alt="USDT Barcode"/>
|
||||
<img src={cryptoQr} className="h-24 w-24 object-contain" alt={`${selectedCoin.toUpperCase()} ${activeNetwork.label} QR code`}/>
|
||||
</div>
|
||||
</div>
|
||||
<h4 className="font-semibold text-foreground">USDT (TRC20)</h4>
|
||||
<h4 className="font-semibold text-foreground">Support via Crypto</h4>
|
||||
<p className="px-4 text-center text-sm text-muted-foreground">
|
||||
Crypto donations are also accepted. Scan the QR code or copy the address.
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex h-10 w-full items-center justify-between gap-2 rounded-lg border bg-muted/50 py-1.5 pr-1.5 pl-3">
|
||||
<code className="truncate text-xs font-mono text-muted-foreground" title={USDT_ADDRESS}>
|
||||
{USDT_ADDRESS}
|
||||
</code>
|
||||
<Button variant="ghost" size="icon" className="h-7 w-7 shrink-0 hover:bg-background" onClick={() => {
|
||||
navigator.clipboard.writeText(USDT_ADDRESS);
|
||||
setCopiedUsdt(true);
|
||||
setTimeout(() => setCopiedUsdt(false), 500);
|
||||
<div className="w-full space-y-2">
|
||||
<div className="grid grid-cols-2 gap-2">
|
||||
<Select value={selectedCoin} onValueChange={(value: CryptoCoin) => handleCoinChange(value)}>
|
||||
<SelectTrigger size="sm" className="w-full" aria-label="Coin">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="usdt">USDT</SelectItem>
|
||||
<SelectItem value="usdc">USDC</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<Select value={selectedNetwork} onValueChange={(value: CryptoNetwork) => {
|
||||
setSelectedNetwork(value);
|
||||
setCopiedAddress(false);
|
||||
}}>
|
||||
{copiedUsdt ? <CircleCheck className="h-3.5 w-3.5 text-green-500"/> : <Copy className="h-3.5 w-3.5"/>}
|
||||
</Button>
|
||||
<SelectTrigger size="sm" className="w-full" aria-label="Network">
|
||||
<SelectValue>{activeNetwork.shortLabel}</SelectValue>
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{networkOptions.map((network) => (<SelectItem key={network.value} value={network.value}>{network.label}</SelectItem>))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
<div className="flex h-10 w-full items-center justify-between gap-2 rounded-lg border bg-muted/50 py-1.5 pr-1.5 pl-3">
|
||||
<code className="min-w-0 flex-1 truncate text-xs font-mono text-muted-foreground" title={cryptoAddress}>
|
||||
{cryptoAddress}
|
||||
</code>
|
||||
<Button variant="ghost" size="icon" className="h-7 w-7 shrink-0 hover:bg-background" aria-label="Copy wallet address" onClick={() => {
|
||||
navigator.clipboard.writeText(cryptoAddress);
|
||||
setCopiedAddress(true);
|
||||
setTimeout(() => setCopiedAddress(false), 500);
|
||||
}}>
|
||||
{copiedAddress ? <CircleCheck className="h-3.5 w-3.5 text-green-500"/> : <Copy className="h-3.5 w-3.5"/>}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -5,7 +5,7 @@ import { openExternal } from "@/lib/utils";
|
||||
const INFO_LINKS = [
|
||||
{ label: "Chrome Extension", icon: Puzzle, url: "https://chromewebstore.google.com/detail/cboceolmgkoobpfjiojkigmihijfgmdo" },
|
||||
{ label: "Userscript", icon: FileCode2, url: "https://greasyfork.org/en/scripts/523157" },
|
||||
{ label: "Website", icon: Globe, url: "https://mediabatchdl.com" },
|
||||
{ label: "Website", icon: Globe, url: "https://twitterdl.app" },
|
||||
];
|
||||
export function TitleBar() {
|
||||
const handleMinimize = () => {
|
||||
|
||||
@@ -1,21 +1,17 @@
|
||||
import { useSyncExternalStore } from "react";
|
||||
import { EventsOn } from "../../wailsjs/runtime/runtime";
|
||||
|
||||
export interface DownloadProgress {
|
||||
current: number;
|
||||
total: number;
|
||||
percent: number;
|
||||
}
|
||||
|
||||
export interface DownloadItemStatus {
|
||||
tweet_id: number;
|
||||
index: number;
|
||||
status: "success" | "failed" | "skipped" | "cancelled";
|
||||
}
|
||||
|
||||
export type DownloadScope = "media" | "database" | "database-bulk";
|
||||
export type DownloadItemResult = "success" | "failed" | "skipped";
|
||||
|
||||
export interface DownloadState {
|
||||
active: boolean;
|
||||
scope: DownloadScope | null;
|
||||
@@ -25,9 +21,7 @@ export interface DownloadState {
|
||||
itemKeyByIndex: Record<number, string>;
|
||||
itemStatusByKey: Record<string, DownloadItemResult>;
|
||||
}
|
||||
|
||||
const listeners = new Set<() => void>();
|
||||
|
||||
let state: DownloadState = {
|
||||
active: false,
|
||||
scope: null,
|
||||
@@ -37,20 +31,16 @@ let state: DownloadState = {
|
||||
itemKeyByIndex: {},
|
||||
itemStatusByKey: {},
|
||||
};
|
||||
|
||||
let unsubscribeEvents: (() => void) | null = null;
|
||||
|
||||
function emit() {
|
||||
for (const listener of listeners) {
|
||||
listener();
|
||||
}
|
||||
}
|
||||
|
||||
function setState(next: Partial<DownloadState>) {
|
||||
state = { ...state, ...next };
|
||||
emit();
|
||||
}
|
||||
|
||||
export function initDownloadProgressEvents() {
|
||||
if (unsubscribeEvents) {
|
||||
return unsubscribeEvents;
|
||||
@@ -80,11 +70,7 @@ export function initDownloadProgressEvents() {
|
||||
};
|
||||
return unsubscribeEvents;
|
||||
}
|
||||
|
||||
export function beginDownload(
|
||||
progress: DownloadProgress,
|
||||
meta: Pick<DownloadState, "scope"> & Partial<Pick<DownloadState, "accountId" | "currentItemKey" | "itemKeyByIndex">>
|
||||
) {
|
||||
export function beginDownload(progress: DownloadProgress, meta: Pick<DownloadState, "scope"> & Partial<Pick<DownloadState, "accountId" | "currentItemKey" | "itemKeyByIndex">>) {
|
||||
setState({
|
||||
active: true,
|
||||
scope: meta.scope,
|
||||
@@ -94,7 +80,6 @@ export function beginDownload(
|
||||
itemKeyByIndex: meta.itemKeyByIndex ?? {},
|
||||
});
|
||||
}
|
||||
|
||||
export function finishDownload() {
|
||||
setState({
|
||||
active: false,
|
||||
@@ -105,7 +90,6 @@ export function finishDownload() {
|
||||
itemKeyByIndex: {},
|
||||
});
|
||||
}
|
||||
|
||||
export function setDownloadItemStatus(itemKey: string, status: DownloadItemResult) {
|
||||
setState({
|
||||
itemStatusByKey: {
|
||||
@@ -114,18 +98,15 @@ export function setDownloadItemStatus(itemKey: string, status: DownloadItemResul
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function subscribeDownloadState(listener: () => void) {
|
||||
listeners.add(listener);
|
||||
return () => {
|
||||
listeners.delete(listener);
|
||||
};
|
||||
}
|
||||
|
||||
export function getDownloadState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
export function useDownloadState() {
|
||||
return useSyncExternalStore(subscribeDownloadState, getDownloadState, getDownloadState);
|
||||
}
|
||||
+1
-1
@@ -11,7 +11,7 @@
|
||||
},
|
||||
"info": {
|
||||
"productName": "Twitter/X Media Batch Downloader",
|
||||
"productVersion": "4.8"
|
||||
"productVersion": "4.9"
|
||||
},
|
||||
"wailsjsdir": "./frontend",
|
||||
"assetdir": "./frontend/dist",
|
||||
|
||||
Reference in new issue
Block a user