diff --git a/backend/download.go b/backend/download.go index f9bd6a4..4aeded8 100644 --- a/backend/download.go +++ b/backend/download.go @@ -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 diff --git a/backend/folder.go b/backend/folder.go index 5acbd1f..b5c92ee 100644 --- a/backend/folder.go +++ b/backend/folder.go @@ -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 diff --git a/backend/twitter.go b/backend/twitter.go index a598665..ee0cc86 100644 --- a/backend/twitter.go +++ b/backend/twitter.go @@ -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 { diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 760b261..9f5f5cd 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -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"; } diff --git a/frontend/src/assets/usdc.jpg b/frontend/src/assets/usdc.jpg new file mode 100644 index 0000000..66d44bb Binary files /dev/null and b/frontend/src/assets/usdc.jpg differ diff --git a/frontend/src/assets/usdt_evm.jpg b/frontend/src/assets/usdt_evm.jpg new file mode 100644 index 0000000..3685c31 Binary files /dev/null and b/frontend/src/assets/usdt_evm.jpg differ diff --git a/frontend/src/components/DatabaseView.tsx b/frontend/src/components/DatabaseView.tsx index 1cb8cd6..a101d50 100644 --- a/frontend/src/components/DatabaseView.tsx +++ b/frontend/src/components/DatabaseView.tsx @@ -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 - {!isPrivateAccount(account.username) && ( { - event.preventDefault(); - handleEditGroup(account); - }} - > + {!isPrivateAccount(account.username) && ( { + event.preventDefault(); + handleEditGroup(account); + }}> Edit Group )} @@ -1179,12 +1173,10 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr - {!isPrivateAccount(account.username) && ( { - event.preventDefault(); - handleEditGroup(account); - }} - > + {!isPrivateAccount(account.username) && ( { + event.preventDefault(); + handleEditGroup(account); + }}> Edit Group )} @@ -1315,12 +1307,10 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr More Options - {!isPrivateAccount(account.username) && ( { - event.preventDefault(); - handleEditGroup(account); - }} - > + {!isPrivateAccount(account.username) && ( { + event.preventDefault(); + handleEditGroup(account); + }}> Edit Group )} diff --git a/frontend/src/components/SearchBar.tsx b/frontend/src/components/SearchBar.tsx index cb7ddcb..1cc633a 100644 --- a/frontend/src/components/SearchBar.tsx +++ b/frontend/src/components/SearchBar.tsx @@ -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 )} + +
{loading && (
-
-
+
+
- USDT Barcode + {`${selectedCoin.toUpperCase()}
-

USDT (TRC20)

+

Support via Crypto

Crypto donations are also accepted. Scan the QR code or copy the address.

-
- - {USDT_ADDRESS} - - +
diff --git a/frontend/src/components/TitleBar.tsx b/frontend/src/components/TitleBar.tsx index e84e103..0b96510 100644 --- a/frontend/src/components/TitleBar.tsx +++ b/frontend/src/components/TitleBar.tsx @@ -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 = () => { diff --git a/frontend/src/lib/download-state.ts b/frontend/src/lib/download-state.ts index 567b886..34052d9 100644 --- a/frontend/src/lib/download-state.ts +++ b/frontend/src/lib/download-state.ts @@ -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; itemStatusByKey: Record; } - 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) { 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 & Partial> -) { +export function beginDownload(progress: DownloadProgress, meta: Pick & Partial>) { 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); } diff --git a/wails.json b/wails.json index 2b2494b..87e63e2 100644 --- a/wails.json +++ b/wails.json @@ -11,7 +11,7 @@ }, "info": { "productName": "Twitter/X Media Batch Downloader", - "productVersion": "4.8" + "productVersion": "4.9" }, "wailsjsdir": "./frontend", "assetdir": "./frontend/dist",