openPreview(index)}>
- {item.type === "photo" || item.type === "animated_gif" || item.type === "gif" ? (
+
+ {index + 1}
+
+ {item.type !== "text" && getEntryThumbnail(item) ? (
})
) : (
{getMediaIcon(item.type)}
)}
@@ -918,6 +1016,8 @@ export function MediaList({ accountInfo, timeline, totalUrls, fetchedMediaType =
delete_incomplete_files: settings.deleteIncompleteFiles,
retry_attempts: settings.retryAttempts,
proxy: settings.proxy || "",
+ filename_template: settings.filenameTemplate || "",
+ folder_template: settings.folderTemplate || "",
});
const response = await DownloadMediaWithMetadata(request);
if (response.cancelled) {
@@ -1095,6 +1195,8 @@ export function MediaList({ accountInfo, timeline, totalUrls, fetchedMediaType =
delete_incomplete_files: settings.deleteIncompleteFiles,
retry_attempts: settings.retryAttempts,
proxy: settings.proxy || "",
+ filename_template: settings.filenameTemplate || "",
+ folder_template: settings.folderTemplate || "",
});
const response = await DownloadMediaWithMetadata(request);
if (response.cancelled) {
diff --git a/frontend/src/components/SearchBar.tsx b/frontend/src/components/SearchBar.tsx
index ab7ade9..cb7ddcb 100644
--- a/frontend/src/components/SearchBar.tsx
+++ b/frontend/src/components/SearchBar.tsx
@@ -4,30 +4,29 @@ import { Checkbox } from "@/components/ui/checkbox";
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog";
import { InputWithContext } from "@/components/ui/input-with-context";
import { Label } from "@/components/ui/label";
-import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
import { FetchHistory } from "@/components/FetchHistory";
import type { HistoryItem } from "@/components/FetchHistory";
import { toastWithSound as toast } from "@/lib/toast-with-sound";
import { cn } from "@/lib/utils";
-import { getSettings, updateSettings, type FetchMode as SettingsFetchMode, type MediaType as SettingsMediaType } 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 { AlertCircle, Bookmark, Calendar, CheckCircle, CloudDownload, Clock, Eye, EyeOff, Globe, Heart, Hourglass, Info, Lock, RotateCcw, SlidersHorizontal, StopCircle, Trash2, User, Users, XCircle } from "lucide-react";
+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 { Spinner } from "@/components/ui/spinner";
-
function formatNumberWithComma(num: number): string {
return num.toLocaleString();
}
-
+function pillClass(active: boolean): string {
+ return cn("rounded-md px-3 py-1.5 text-sm font-medium transition-colors cursor-pointer", active
+ ? "bg-primary text-primary-foreground"
+ : "bg-muted text-muted-foreground hover:text-foreground");
+}
export type FetchMode = "public" | "private";
export type PrivateType = "bookmarks" | "likes";
export type FetchType = "single" | "multiple";
-
const LEGACY_PUBLIC_AUTH_TOKEN_KEY = "twitter_public_auth_token";
const LEGACY_PRIVATE_AUTH_TOKEN_KEY = "twitter_private_auth_token";
-
let sessionAuthToken = "";
-
export interface MultipleAccount {
id: string;
username: string;
@@ -45,7 +44,6 @@ export interface MultipleAccount {
showDiff?: boolean;
cursor?: string;
}
-
interface SearchBarProps {
username: string;
loading: boolean;
@@ -74,19 +72,22 @@ interface SearchBarProps {
onRetryAccount?: (accountId: string, authToken: string) => void;
onClearMultipleAccounts?: () => void;
onRemoveMultipleAccount?: (accountId: string) => void;
+ onOpenSavedAccounts?: () => void;
isFetchingAll?: boolean;
mode?: FetchMode;
privateType?: PrivateType;
onModeChange?: (mode: FetchMode, privateType?: PrivateType) => void;
}
-
-export function SearchBar({ username, loading, onUsernameChange, onFetch, onStopFetch, onResume, onClearResume, resumeInfo, history, onHistorySelect, onHistoryRemove, hasResult, elapsedTime = 0, remainingTime = null, fetchType = "single", onFetchTypeChange, multipleAccounts = [], onImportAccounts, onFetchAll, onStopAll, onStopAccount, onRetryAccount, onClearMultipleAccounts, onRemoveMultipleAccount, isFetchingAll = false, mode: externalMode, privateType: externalPrivateType, onModeChange, }: SearchBarProps) {
- const [useDateRange, setUseDateRange] = useState(false);
- const [startDate, setStartDate] = useState("");
- const [endDate, setEndDate] = useState("");
- const [mediaType, setMediaType] = useState
(getSettings().mediaType);
+export function SearchBar({ username, loading, onUsernameChange, onFetch, onStopFetch, onResume, onClearResume, resumeInfo, history, onHistorySelect, onHistoryRemove, hasResult, elapsedTime = 0, remainingTime = null, fetchType = "single", onFetchTypeChange, multipleAccounts = [], onImportAccounts, onFetchAll, onStopAll, onStopAccount, onRetryAccount, onClearMultipleAccounts, onRemoveMultipleAccount, onOpenSavedAccounts, isFetchingAll = false, mode: externalMode, privateType: externalPrivateType, onModeChange, }: SearchBarProps) {
+ const [includePhotos, setIncludePhotos] = useState(getSettings().includePhotos);
+ const [includeVideos, setIncludeVideos] = useState(getSettings().includeVideos);
+ const [includeGifs, setIncludeGifs] = useState(getSettings().includeGifs);
+ const [includeText, setIncludeText] = useState(getSettings().includeText);
const [retweets, setRetweets] = useState(getSettings().includeRetweets);
- const [currentFetchMode, setCurrentFetchMode] = useState(getSettings().fetchMode);
+ const [videoQuality, setVideoQuality] = useState(getSettings().videoQuality);
+ const [imageSize, setImageSize] = useState(getSettings().imageSize);
+ const [avatarSize, setAvatarSize] = useState(getSettings().avatarSize);
+ const [bannerSize, setBannerSize] = useState(getSettings().bannerSize);
const [sharedAuthToken, setSharedAuthToken] = useState(() => sessionAuthToken || localStorage.getItem(LEGACY_PUBLIC_AUTH_TOKEN_KEY) || localStorage.getItem(LEGACY_PRIVATE_AUTH_TOKEN_KEY) || "");
const [showAuthToken, setShowAuthToken] = useState(false);
const [showAuthRequiredDialog, setShowAuthRequiredDialog] = useState(false);
@@ -94,29 +95,31 @@ export function SearchBar({ username, loading, onUsernameChange, onFetch, onStop
useEffect(() => {
if (showSettingsDialog) {
const fresh = getSettings();
- setMediaType(fresh.mediaType);
+ setIncludePhotos(fresh.includePhotos);
+ setIncludeVideos(fresh.includeVideos);
+ setIncludeGifs(fresh.includeGifs);
+ setIncludeText(fresh.includeText);
setRetweets(fresh.includeRetweets);
- setCurrentFetchMode(fresh.fetchMode);
+ setVideoQuality(fresh.videoQuality);
+ setImageSize(fresh.imageSize);
+ setAvatarSize(fresh.avatarSize);
+ setBannerSize(fresh.bannerSize);
}
}, [showSettingsDialog]);
const [showImportDialog, setShowImportDialog] = useState(false);
const [importAccountsText, setImportAccountsText] = useState("");
const [authPromptToken, setAuthPromptToken] = useState("");
-
const mode = externalMode || "public";
const privateType = externalPrivateType || "bookmarks";
const isLikesMode = mode === "private" && privateType === "likes";
const isBookmarksMode = mode === "private" && privateType === "bookmarks";
const isAnyMultipleAccountFetching = multipleAccounts.some((account) => account.status === "fetching");
-
useEffect(() => {
let active = true;
-
const syncStoredTokens = async () => {
const legacyPublicToken = localStorage.getItem(LEGACY_PUBLIC_AUTH_TOKEN_KEY) || "";
const legacyPrivateToken = localStorage.getItem(LEGACY_PRIVATE_AUTH_TOKEN_KEY) || "";
const legacyUnifiedToken = legacyPublicToken || legacyPrivateToken;
-
try {
if (legacyUnifiedToken) {
await Promise.all([
@@ -132,7 +135,6 @@ export function SearchBar({ username, loading, onUsernameChange, onFetch, onStop
localStorage.removeItem(LEGACY_PUBLIC_AUTH_TOKEN_KEY);
localStorage.removeItem(LEGACY_PRIVATE_AUTH_TOKEN_KEY);
}
-
try {
const [storedPublicToken, storedPrivateToken] = await Promise.all([
GetStoredAuthToken("public"),
@@ -141,11 +143,9 @@ export function SearchBar({ username, loading, onUsernameChange, onFetch, onStop
if (!active) {
return;
}
-
const unifiedToken = storedPublicToken || storedPrivateToken || "";
sessionAuthToken = unifiedToken;
setSharedAuthToken(unifiedToken);
-
if (unifiedToken && (storedPublicToken !== unifiedToken || storedPrivateToken !== unifiedToken)) {
await Promise.all([
SetStoredAuthToken("public", unifiedToken),
@@ -157,14 +157,11 @@ export function SearchBar({ username, loading, onUsernameChange, onFetch, onStop
console.error("Failed to load auth token from secure storage:", error);
}
};
-
void syncStoredTokens();
-
return () => {
active = false;
};
}, []);
-
const tokenWriteTimerRef = useRef | null>(null);
const pendingAuthActionRef = useRef<((authToken: string) => void) | null>(null);
useEffect(() => {
@@ -174,7 +171,6 @@ export function SearchBar({ username, loading, onUsernameChange, onFetch, onStop
}
};
}, []);
-
const handleSharedTokenChange = (value: string) => {
sessionAuthToken = value;
setSharedAuthToken(value);
@@ -190,14 +186,12 @@ export function SearchBar({ username, loading, onUsernameChange, onFetch, onStop
});
}, 400);
};
-
const closeAuthRequiredDialog = (open: boolean) => {
setShowAuthRequiredDialog(open);
if (!open) {
pendingAuthActionRef.current = null;
}
};
-
const requireAuthToken = (onAuthorized: (authToken: string) => void) => {
const token = sharedAuthToken.trim();
if (token) {
@@ -208,33 +202,28 @@ export function SearchBar({ username, loading, onUsernameChange, onFetch, onStop
setAuthPromptToken(sharedAuthToken);
setShowAuthRequiredDialog(true);
};
-
const handleFetch = () => {
requireAuthToken((authToken) => {
- onFetch(useDateRange, startDate, endDate, mediaType, retweets, mode, privateType, authToken, false);
+ onFetch(false, undefined, undefined, undefined, retweets, mode, privateType, authToken, false);
});
};
-
const handleResume = () => {
if (onResume) {
requireAuthToken((authToken) => {
- onResume(authToken, mediaType, retweets);
+ onResume(authToken, undefined, retweets);
});
}
};
-
const handleFetchAll = () => {
requireAuthToken((authToken) => {
onFetchAll?.(authToken);
});
};
-
const handleRetry = (accountId: string) => {
requireAuthToken((authToken) => {
onRetryAccount?.(accountId, authToken);
});
};
-
const handleAuthPromptSubmit = () => {
const token = authPromptToken.trim();
if (!token) {
@@ -247,39 +236,32 @@ export function SearchBar({ username, loading, onUsernameChange, onFetch, onStop
setShowAuthRequiredDialog(false);
pendingAction?.(token);
};
-
const handleOpenFetchSettings = () => {
pendingAuthActionRef.current = null;
setShowAuthRequiredDialog(false);
setShowSettingsDialog(true);
};
-
const openImportDialog = () => {
setImportAccountsText(multipleAccounts.map((account) => account.username).join("\n"));
setShowImportDialog(true);
};
-
const handleImportSubmit = () => {
const accounts = importAccountsText
.split(/[\n,;]+/)
.map((entry) => entry.trim())
.filter((entry) => entry.length > 0);
-
if (accounts.length === 0) {
toast.error("Please enter at least one account");
return;
}
-
onImportAccounts?.(accounts);
setShowImportDialog(false);
};
-
const formatTime = (seconds: number): string => {
const mins = Math.floor(seconds / 60);
const secs = seconds % 60;
return `${mins}:${String(secs).padStart(2, "0")}`;
};
-
const activeCountdown = remainingTime !== null && remainingTime >= 0
? formatTime(remainingTime)
: elapsedTime > 0
@@ -289,7 +271,6 @@ export function SearchBar({ username, loading, onUsernameChange, onFetch, onStop
const authTokenHelpText = mode === "private"
? "Use auth token from the account whose bookmarks or likes you want to fetch."
: "Recommended to use a dummy account, not your main account. Excessive usage may cause suspension.";
-
return (
@@ -508,11 +489,17 @@ export function SearchBar({ username, loading, onUsernameChange, onFetch, onStop
-
-
Total:
-
- {formatNumberWithComma(multipleAccounts.filter((acc) => acc.status === "completed" || acc.status === "incomplete" || acc.status === "failed").length)}/{formatNumberWithComma(multipleAccounts.length)}
-
+
+
+ Total:
+
+ {formatNumberWithComma(multipleAccounts.filter((acc) => acc.status === "completed" || acc.status === "incomplete" || acc.status === "failed").length)}/{formatNumberWithComma(multipleAccounts.length)}
+
+
+ {!isFetchingAll && onOpenSavedAccounts && multipleAccounts.some((acc) => acc.status === "completed" || acc.status === "incomplete") && (
)}
)}
@@ -557,8 +544,8 @@ export function SearchBar({ username, loading, onUsernameChange, onFetch, onStop
{account.remainingTime !== null && account.remainingTime >= 0
- ? formatTime(account.remainingTime)
- : formatTime(account.elapsedTime)}
+ ? formatTime(account.remainingTime)
+ : formatTime(account.elapsedTime)}