This commit is contained in:
afkarxyz committed 2026-07-16 18:27:23 +07:00
1 parent 3fb8bda2ff
commit 2ada5da9bf
12 files changed
+164 -116

No files matched your search

+20 -22
View File
@@ -340,34 +340,32 @@ func DownloadMediaWithMetadataProgressAndStatus(items []MediaItem, outputDir str
}
filenameIndexes := make(map[string]int, len(filenameCounts))
tasks := make([]downloadTask, 0, len(pendingTasks))
tasks := make([]downloadTask, 0, len(pendingTasks))
for _, pending := range pendingTasks {
key := filenameCollisionKey(pending.typeDir, pending.baseName, pending.ext)
for _, pending := range pendingTasks {
key := filenameCollisionKey(pending.typeDir, pending.baseName, pending.ext)
filenameIndexes[key]++
filenameIndexes[key]++
filename := formatDownloadFilename(
pending.baseName,
pending.ext,
filenameCounts[key],
filenameIndexes[key],
)
filename := formatDownloadFilename(
pending.baseName,
pending.ext,
filenameCounts[key],
filenameIndexes[key],
)
// If skipping existing files, first check the canonical filename.
// This prevents existing files from being downloaded again as _01, _02, etc.
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
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)
}
pending.task.outputPath = filepath.Join(pending.typeDir, filename)
tasks = append(tasks, pending.task)
}
var downloadedCount int64
var skippedCount int64
+1 -1
View File
@@ -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
View File
@@ -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 {
+1 -1
View File
@@ -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

+36 -46
View File
@@ -317,34 +317,30 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
}
};
const handleOpenFolder = async (account: AccountListItem) => {
const settings = getSettings();
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 {
// fall back to saved row data
}
const folderName = getFolderNameForAccount(username);
try {
const folderPath = await GetFolderPath(basePath, folderName);
await OpenFolder(folderPath);
} catch (error) {
console.error(`Failed to open folder for @${username}:`, error);
toast.error("Failed to open folder");
}
};
const settings = getSettings();
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 @${username}:`, error);
toast.error("Failed to open folder");
}
};
const handleDownload = async (id: number, username: string) => {
try {
const responseJSON = await GetAccountFromDB(id);
@@ -1080,12 +1076,10 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
{!isPrivateAccount(account.username) && (<DropdownMenuItem
onSelect={(event) => {
event.preventDefault();
handleEditGroup(account);
}}
>
{!isPrivateAccount(account.username) && (<DropdownMenuItem onSelect={(event) => {
event.preventDefault();
handleEditGroup(account);
}}>
<Pencil className="h-4 w-4 mr-2"/>
Edit Group
</DropdownMenuItem>)}
@@ -1179,12 +1173,10 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
{!isPrivateAccount(account.username) && (<DropdownMenuItem
onSelect={(event) => {
event.preventDefault();
handleEditGroup(account);
}}
>
{!isPrivateAccount(account.username) && (<DropdownMenuItem onSelect={(event) => {
event.preventDefault();
handleEditGroup(account);
}}>
<Pencil className="h-4 w-4 mr-2"/>
Edit Group
</DropdownMenuItem>)}
@@ -1315,12 +1307,10 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
<TooltipContent>More Options</TooltipContent>
</Tooltip>
<DropdownMenuContent align="end">
{!isPrivateAccount(account.username) && (<DropdownMenuItem
onSelect={(event) => {
event.preventDefault();
handleEditGroup(account);
}}
>
{!isPrivateAccount(account.username) && (<DropdownMenuItem onSelect={(event) => {
event.preventDefault();
handleEditGroup(account);
}}>
<Pencil className="h-4 w-4 mr-2"/>
Edit Group
</DropdownMenuItem>)}
+16 -1
View File
@@ -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"/>
+85 -20
View File
@@ -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>
+1 -1
View File
@@ -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 -20
View File
@@ -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
View File
@@ -11,7 +11,7 @@
},
"info": {
"productName": "Twitter/X Media Batch Downloader",
"productVersion": "4.8"
"productVersion": "4.9"
},
"wailsjsdir": "./frontend",
"assetdir": "./frontend/dist",