mirror of
https://github.com/Alvin-Zilverstand/Twitter-X-Media-Batch-Downloader.git
synced 2026-12-01 18:41:24 +01:00
v4.9
This commit is contained in:
1 parent
3fb8bda2ff
commit
2ada5da9bf
12 files changed
+164
-116
No files matched your search
+20
-22
@@ -340,34 +340,32 @@ func DownloadMediaWithMetadataProgressAndStatus(items []MediaItem, outputDir str
|
|||||||
}
|
}
|
||||||
|
|
||||||
filenameIndexes := make(map[string]int, len(filenameCounts))
|
filenameIndexes := make(map[string]int, len(filenameCounts))
|
||||||
tasks := make([]downloadTask, 0, len(pendingTasks))
|
tasks := make([]downloadTask, 0, len(pendingTasks))
|
||||||
|
|
||||||
for _, pending := range pendingTasks {
|
for _, pending := range pendingTasks {
|
||||||
key := filenameCollisionKey(pending.typeDir, pending.baseName, pending.ext)
|
key := filenameCollisionKey(pending.typeDir, pending.baseName, pending.ext)
|
||||||
|
|
||||||
filenameIndexes[key]++
|
filenameIndexes[key]++
|
||||||
|
|
||||||
filename := formatDownloadFilename(
|
filename := formatDownloadFilename(
|
||||||
pending.baseName,
|
pending.baseName,
|
||||||
pending.ext,
|
pending.ext,
|
||||||
filenameCounts[key],
|
filenameCounts[key],
|
||||||
filenameIndexes[key],
|
filenameIndexes[key],
|
||||||
)
|
)
|
||||||
|
|
||||||
// If skipping existing files, first check the canonical filename.
|
if options.SkipExistingFiles {
|
||||||
// This prevents existing files from being downloaded again as _01, _02, etc.
|
canonicalPath := filepath.Join(pending.typeDir, formatDownloadFilename(pending.baseName, pending.ext, 1, 1))
|
||||||
if options.SkipExistingFiles {
|
if exists, err := fileExists(canonicalPath); err == nil && exists {
|
||||||
canonicalPath := filepath.Join(pending.typeDir, formatDownloadFilename(pending.baseName, pending.ext, 1, 1))
|
pending.task.outputPath = canonicalPath
|
||||||
if exists, err := fileExists(canonicalPath); err == nil && exists {
|
tasks = append(tasks, pending.task)
|
||||||
pending.task.outputPath = canonicalPath
|
continue
|
||||||
tasks = append(tasks, pending.task)
|
}
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
pending.task.outputPath = filepath.Join(pending.typeDir, filename)
|
pending.task.outputPath = filepath.Join(pending.typeDir, filename)
|
||||||
tasks = append(tasks, pending.task)
|
tasks = append(tasks, pending.task)
|
||||||
}
|
}
|
||||||
|
|
||||||
var downloadedCount int64
|
var downloadedCount int64
|
||||||
var skippedCount int64
|
var skippedCount int64
|
||||||
|
|||||||
+1
-1
@@ -11,7 +11,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func OpenFolderInExplorer(path string) error {
|
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)
|
info, err := os.Stat(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
+2
-3
@@ -698,11 +698,10 @@ func ExtractTimeline(req TimelineRequest) (*TwitterResponse, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
includeText := req.IncludeText
|
includeText := req.IncludeText
|
||||||
wantsRetweets := req.Retweets
|
|
||||||
|
|
||||||
timelineType := req.TimelineType
|
timelineType := req.TimelineType
|
||||||
if timelineType == "" {
|
if timelineType == "" {
|
||||||
if includeText || wantsRetweets {
|
if includeText {
|
||||||
timelineType = "tweets"
|
timelineType = "tweets"
|
||||||
} else {
|
} else {
|
||||||
timelineType = "media"
|
timelineType = "media"
|
||||||
@@ -725,7 +724,7 @@ func ExtractTimeline(req TimelineRequest) (*TwitterResponse, error) {
|
|||||||
args = append(args, "--limit", fmt.Sprintf("%d", req.BatchSize))
|
args = append(args, "--limit", fmt.Sprintf("%d", req.BatchSize))
|
||||||
}
|
}
|
||||||
|
|
||||||
if timelineType == "tweets" || timelineType == "timeline" {
|
if timelineType == "tweets" || timelineType == "timeline" || timelineType == "media" {
|
||||||
if req.Retweets {
|
if req.Retweets {
|
||||||
args = append(args, "--retweets", "include")
|
args = append(args, "--retweets", "include")
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -441,7 +441,7 @@ function App() {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const batchSize = BATCH_SIZE;
|
const batchSize = BATCH_SIZE;
|
||||||
let timelineType = (settings.includeText || retweets) ? "tweets" : "media";
|
let timelineType = settings.includeText ? "tweets" : "media";
|
||||||
if (isBookmarks) {
|
if (isBookmarks) {
|
||||||
timelineType = "bookmarks";
|
timelineType = "bookmarks";
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 45 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 44 KiB |
@@ -317,34 +317,30 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
const handleOpenFolder = async (account: AccountListItem) => {
|
const handleOpenFolder = async (account: AccountListItem) => {
|
||||||
const settings = getSettings();
|
const settings = getSettings();
|
||||||
const basePath = settings.downloadPath || "";
|
const basePath = settings.downloadPath || "";
|
||||||
|
if (!basePath) {
|
||||||
if (!basePath) {
|
toast.error("Download folder is not set");
|
||||||
toast.error("Download folder is not set");
|
return;
|
||||||
return;
|
}
|
||||||
}
|
let username = account.username || account.name || "";
|
||||||
|
try {
|
||||||
let username = account.username || account.name || "";
|
const responseJSON = await GetAccountFromDB(account.id);
|
||||||
|
const data = JSON.parse(responseJSON);
|
||||||
try {
|
username = data.account_info?.name || username;
|
||||||
const responseJSON = await GetAccountFromDB(account.id);
|
}
|
||||||
const data = JSON.parse(responseJSON);
|
catch {
|
||||||
username = data.account_info?.name || username;
|
}
|
||||||
} catch {
|
const folderName = getFolderNameForAccount(username);
|
||||||
// fall back to saved row data
|
try {
|
||||||
}
|
const folderPath = await GetFolderPath(basePath, folderName);
|
||||||
|
await OpenFolder(folderPath);
|
||||||
const folderName = getFolderNameForAccount(username);
|
}
|
||||||
|
catch (error) {
|
||||||
try {
|
console.error(`Failed to open folder for @${username}:`, error);
|
||||||
const folderPath = await GetFolderPath(basePath, folderName);
|
toast.error("Failed to open folder");
|
||||||
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) => {
|
const handleDownload = async (id: number, username: string) => {
|
||||||
try {
|
try {
|
||||||
const responseJSON = await GetAccountFromDB(id);
|
const responseJSON = await GetAccountFromDB(id);
|
||||||
@@ -1080,12 +1076,10 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
|
|||||||
</Button>
|
</Button>
|
||||||
</DropdownMenuTrigger>
|
</DropdownMenuTrigger>
|
||||||
<DropdownMenuContent align="end">
|
<DropdownMenuContent align="end">
|
||||||
{!isPrivateAccount(account.username) && (<DropdownMenuItem
|
{!isPrivateAccount(account.username) && (<DropdownMenuItem onSelect={(event) => {
|
||||||
onSelect={(event) => {
|
event.preventDefault();
|
||||||
event.preventDefault();
|
handleEditGroup(account);
|
||||||
handleEditGroup(account);
|
}}>
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Pencil className="h-4 w-4 mr-2"/>
|
<Pencil className="h-4 w-4 mr-2"/>
|
||||||
Edit Group
|
Edit Group
|
||||||
</DropdownMenuItem>)}
|
</DropdownMenuItem>)}
|
||||||
@@ -1179,12 +1173,10 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
|
|||||||
</Button>
|
</Button>
|
||||||
</DropdownMenuTrigger>
|
</DropdownMenuTrigger>
|
||||||
<DropdownMenuContent align="end">
|
<DropdownMenuContent align="end">
|
||||||
{!isPrivateAccount(account.username) && (<DropdownMenuItem
|
{!isPrivateAccount(account.username) && (<DropdownMenuItem onSelect={(event) => {
|
||||||
onSelect={(event) => {
|
event.preventDefault();
|
||||||
event.preventDefault();
|
handleEditGroup(account);
|
||||||
handleEditGroup(account);
|
}}>
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Pencil className="h-4 w-4 mr-2"/>
|
<Pencil className="h-4 w-4 mr-2"/>
|
||||||
Edit Group
|
Edit Group
|
||||||
</DropdownMenuItem>)}
|
</DropdownMenuItem>)}
|
||||||
@@ -1315,12 +1307,10 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
|
|||||||
<TooltipContent>More Options</TooltipContent>
|
<TooltipContent>More Options</TooltipContent>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<DropdownMenuContent align="end">
|
<DropdownMenuContent align="end">
|
||||||
{!isPrivateAccount(account.username) && (<DropdownMenuItem
|
{!isPrivateAccount(account.username) && (<DropdownMenuItem onSelect={(event) => {
|
||||||
onSelect={(event) => {
|
event.preventDefault();
|
||||||
event.preventDefault();
|
handleEditGroup(account);
|
||||||
handleEditGroup(account);
|
}}>
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Pencil className="h-4 w-4 mr-2"/>
|
<Pencil className="h-4 w-4 mr-2"/>
|
||||||
Edit Group
|
Edit Group
|
||||||
</DropdownMenuItem>)}
|
</DropdownMenuItem>)}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import { toastWithSound as toast } from "@/lib/toast-with-sound";
|
|||||||
import { cn } from "@/lib/utils";
|
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 { 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 { 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";
|
import { Spinner } from "@/components/ui/spinner";
|
||||||
function formatNumberWithComma(num: number): string {
|
function formatNumberWithComma(num: number): string {
|
||||||
return num.toLocaleString();
|
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);
|
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 = () => {
|
const handleResume = () => {
|
||||||
if (onResume) {
|
if (onResume) {
|
||||||
requireAuthToken((authToken) => {
|
requireAuthToken((authToken) => {
|
||||||
@@ -371,6 +382,10 @@ export function SearchBar({ username, loading, onUsernameChange, onFetch, onStop
|
|||||||
</button>)}
|
</button>)}
|
||||||
</div>
|
</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">
|
<div className="flex items-center gap-2">
|
||||||
{loading && (<Button variant="destructive" onClick={onStopFetch}>
|
{loading && (<Button variant="destructive" onClick={onStopFetch}>
|
||||||
<StopCircle className="h-4 w-4"/>
|
<StopCircle className="h-4 w-4"/>
|
||||||
|
|||||||
@@ -1,16 +1,57 @@
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||||
import { CircleCheck, Copy } from "lucide-react";
|
import { CircleCheck, Copy } from "lucide-react";
|
||||||
import { openExternal } from "@/lib/utils";
|
import { openExternal } from "@/lib/utils";
|
||||||
import KofiLogo from "@/assets/ko-fi.gif";
|
import KofiLogo from "@/assets/ko-fi.gif";
|
||||||
import KofiSvg from "@/assets/kofi_symbol.svg";
|
import KofiSvg from "@/assets/kofi_symbol.svg";
|
||||||
import UsdtBarcode from "@/assets/usdt.jpg";
|
import UsdtTronQr from "@/assets/usdt.jpg";
|
||||||
const USDT_ADDRESS = "THnzAAwZgp2Sq5CAXLP2njQDhTvgZG9EWs";
|
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() {
|
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">
|
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 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="flex flex-col items-center space-y-4">
|
||||||
<div className="relative flex h-32 w-full items-center justify-center">
|
<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"/>
|
<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.
|
Enjoying the project? You can support ongoing development by buying me a coffee.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</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")}>
|
<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-5 w-5 shrink-0" alt="" aria-hidden="true"/>
|
<img src={KofiSvg} className="h-6 w-6 shrink-0" alt="" aria-hidden="true"/>
|
||||||
Support me on Ko-fi
|
Support me on Ko-fi
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex flex-1 flex-col items-center justify-between space-y-6 p-6">
|
<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-4">
|
<div className="flex w-full flex-col items-center space-y-3">
|
||||||
<div className="flex h-32 items-center justify-center">
|
<div className="flex h-32 items-center justify-center">
|
||||||
<div className="rounded-xl border bg-white p-2 shadow-sm">
|
<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>
|
||||||
</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">
|
<p className="px-4 text-center text-sm text-muted-foreground">
|
||||||
Crypto donations are also accepted. Scan the QR code or copy the address.
|
Crypto donations are also accepted. Scan the QR code or copy the address.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</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">
|
<div className="w-full space-y-2">
|
||||||
<code className="truncate text-xs font-mono text-muted-foreground" title={USDT_ADDRESS}>
|
<div className="grid grid-cols-2 gap-2">
|
||||||
{USDT_ADDRESS}
|
<Select value={selectedCoin} onValueChange={(value: CryptoCoin) => handleCoinChange(value)}>
|
||||||
</code>
|
<SelectTrigger size="sm" className="w-full" aria-label="Coin">
|
||||||
<Button variant="ghost" size="icon" className="h-7 w-7 shrink-0 hover:bg-background" onClick={() => {
|
<SelectValue />
|
||||||
navigator.clipboard.writeText(USDT_ADDRESS);
|
</SelectTrigger>
|
||||||
setCopiedUsdt(true);
|
<SelectContent>
|
||||||
setTimeout(() => setCopiedUsdt(false), 500);
|
<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"/>}
|
<SelectTrigger size="sm" className="w-full" aria-label="Network">
|
||||||
</Button>
|
<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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { openExternal } from "@/lib/utils";
|
|||||||
const INFO_LINKS = [
|
const INFO_LINKS = [
|
||||||
{ label: "Chrome Extension", icon: Puzzle, url: "https://chromewebstore.google.com/detail/cboceolmgkoobpfjiojkigmihijfgmdo" },
|
{ label: "Chrome Extension", icon: Puzzle, url: "https://chromewebstore.google.com/detail/cboceolmgkoobpfjiojkigmihijfgmdo" },
|
||||||
{ label: "Userscript", icon: FileCode2, url: "https://greasyfork.org/en/scripts/523157" },
|
{ 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() {
|
export function TitleBar() {
|
||||||
const handleMinimize = () => {
|
const handleMinimize = () => {
|
||||||
|
|||||||
@@ -1,21 +1,17 @@
|
|||||||
import { useSyncExternalStore } from "react";
|
import { useSyncExternalStore } from "react";
|
||||||
import { EventsOn } from "../../wailsjs/runtime/runtime";
|
import { EventsOn } from "../../wailsjs/runtime/runtime";
|
||||||
|
|
||||||
export interface DownloadProgress {
|
export interface DownloadProgress {
|
||||||
current: number;
|
current: number;
|
||||||
total: number;
|
total: number;
|
||||||
percent: number;
|
percent: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DownloadItemStatus {
|
export interface DownloadItemStatus {
|
||||||
tweet_id: number;
|
tweet_id: number;
|
||||||
index: number;
|
index: number;
|
||||||
status: "success" | "failed" | "skipped" | "cancelled";
|
status: "success" | "failed" | "skipped" | "cancelled";
|
||||||
}
|
}
|
||||||
|
|
||||||
export type DownloadScope = "media" | "database" | "database-bulk";
|
export type DownloadScope = "media" | "database" | "database-bulk";
|
||||||
export type DownloadItemResult = "success" | "failed" | "skipped";
|
export type DownloadItemResult = "success" | "failed" | "skipped";
|
||||||
|
|
||||||
export interface DownloadState {
|
export interface DownloadState {
|
||||||
active: boolean;
|
active: boolean;
|
||||||
scope: DownloadScope | null;
|
scope: DownloadScope | null;
|
||||||
@@ -25,9 +21,7 @@ export interface DownloadState {
|
|||||||
itemKeyByIndex: Record<number, string>;
|
itemKeyByIndex: Record<number, string>;
|
||||||
itemStatusByKey: Record<string, DownloadItemResult>;
|
itemStatusByKey: Record<string, DownloadItemResult>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const listeners = new Set<() => void>();
|
const listeners = new Set<() => void>();
|
||||||
|
|
||||||
let state: DownloadState = {
|
let state: DownloadState = {
|
||||||
active: false,
|
active: false,
|
||||||
scope: null,
|
scope: null,
|
||||||
@@ -37,20 +31,16 @@ let state: DownloadState = {
|
|||||||
itemKeyByIndex: {},
|
itemKeyByIndex: {},
|
||||||
itemStatusByKey: {},
|
itemStatusByKey: {},
|
||||||
};
|
};
|
||||||
|
|
||||||
let unsubscribeEvents: (() => void) | null = null;
|
let unsubscribeEvents: (() => void) | null = null;
|
||||||
|
|
||||||
function emit() {
|
function emit() {
|
||||||
for (const listener of listeners) {
|
for (const listener of listeners) {
|
||||||
listener();
|
listener();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setState(next: Partial<DownloadState>) {
|
function setState(next: Partial<DownloadState>) {
|
||||||
state = { ...state, ...next };
|
state = { ...state, ...next };
|
||||||
emit();
|
emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function initDownloadProgressEvents() {
|
export function initDownloadProgressEvents() {
|
||||||
if (unsubscribeEvents) {
|
if (unsubscribeEvents) {
|
||||||
return unsubscribeEvents;
|
return unsubscribeEvents;
|
||||||
@@ -80,11 +70,7 @@ export function initDownloadProgressEvents() {
|
|||||||
};
|
};
|
||||||
return unsubscribeEvents;
|
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({
|
setState({
|
||||||
active: true,
|
active: true,
|
||||||
scope: meta.scope,
|
scope: meta.scope,
|
||||||
@@ -94,7 +80,6 @@ export function beginDownload(
|
|||||||
itemKeyByIndex: meta.itemKeyByIndex ?? {},
|
itemKeyByIndex: meta.itemKeyByIndex ?? {},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function finishDownload() {
|
export function finishDownload() {
|
||||||
setState({
|
setState({
|
||||||
active: false,
|
active: false,
|
||||||
@@ -105,7 +90,6 @@ export function finishDownload() {
|
|||||||
itemKeyByIndex: {},
|
itemKeyByIndex: {},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setDownloadItemStatus(itemKey: string, status: DownloadItemResult) {
|
export function setDownloadItemStatus(itemKey: string, status: DownloadItemResult) {
|
||||||
setState({
|
setState({
|
||||||
itemStatusByKey: {
|
itemStatusByKey: {
|
||||||
@@ -114,18 +98,15 @@ export function setDownloadItemStatus(itemKey: string, status: DownloadItemResul
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function subscribeDownloadState(listener: () => void) {
|
export function subscribeDownloadState(listener: () => void) {
|
||||||
listeners.add(listener);
|
listeners.add(listener);
|
||||||
return () => {
|
return () => {
|
||||||
listeners.delete(listener);
|
listeners.delete(listener);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getDownloadState() {
|
export function getDownloadState() {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useDownloadState() {
|
export function useDownloadState() {
|
||||||
return useSyncExternalStore(subscribeDownloadState, getDownloadState, getDownloadState);
|
return useSyncExternalStore(subscribeDownloadState, getDownloadState, getDownloadState);
|
||||||
}
|
}
|
||||||
+1
-1
@@ -11,7 +11,7 @@
|
|||||||
},
|
},
|
||||||
"info": {
|
"info": {
|
||||||
"productName": "Twitter/X Media Batch Downloader",
|
"productName": "Twitter/X Media Batch Downloader",
|
||||||
"productVersion": "4.8"
|
"productVersion": "4.9"
|
||||||
},
|
},
|
||||||
"wailsjsdir": "./frontend",
|
"wailsjsdir": "./frontend",
|
||||||
"assetdir": "./frontend/dist",
|
"assetdir": "./frontend/dist",
|
||||||
|
|||||||
Reference in new issue
Block a user