mirror of
https://github.com/Alvin-Zilverstand/Twitter-X-Media-Batch-Downloader.git
synced 2026-11-30 10:07:54 +01:00
v4.7
This commit is contained in:
1 parent
e05a9379fc
commit
c42808431c
31 files changed
+3187
-2798
No files matched your search
@@ -66,11 +66,9 @@ interface DatabaseViewProps {
|
||||
}
|
||||
const INITIAL_LOAD_COUNT = 12;
|
||||
const LOAD_MORE_COUNT = 12;
|
||||
|
||||
function getContentScrollElement(): HTMLElement | null {
|
||||
return document.getElementById("app-content-scroll");
|
||||
}
|
||||
|
||||
export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewProps) {
|
||||
const [accounts, setAccounts] = useState<AccountListItem[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
@@ -84,7 +82,13 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
|
||||
const [searchQuery, setSearchQuery] = useState<string>("");
|
||||
const deferredSearchQuery = useDeferredValue(searchQuery);
|
||||
const [sortOrder, setSortOrder] = useState<"newest" | "oldest" | "username-asc" | "username-desc" | "followers-high" | "followers-low" | "posts-high" | "posts-low" | "media-high" | "media-low">("newest");
|
||||
const [gridView, setGridView] = useState<"large" | "small" | "list">("list");
|
||||
const [gridView, setGridView] = useState<"large" | "small" | "list">(() => {
|
||||
const stored = localStorage.getItem("savedAccountsViewMode");
|
||||
return stored === "large" || stored === "small" || stored === "list" ? stored : "list";
|
||||
});
|
||||
useEffect(() => {
|
||||
localStorage.setItem("savedAccountsViewMode", gridView);
|
||||
}, [gridView]);
|
||||
const [editingAccount, setEditingAccount] = useState<AccountListItem | null>(null);
|
||||
const [editGroupName, setEditGroupName] = useState("");
|
||||
const [editGroupColor, setEditGroupColor] = useState("");
|
||||
@@ -230,11 +234,9 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
|
||||
setFolderExistence(new Map());
|
||||
return;
|
||||
}
|
||||
|
||||
if (visibleAccounts.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
let active = true;
|
||||
const loadVisibleFolderExistence = async () => {
|
||||
try {
|
||||
@@ -243,7 +245,6 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
|
||||
if (!active) {
|
||||
return;
|
||||
}
|
||||
|
||||
setFolderExistence((prev) => {
|
||||
const next = new Map(prev);
|
||||
for (const account of visibleAccounts) {
|
||||
@@ -256,7 +257,6 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
|
||||
console.error("Failed to check visible folders:", error);
|
||||
}
|
||||
};
|
||||
|
||||
void loadVisibleFolderExistence();
|
||||
return () => {
|
||||
active = false;
|
||||
@@ -382,6 +382,8 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
|
||||
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) {
|
||||
@@ -505,6 +507,8 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
|
||||
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) {
|
||||
@@ -628,105 +632,106 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
|
||||
};
|
||||
input.onchange = async (e) => {
|
||||
try {
|
||||
const files = (e.target as HTMLInputElement).files;
|
||||
if (!files || files.length === 0)
|
||||
return;
|
||||
let imported = 0;
|
||||
for (const file of Array.from(files)) {
|
||||
try {
|
||||
const text = await file.text();
|
||||
const data = JSON.parse(text);
|
||||
let detectedMediaType = "all";
|
||||
if (data.media_type) {
|
||||
detectedMediaType = data.media_type;
|
||||
}
|
||||
else if (data.media_list && Array.isArray(data.media_list)) {
|
||||
const types = new Set(data.media_list.map((item: {
|
||||
media_type?: string;
|
||||
type?: string;
|
||||
}) => item.media_type || item.type).filter(Boolean));
|
||||
if (types.size === 1) {
|
||||
const singleType = Array.from(types)[0] as string;
|
||||
if (singleType === "photo")
|
||||
detectedMediaType = "image";
|
||||
else if (singleType === "video")
|
||||
detectedMediaType = "video";
|
||||
else if (singleType === "animated_gif")
|
||||
detectedMediaType = "gif";
|
||||
else
|
||||
detectedMediaType = singleType;
|
||||
const files = (e.target as HTMLInputElement).files;
|
||||
if (!files || files.length === 0)
|
||||
return;
|
||||
let imported = 0;
|
||||
for (const file of Array.from(files)) {
|
||||
try {
|
||||
const text = await file.text();
|
||||
const data = JSON.parse(text);
|
||||
let detectedMediaType = "all";
|
||||
if (data.media_type) {
|
||||
detectedMediaType = data.media_type;
|
||||
}
|
||||
}
|
||||
else if (data.timeline && Array.isArray(data.timeline)) {
|
||||
const types = new Set(data.timeline.map((item: {
|
||||
type?: string;
|
||||
}) => item.type).filter(Boolean));
|
||||
if (types.size === 1) {
|
||||
const singleType = Array.from(types)[0] as string;
|
||||
if (singleType === "photo")
|
||||
detectedMediaType = "image";
|
||||
else if (singleType === "video")
|
||||
detectedMediaType = "video";
|
||||
else if (singleType === "animated_gif")
|
||||
detectedMediaType = "gif";
|
||||
else if (singleType === "text")
|
||||
detectedMediaType = "text";
|
||||
else
|
||||
detectedMediaType = singleType;
|
||||
}
|
||||
}
|
||||
if (data.account_info && data.timeline) {
|
||||
await SaveAccountToDB(data.account_info.name, data.account_info.nick, data.account_info.profile_image, data.total_urls || data.timeline.length, text, detectedMediaType);
|
||||
imported++;
|
||||
}
|
||||
else if (data.username && data.media_list) {
|
||||
const convertedData = {
|
||||
account_info: {
|
||||
name: data.username,
|
||||
nick: data.nick || data.username,
|
||||
date: "",
|
||||
followers_count: data.followers || 0,
|
||||
friends_count: data.following || 0,
|
||||
profile_image: data.profile_image || "",
|
||||
statuses_count: data.posts || 0,
|
||||
},
|
||||
total_urls: data.media_list.length,
|
||||
timeline: data.media_list.map((item: {
|
||||
url: string;
|
||||
date: string;
|
||||
tweet_id: string;
|
||||
type: string;
|
||||
else if (data.media_list && Array.isArray(data.media_list)) {
|
||||
const types = new Set(data.media_list.map((item: {
|
||||
media_type?: string;
|
||||
}) => ({
|
||||
url: item.url,
|
||||
date: item.date,
|
||||
tweet_id: item.tweet_id,
|
||||
type: item.media_type || item.type,
|
||||
is_retweet: false,
|
||||
})),
|
||||
metadata: {
|
||||
new_entries: data.media_list.length,
|
||||
page: 0,
|
||||
batch_size: 0,
|
||||
has_more: false,
|
||||
},
|
||||
};
|
||||
await SaveAccountToDB(convertedData.account_info.name, convertedData.account_info.nick, convertedData.account_info.profile_image, convertedData.total_urls, JSON.stringify(convertedData), detectedMediaType);
|
||||
imported++;
|
||||
type?: string;
|
||||
}) => item.media_type || item.type).filter(Boolean));
|
||||
if (types.size === 1) {
|
||||
const singleType = Array.from(types)[0] as string;
|
||||
if (singleType === "photo")
|
||||
detectedMediaType = "image";
|
||||
else if (singleType === "video")
|
||||
detectedMediaType = "video";
|
||||
else if (singleType === "animated_gif")
|
||||
detectedMediaType = "gif";
|
||||
else
|
||||
detectedMediaType = singleType;
|
||||
}
|
||||
}
|
||||
else if (data.timeline && Array.isArray(data.timeline)) {
|
||||
const types = new Set(data.timeline.map((item: {
|
||||
type?: string;
|
||||
}) => item.type).filter(Boolean));
|
||||
if (types.size === 1) {
|
||||
const singleType = Array.from(types)[0] as string;
|
||||
if (singleType === "photo")
|
||||
detectedMediaType = "image";
|
||||
else if (singleType === "video")
|
||||
detectedMediaType = "video";
|
||||
else if (singleType === "animated_gif")
|
||||
detectedMediaType = "gif";
|
||||
else if (singleType === "text")
|
||||
detectedMediaType = "text";
|
||||
else
|
||||
detectedMediaType = singleType;
|
||||
}
|
||||
}
|
||||
if (data.account_info && data.timeline) {
|
||||
await SaveAccountToDB(data.account_info.name, data.account_info.nick, data.account_info.profile_image, data.total_urls || data.timeline.length, text, detectedMediaType);
|
||||
imported++;
|
||||
}
|
||||
else if (data.username && data.media_list) {
|
||||
const convertedData = {
|
||||
account_info: {
|
||||
name: data.username,
|
||||
nick: data.nick || data.username,
|
||||
date: "",
|
||||
followers_count: data.followers || 0,
|
||||
friends_count: data.following || 0,
|
||||
profile_image: data.profile_image || "",
|
||||
statuses_count: data.posts || 0,
|
||||
},
|
||||
total_urls: data.media_list.length,
|
||||
timeline: data.media_list.map((item: {
|
||||
url: string;
|
||||
date: string;
|
||||
tweet_id: string;
|
||||
type: string;
|
||||
media_type?: string;
|
||||
}) => ({
|
||||
url: item.url,
|
||||
date: item.date,
|
||||
tweet_id: item.tweet_id,
|
||||
type: item.media_type || item.type,
|
||||
is_retweet: false,
|
||||
})),
|
||||
metadata: {
|
||||
new_entries: data.media_list.length,
|
||||
page: 0,
|
||||
batch_size: 0,
|
||||
has_more: false,
|
||||
},
|
||||
};
|
||||
await SaveAccountToDB(convertedData.account_info.name, convertedData.account_info.nick, convertedData.account_info.profile_image, convertedData.total_urls, JSON.stringify(convertedData), detectedMediaType);
|
||||
imported++;
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
console.error(`Failed to import ${file.name}:`, err);
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
console.error(`Failed to import ${file.name}:`, err);
|
||||
if (imported > 0) {
|
||||
toast.success(`Imported ${imported} account(s)`);
|
||||
loadAccounts();
|
||||
}
|
||||
else {
|
||||
toast.error("No valid files imported");
|
||||
}
|
||||
}
|
||||
if (imported > 0) {
|
||||
toast.success(`Imported ${imported} account(s)`);
|
||||
loadAccounts();
|
||||
}
|
||||
else {
|
||||
toast.error("No valid files imported");
|
||||
}
|
||||
} finally {
|
||||
finally {
|
||||
cleanup();
|
||||
}
|
||||
};
|
||||
@@ -1014,9 +1019,9 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
|
||||
{gridView === "large" && (<div className="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4">
|
||||
{filteredAccounts
|
||||
.slice(0, visibleCount)
|
||||
.map((account) => (<div key={account.id} className={`relative rounded-lg border transition-colors p-4 ${selectedIds.has(account.id) ? "border-primary bg-primary/5" : "bg-card hover:bg-muted/50"}`}>
|
||||
|
||||
<Checkbox checked={selectedIds.has(account.id)} onCheckedChange={() => toggleSelect(account.id)} className="absolute top-2 left-2 z-10"/>
|
||||
.map((account, index) => (<div key={account.id} onClick={() => handleView(account.id, account.username)} className={`relative rounded-lg border transition-colors p-4 cursor-pointer ${selectedIds.has(account.id) ? "border-primary bg-primary/5" : "bg-card hover:bg-muted/50"}`}>
|
||||
|
||||
<Checkbox checked={selectedIds.has(account.id)} onCheckedChange={() => toggleSelect(account.id)} onClick={(e) => e.stopPropagation()} className="absolute top-2 left-2 z-10"/>
|
||||
|
||||
<div className="absolute top-2 right-2 z-10 flex gap-1">
|
||||
<Badge variant="secondary" className={cn("text-xs flex items-center gap-1", account.media_type === "text" && "bg-orange-500/20 text-orange-600 dark:text-orange-400", account.media_type === "image" && "bg-blue-500/20 text-blue-600 dark:text-blue-400", account.media_type === "video" && "bg-purple-500/20 text-purple-600 dark:text-purple-400", account.media_type === "gif" && "bg-green-500/20 text-green-600 dark:text-green-400", (!account.media_type || account.media_type === "all") && "bg-indigo-500/20 text-indigo-600 dark:text-indigo-400")}>
|
||||
@@ -1031,9 +1036,14 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
|
||||
</Badge>)}
|
||||
</div>
|
||||
<div className="flex flex-col items-center text-center gap-3 pt-4">
|
||||
{isPrivateAccount(account.username) ? (<div className="w-20 h-20 rounded-full bg-primary/10 flex items-center justify-center cursor-pointer hover:bg-primary/20 transition-colors" onClick={() => handleView(account.id, account.username)}>
|
||||
{account.username === "bookmarks" ? (<Bookmark className="h-10 w-10 text-primary"/>) : (<Heart className="h-10 w-10 text-primary"/>)}
|
||||
</div>) : (<img src={account.profile_image} alt={account.name} className="w-20 h-20 rounded-full cursor-pointer hover:opacity-80 transition-opacity" onClick={() => handleView(account.id, account.username)}/>)}
|
||||
<div className="relative">
|
||||
<span className="absolute -top-1.5 -left-1.5 z-10 flex h-5 min-w-5 items-center justify-center rounded-full bg-primary px-1 text-xs font-medium text-primary-foreground">
|
||||
{index + 1}
|
||||
</span>
|
||||
{isPrivateAccount(account.username) ? (<div className="w-20 h-20 rounded-full bg-primary/10 flex items-center justify-center">
|
||||
{account.username === "bookmarks" ? (<Bookmark className="h-10 w-10 text-primary"/>) : (<Heart className="h-10 w-10 text-primary"/>)}
|
||||
</div>) : (<img src={account.profile_image} alt={account.name} className="w-20 h-20 rounded-full"/>)}
|
||||
</div>
|
||||
<div className="w-full min-w-0">
|
||||
<div className="font-medium truncate">{account.name}</div>
|
||||
{!isPrivateAccount(account.username) && (<button type="button" onClick={() => openExternal(`https://x.com/${account.username}`)} className="text-sm text-muted-foreground hover:text-primary hover:underline">
|
||||
@@ -1103,9 +1113,9 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
|
||||
{gridView === "small" && (<div className="grid grid-cols-3 md:grid-cols-4 lg:grid-cols-6 gap-3">
|
||||
{filteredAccounts
|
||||
.slice(0, visibleCount)
|
||||
.map((account) => (<div key={account.id} className={`relative rounded-lg border transition-colors p-3 ${selectedIds.has(account.id) ? "border-primary bg-primary/5" : "bg-card hover:bg-muted/50"}`}>
|
||||
|
||||
<Checkbox checked={selectedIds.has(account.id)} onCheckedChange={() => toggleSelect(account.id)} className="absolute top-1.5 left-1.5 z-10"/>
|
||||
.map((account, index) => (<div key={account.id} onClick={() => handleView(account.id, account.username)} className={`relative rounded-lg border transition-colors p-3 cursor-pointer ${selectedIds.has(account.id) ? "border-primary bg-primary/5" : "bg-card hover:bg-muted/50"}`}>
|
||||
|
||||
<Checkbox checked={selectedIds.has(account.id)} onCheckedChange={() => toggleSelect(account.id)} onClick={(e) => e.stopPropagation()} className="absolute top-1.5 left-1.5 z-10"/>
|
||||
|
||||
<div className="absolute top-1.5 right-1.5 z-10 flex gap-1">
|
||||
<Badge variant="secondary" className={cn("text-xs p-1", account.media_type === "text" && "bg-orange-500/20 text-orange-600 dark:text-orange-400", account.media_type === "image" && "bg-blue-500/20 text-blue-600 dark:text-blue-400", account.media_type === "video" && "bg-purple-500/20 text-purple-600 dark:text-purple-400", account.media_type === "gif" && "bg-green-500/20 text-green-600 dark:text-green-400", (!account.media_type || account.media_type === "all") && "bg-indigo-500/20 text-indigo-600 dark:text-indigo-400")}>
|
||||
@@ -1120,9 +1130,14 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
|
||||
</Badge>)}
|
||||
</div>
|
||||
<div className="flex flex-col items-center text-center gap-2 pt-4">
|
||||
{isPrivateAccount(account.username) ? (<div className="w-14 h-14 rounded-full bg-primary/10 flex items-center justify-center cursor-pointer hover:bg-primary/20 transition-colors" onClick={() => handleView(account.id, account.username)}>
|
||||
{account.username === "bookmarks" ? (<Bookmark className="h-7 w-7 text-primary"/>) : (<Heart className="h-7 w-7 text-primary"/>)}
|
||||
</div>) : (<img src={account.profile_image} alt={account.name} className="w-14 h-14 rounded-full cursor-pointer hover:opacity-80 transition-opacity" onClick={() => handleView(account.id, account.username)}/>)}
|
||||
<div className="relative">
|
||||
<span className="absolute -top-1.5 -left-1.5 z-10 flex h-5 min-w-5 items-center justify-center rounded-full bg-primary px-1 text-xs font-medium text-primary-foreground">
|
||||
{index + 1}
|
||||
</span>
|
||||
{isPrivateAccount(account.username) ? (<div className="w-14 h-14 rounded-full bg-primary/10 flex items-center justify-center">
|
||||
{account.username === "bookmarks" ? (<Bookmark className="h-7 w-7 text-primary"/>) : (<Heart className="h-7 w-7 text-primary"/>)}
|
||||
</div>) : (<img src={account.profile_image} alt={account.name} className="w-14 h-14 rounded-full"/>)}
|
||||
</div>
|
||||
<div className="w-full min-w-0">
|
||||
<div className="text-xs font-medium truncate">{account.name}</div>
|
||||
{!isPrivateAccount(account.username) && (<button type="button" onClick={() => openExternal(`https://x.com/${account.username}`)} className="text-xs text-muted-foreground hover:text-primary hover:underline truncate block w-full">
|
||||
@@ -1192,14 +1207,16 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
|
||||
{gridView === "list" && filteredAccounts
|
||||
.slice(0, visibleCount)
|
||||
.map((account, index) => (<div key={account.id} className={`rounded-lg border transition-colors ${selectedIds.has(account.id) ? "border-primary bg-primary/5" : "bg-card hover:bg-muted/50"}`}>
|
||||
<div className="flex items-center gap-4 p-4">
|
||||
<Checkbox checked={selectedIds.has(account.id)} onCheckedChange={() => toggleSelect(account.id)}/>
|
||||
<span className="text-sm text-muted-foreground w-8 text-center shrink-0">
|
||||
{index + 1}
|
||||
</span>
|
||||
{isPrivateAccount(account.username) ? (<div className="w-12 h-12 rounded-full bg-primary/10 flex items-center justify-center cursor-pointer hover:bg-primary/20 transition-colors" onClick={() => handleView(account.id, account.username)}>
|
||||
{account.username === "bookmarks" ? (<Bookmark className="h-6 w-6 text-primary"/>) : (<Heart className="h-6 w-6 text-primary"/>)}
|
||||
</div>) : (<img src={account.profile_image} alt={account.name} className="w-12 h-12 rounded-full cursor-pointer hover:opacity-80 transition-opacity" onClick={() => handleView(account.id, account.username)}/>)}
|
||||
<div className="flex items-center gap-4 p-4 cursor-pointer" onClick={() => handleView(account.id, account.username)}>
|
||||
<Checkbox checked={selectedIds.has(account.id)} onCheckedChange={() => toggleSelect(account.id)} onClick={(e) => e.stopPropagation()}/>
|
||||
<div className="relative shrink-0">
|
||||
<span className="absolute -top-1.5 -left-1.5 z-10 flex h-5 min-w-5 items-center justify-center rounded-full bg-primary px-1 text-xs font-medium text-primary-foreground">
|
||||
{index + 1}
|
||||
</span>
|
||||
{isPrivateAccount(account.username) ? (<div className="w-12 h-12 rounded-full bg-primary/10 flex items-center justify-center">
|
||||
{account.username === "bookmarks" ? (<Bookmark className="h-6 w-6 text-primary"/>) : (<Heart className="h-6 w-6 text-primary"/>)}
|
||||
</div>) : (<img src={account.profile_image} alt={account.name} className="w-12 h-12 rounded-full"/>)}
|
||||
</div>
|
||||
<div className="flex-1 min-w-0">
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="truncate">{account.name}</span>
|
||||
|
||||
@@ -6,17 +6,13 @@ import { Spinner } from "@/components/ui/spinner";
|
||||
import { toastWithSound as toast } from "@/lib/toast-with-sound";
|
||||
import { Quit } from "../../wailsjs/runtime/runtime";
|
||||
import { DownloadExtractor, IsExtractorInstalled } from "../../wailsjs/go/main/App";
|
||||
|
||||
interface DependencySetupDialogProps {
|
||||
onInstalled?: () => void;
|
||||
}
|
||||
|
||||
interface GithubReleaseResponse {
|
||||
tag_name?: string;
|
||||
}
|
||||
|
||||
const extractorReleaseAPIURL = "https://api.github.com/repos/afkarxyz/xtractor-binaries/releases/latest";
|
||||
|
||||
export function DependencySetupDialog({ onInstalled }: DependencySetupDialogProps) {
|
||||
const [open, setOpen] = useState(false);
|
||||
const [checking, setChecking] = useState(true);
|
||||
@@ -24,11 +20,9 @@ export function DependencySetupDialog({ onInstalled }: DependencySetupDialogProp
|
||||
const [errorMessage, setErrorMessage] = useState<string | null>(null);
|
||||
const [releaseVersion, setReleaseVersion] = useState<string | null>(null);
|
||||
const [releaseStatusMessage, setReleaseStatusMessage] = useState("Checking latest GitHub release...");
|
||||
|
||||
useEffect(() => {
|
||||
let cancelled = false;
|
||||
const abortController = new AbortController();
|
||||
|
||||
const checkDependency = async () => {
|
||||
try {
|
||||
const installed = await IsExtractorInstalled();
|
||||
@@ -49,7 +43,6 @@ export function DependencySetupDialog({ onInstalled }: DependencySetupDialogProp
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const loadReleaseInfo = async () => {
|
||||
try {
|
||||
const response = await fetch(extractorReleaseAPIURL, {
|
||||
@@ -58,18 +51,14 @@ export function DependencySetupDialog({ onInstalled }: DependencySetupDialogProp
|
||||
},
|
||||
signal: abortController.signal,
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`GitHub release status ${response.status}`);
|
||||
}
|
||||
|
||||
const release = (await response.json()) as GithubReleaseResponse;
|
||||
const version = release.tag_name?.trim();
|
||||
|
||||
if (!version) {
|
||||
throw new Error("Missing GitHub release tag");
|
||||
}
|
||||
|
||||
if (!cancelled) {
|
||||
setReleaseVersion(version);
|
||||
setReleaseStatusMessage(`Latest GitHub release: ${version}`);
|
||||
@@ -82,16 +71,13 @@ export function DependencySetupDialog({ onInstalled }: DependencySetupDialogProp
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void checkDependency();
|
||||
void loadReleaseInfo();
|
||||
|
||||
return () => {
|
||||
cancelled = true;
|
||||
abortController.abort();
|
||||
};
|
||||
}, []);
|
||||
|
||||
const handleDownload = async () => {
|
||||
setDownloading(true);
|
||||
setErrorMessage(null);
|
||||
@@ -110,17 +96,14 @@ export function DependencySetupDialog({ onInstalled }: DependencySetupDialogProp
|
||||
setDownloading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleExit = () => {
|
||||
if (!downloading) {
|
||||
void Quit();
|
||||
}
|
||||
};
|
||||
|
||||
if (checking && !open) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (<Dialog open={open} onOpenChange={(nextOpen) => {
|
||||
if (nextOpen) {
|
||||
setOpen(true);
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
import { useRef } from "react";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { RefreshCw } from "lucide-react";
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
|
||||
import { type TemplateToken } from "@/lib/settings";
|
||||
export function FormatEditor({ title, value, defaultValue, tokens, suffix, placeholder, render, onChange }: {
|
||||
title: string;
|
||||
value: string;
|
||||
defaultValue: string;
|
||||
tokens: TemplateToken[];
|
||||
suffix?: string;
|
||||
placeholder?: string;
|
||||
render: (template: string) => string;
|
||||
onChange: (next: string) => void;
|
||||
}) {
|
||||
const inputRef = useRef<HTMLInputElement | null>(null);
|
||||
const insertToken = (token: string) => {
|
||||
const input = inputRef.current;
|
||||
let next: string;
|
||||
let caret: number;
|
||||
if (input && input.selectionStart !== null && input.selectionEnd !== null) {
|
||||
const start = input.selectionStart;
|
||||
const end = input.selectionEnd;
|
||||
next = value.slice(0, start) + token + value.slice(end);
|
||||
caret = start + token.length;
|
||||
}
|
||||
else {
|
||||
next = value + token;
|
||||
caret = next.length;
|
||||
}
|
||||
onChange(next);
|
||||
requestAnimationFrame(() => {
|
||||
if (input) {
|
||||
input.focus();
|
||||
input.setSelectionRange(caret, caret);
|
||||
}
|
||||
});
|
||||
};
|
||||
const preview = render(value) + (suffix ?? "");
|
||||
return (<div className="space-y-3">
|
||||
<Label className="text-sm font-semibold">{title}</Label>
|
||||
<div className="relative">
|
||||
<Input ref={inputRef} value={value} placeholder={placeholder} onChange={(e) => onChange(e.target.value)} className="font-mono text-sm pr-9"/>
|
||||
<button type="button" onClick={() => onChange(defaultValue)} className="absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors">
|
||||
<RefreshCw className="h-4 w-4"/>
|
||||
</button>
|
||||
</div>
|
||||
<div className="rounded-lg border bg-muted/40 px-3 py-2">
|
||||
<div className="text-[10px] font-semibold uppercase tracking-wide text-muted-foreground">Preview</div>
|
||||
<div className="font-mono text-sm break-all">{preview || <span className="text-muted-foreground italic">empty</span>}</div>
|
||||
</div>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{tokens.map((token) => (<Tooltip key={token.key}>
|
||||
<TooltipTrigger asChild>
|
||||
<button type="button" onMouseDown={(e) => e.preventDefault()} onClick={() => insertToken(token.key)} className="rounded-md border bg-background px-2.5 py-1 text-xs font-mono text-muted-foreground transition-colors hover:text-foreground hover:border-primary/50">
|
||||
{token.key}
|
||||
</button>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="top">
|
||||
<span className="font-mono">{token.example || "—"}</span>
|
||||
</TooltipContent>
|
||||
</Tooltip>))}
|
||||
</div>
|
||||
</div>);
|
||||
}
|
||||
@@ -5,15 +5,15 @@ import { Badge } from "@/components/ui/badge";
|
||||
import { Progress } from "@/components/ui/progress";
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@/components/ui/select";
|
||||
import { Tooltip, TooltipContent, TooltipTrigger, } from "@/components/ui/tooltip";
|
||||
import { Image, Video, Film, FileText, ExternalLink, Repeat2, Download, FolderOpen, LayoutGrid, Grid3X3, List, StopCircle, Users, UserPlus, MessageSquare, Calendar, ArrowUp, ChevronLeft, ChevronRight, Eye, Heart, Bookmark, BadgeCheck, Maximize2, CheckCircle, XCircle, FileCheck, } from "lucide-react";
|
||||
import { Image, Video, Film, FileText, ExternalLink, Repeat2, Download, FolderOpen, LayoutGrid, Grid3X3, List, StopCircle, MapPin, Link2, Lock, Calendar, ArrowUp, ChevronLeft, ChevronRight, Eye, Heart, Bookmark, BadgeCheck, Maximize2, CheckCircle, XCircle, FileCheck, } from "lucide-react";
|
||||
import { Spinner } from "@/components/ui/spinner";
|
||||
import type { TimelineEntry, AccountInfo } from "@/types/api";
|
||||
import { logger } from "@/lib/logger";
|
||||
import { toastWithSound as toast } from "@/lib/toast-with-sound";
|
||||
import { getSettings } from "@/lib/settings";
|
||||
import { getSettings, renderFolderTemplate } from "@/lib/settings";
|
||||
import { getCachedDependencyStatus, getCachedMediaFolderStatus, setCachedDependencyStatus, setCachedMediaFolderStatus } from "@/lib/runtime-cache";
|
||||
import { openExternal } from "@/lib/utils";
|
||||
import { DownloadMediaWithMetadata, OpenFolder, IsFFmpegInstalled, ConvertGIFs, StopDownload, CheckFolderExists, CheckGifsFolderHasMP4 } from "../../wailsjs/go/main/App";
|
||||
import { DownloadMediaWithMetadata, DownloadProfileImage, OpenFolder, IsFFmpegInstalled, ConvertGIFs, StopDownload, CheckFolderExists, CheckGifsFolderHasMP4 } from "../../wailsjs/go/main/App";
|
||||
import { EventsOn } from "../../wailsjs/runtime/runtime";
|
||||
import { main } from "../../wailsjs/go/models";
|
||||
interface DownloadProgress {
|
||||
@@ -34,11 +34,9 @@ interface MediaListProps {
|
||||
newMediaCount?: number | null;
|
||||
}
|
||||
const MEDIA_LIST_PAGE_SIZE = 30;
|
||||
|
||||
function getContentScrollElement(): HTMLElement | null {
|
||||
return document.getElementById("app-content-scroll");
|
||||
}
|
||||
|
||||
function getThumbnailUrl(url: string): string {
|
||||
if (url.includes("video.twimg.com/tweet_video/")) {
|
||||
const match = url.match(/tweet_video\/([^/]+)\.mp4/);
|
||||
@@ -78,6 +76,12 @@ function getPreviewUrl(url: string): string {
|
||||
}
|
||||
return url;
|
||||
}
|
||||
function getEntryThumbnail(item: TimelineEntry): string {
|
||||
if (item.thumbnail) {
|
||||
return item.thumbnail;
|
||||
}
|
||||
return getThumbnailUrl(item.url);
|
||||
}
|
||||
function getMediaIcon(type: string) {
|
||||
switch (type) {
|
||||
case "photo":
|
||||
@@ -95,10 +99,14 @@ function getMediaIcon(type: string) {
|
||||
}
|
||||
function formatDate(dateStr: string): string {
|
||||
try {
|
||||
if (dateStr.includes("T")) {
|
||||
const [datePart, timePart] = dateStr.split("T");
|
||||
const timeClean = timePart.split("+")[0].split("Z")[0];
|
||||
return `${datePart} • ${timeClean}`;
|
||||
const d = new Date(dateStr);
|
||||
if (!Number.isNaN(d.getTime())) {
|
||||
const year = d.getFullYear();
|
||||
const month = String(d.getMonth() + 1).padStart(2, "0");
|
||||
const day = String(d.getDate()).padStart(2, "0");
|
||||
const hours = String(d.getHours()).padStart(2, "0");
|
||||
const minutes = String(d.getMinutes()).padStart(2, "0");
|
||||
return `${year}-${month}-${day} ${hours}:${minutes}`;
|
||||
}
|
||||
return dateStr;
|
||||
}
|
||||
@@ -168,7 +176,6 @@ function formatJoinDate(dateStr: string): string {
|
||||
return dateStr;
|
||||
}
|
||||
}
|
||||
|
||||
function getAccountFolderName(accountInfo: AccountInfo): string {
|
||||
if (accountInfo.nick === "My Bookmarks" || accountInfo.name === "bookmarks") {
|
||||
return "My Bookmarks";
|
||||
@@ -176,9 +183,26 @@ function getAccountFolderName(accountInfo: AccountInfo): string {
|
||||
if (accountInfo.nick === "My Likes" || accountInfo.name === "likes") {
|
||||
return "My Likes";
|
||||
}
|
||||
return accountInfo.name;
|
||||
const template = getSettings().folderTemplate;
|
||||
const pad = (n: number) => String(n).padStart(2, "0");
|
||||
const now = new Date();
|
||||
const rendered = renderFolderTemplate(template, {
|
||||
username: accountInfo.name,
|
||||
date: `${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(now.getDate())}`,
|
||||
});
|
||||
return rendered || accountInfo.name;
|
||||
}
|
||||
function pickVariantUrl(variants: {
|
||||
name: string;
|
||||
url: string;
|
||||
}[] | undefined, size: string, fallback: string): string {
|
||||
if (variants && variants.length > 0) {
|
||||
const match = variants.find((v) => v.name === size);
|
||||
if (match?.url)
|
||||
return match.url;
|
||||
}
|
||||
return fallback;
|
||||
}
|
||||
|
||||
export function MediaList({ accountInfo, timeline, totalUrls, fetchedMediaType = "all", newMediaCount = null, }: MediaListProps) {
|
||||
const settings = getSettings();
|
||||
const folderName = getAccountFolderName(accountInfo);
|
||||
@@ -188,7 +212,13 @@ export function MediaList({ accountInfo, timeline, totalUrls, fetchedMediaType =
|
||||
const [selectedItems, setSelectedItems] = useState<Set<string>>(new Set());
|
||||
const [sortBy, setSortBy] = useState<string>("date-desc");
|
||||
const [filterType, setFilterType] = useState<string>("all");
|
||||
const [viewMode, setViewMode] = useState<"large" | "small" | "list">("list");
|
||||
const [viewMode, setViewMode] = useState<"large" | "small" | "list">(() => {
|
||||
const stored = localStorage.getItem("resultViewMode");
|
||||
return stored === "large" || stored === "small" || stored === "list" ? stored : "list";
|
||||
});
|
||||
useEffect(() => {
|
||||
localStorage.setItem("resultViewMode", viewMode);
|
||||
}, [viewMode]);
|
||||
const [isDownloading, setIsDownloading] = useState(false);
|
||||
const [downloadProgress, setDownloadProgress] = useState<DownloadProgress | null>(null);
|
||||
const [hasDownloaded, setHasDownloaded] = useState(false);
|
||||
@@ -466,6 +496,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) {
|
||||
@@ -537,6 +569,30 @@ export function MediaList({ accountInfo, timeline, totalUrls, fetchedMediaType =
|
||||
console.error("Failed to stop download:", error);
|
||||
}
|
||||
};
|
||||
const handleDownloadProfileImage = async (kind: "avatar" | "banner") => {
|
||||
const settings = getSettings();
|
||||
const url = kind === "avatar"
|
||||
? pickVariantUrl(accountInfo.avatar_variants, settings.avatarSize, accountInfo.profile_image)
|
||||
: pickVariantUrl(accountInfo.banner_variants, settings.bannerSize, accountInfo.banner || "");
|
||||
if (!url) {
|
||||
toast.error(`No ${kind} available`);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await DownloadProfileImage(new main.DownloadProfileImageRequest({
|
||||
url,
|
||||
output_dir: settings.downloadPath,
|
||||
username: folderName,
|
||||
kind,
|
||||
proxy: settings.proxy || "",
|
||||
}));
|
||||
toast.success(`${kind === "avatar" ? "Avatar" : "Banner"} downloaded`);
|
||||
}
|
||||
catch (error) {
|
||||
logger.error(`Failed to download ${kind}: ${error}`);
|
||||
toast.error(`Failed to download ${kind}`);
|
||||
}
|
||||
};
|
||||
const handleOpenFolder = async () => {
|
||||
const settings = getSettings();
|
||||
const isBookmarks = accountInfo.nick === "My Bookmarks";
|
||||
@@ -633,40 +689,69 @@ export function MediaList({ accountInfo, timeline, totalUrls, fetchedMediaType =
|
||||
</div>
|
||||
<div className="text-sm text-muted-foreground">items found</div>
|
||||
</div>
|
||||
</div>) : (<div className="flex items-center gap-4 p-4 bg-muted/50 rounded-lg">
|
||||
<img src={accountInfo.profile_image} alt={accountInfo.nick} className="w-16 h-16 rounded-full"/>
|
||||
<div className="flex-1">
|
||||
<div className="flex items-center gap-2">
|
||||
<h2 className="text-xl">{accountInfo.nick}</h2>
|
||||
<span className="text-muted-foreground">@{accountInfo.name}</span>
|
||||
</div>) : (<div className="rounded-lg overflow-hidden bg-muted/50 border">
|
||||
{accountInfo.banner && (<div className="group/banner relative h-24 w-full bg-cover bg-center" style={{ backgroundImage: `url("${accountInfo.banner}")` }}>
|
||||
<button type="button" aria-label="Download banner" onClick={() => void handleDownloadProfileImage("banner")} className="absolute top-2 right-2 flex h-9 w-9 items-center justify-center rounded-full bg-black/60 text-white opacity-0 transition-all hover:scale-105 hover:bg-primary hover:text-primary-foreground group-hover/banner:opacity-100">
|
||||
<Download className="h-4 w-4"/>
|
||||
</button>
|
||||
</div>)}
|
||||
<div className="p-4">
|
||||
<div className="flex items-end justify-between gap-4">
|
||||
<div className="flex items-end gap-3 min-w-0">
|
||||
<div className={`group/avatar relative shrink-0 ${accountInfo.banner ? "-mt-14" : ""}`}>
|
||||
<img src={accountInfo.profile_image} alt={accountInfo.nick} className={`w-20 h-20 rounded-full object-cover bg-muted ${accountInfo.banner ? "ring-4 ring-background" : ""}`}/>
|
||||
<button type="button" aria-label="Download avatar" onClick={() => void handleDownloadProfileImage("avatar")} className="absolute inset-0 flex items-center justify-center rounded-full bg-black/50 text-white opacity-0 transition-opacity hover:bg-black/62 group-hover/avatar:opacity-100">
|
||||
<Download className="h-5 w-5"/>
|
||||
</button>
|
||||
</div>
|
||||
<div className="min-w-0">
|
||||
<div className="flex items-center gap-1.5">
|
||||
<h2 className="text-xl font-bold truncate">{accountInfo.nick}</h2>
|
||||
{(accountInfo.verified || accountInfo.blue_verified) && (<BadgeCheck className="h-4 w-4 text-blue-500 shrink-0"/>)}
|
||||
{accountInfo.protected && (<Lock className="h-3.5 w-3.5 text-muted-foreground shrink-0"/>)}
|
||||
</div>
|
||||
<div className="text-sm text-muted-foreground truncate">@{accountInfo.name}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="text-right shrink-0">
|
||||
<div className="flex items-center justify-end gap-2">
|
||||
{newMediaCount !== null && newMediaCount > 0 && (<div className="text-lg font-semibold text-green-600 dark:text-green-400 animate-in fade-in slide-in-from-left-2 duration-300">
|
||||
{formatNumberWithComma(newMediaCount)}+
|
||||
</div>)}
|
||||
<div className="text-2xl font-bold text-primary">{formatNumberWithComma(totalUrls)}</div>
|
||||
</div>
|
||||
<div className="text-sm text-muted-foreground">items found</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center gap-4 text-sm text-muted-foreground mt-1">
|
||||
<span className="flex items-center gap-1">
|
||||
<Users className="h-3.5 w-3.5"/>
|
||||
{formatNumber(accountInfo.followers_count)} followers
|
||||
</span>
|
||||
<span className="flex items-center gap-1">
|
||||
<UserPlus className="h-3.5 w-3.5"/>
|
||||
{formatNumber(accountInfo.friends_count)} following
|
||||
</span>
|
||||
<span className="flex items-center gap-1">
|
||||
<MessageSquare className="h-3.5 w-3.5"/>
|
||||
{formatNumber(accountInfo.statuses_count)} posts
|
||||
</span>
|
||||
|
||||
{accountInfo.bio && (<p className="text-sm mt-3 whitespace-pre-wrap wrap-break-word">{accountInfo.bio}</p>)}
|
||||
|
||||
<div className="flex flex-wrap items-center gap-x-4 gap-y-1 text-sm text-muted-foreground mt-3">
|
||||
{accountInfo.location && (<span className="flex items-center gap-1">
|
||||
<MapPin className="h-3.5 w-3.5"/>
|
||||
{accountInfo.location}
|
||||
</span>)}
|
||||
{accountInfo.url && (<button type="button" onClick={() => openExternal(accountInfo.url!)} className="flex items-center gap-1 hover:underline">
|
||||
<Link2 className="h-3.5 w-3.5"/>
|
||||
{accountInfo.url.replace(/^https?:\/\//, "").replace(/\/+$/, "")}
|
||||
</button>)}
|
||||
{accountInfo.date && (<span className="flex items-center gap-1">
|
||||
<Calendar className="h-3.5 w-3.5"/>
|
||||
Joined {formatJoinDate(accountInfo.date)}
|
||||
</span>)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="text-right">
|
||||
<div className="flex items-center justify-end gap-2">
|
||||
{newMediaCount !== null && newMediaCount > 0 && (<div className="text-lg font-semibold text-green-600 dark:text-green-400 animate-in fade-in slide-in-from-left-2 duration-300">
|
||||
{formatNumberWithComma(newMediaCount)}+
|
||||
</div>)}
|
||||
<div className="text-2xl font-bold text-primary">{formatNumberWithComma(totalUrls)}</div>
|
||||
|
||||
<div className="flex flex-wrap items-center gap-x-2 gap-y-1 text-sm mt-3">
|
||||
<span><strong className="text-foreground">{formatNumber(accountInfo.statuses_count)}</strong> <span className="text-muted-foreground">posts</span></span>
|
||||
<span className="text-muted-foreground">·</span>
|
||||
<span><strong className="text-foreground">{formatNumber(accountInfo.friends_count)}</strong> <span className="text-muted-foreground">following</span></span>
|
||||
<span className="text-muted-foreground">·</span>
|
||||
<span><strong className="text-foreground">{formatNumber(accountInfo.followers_count)}</strong> <span className="text-muted-foreground">followers</span></span>
|
||||
{accountInfo.media_count ? (<>
|
||||
<span className="text-muted-foreground">·</span>
|
||||
<span><strong className="text-foreground">{formatNumber(accountInfo.media_count)}</strong> <span className="text-muted-foreground">media</span></span>
|
||||
</>) : null}
|
||||
</div>
|
||||
<div className="text-sm text-muted-foreground">items found</div>
|
||||
</div>
|
||||
</div>)}
|
||||
|
||||
@@ -707,6 +792,12 @@ export function MediaList({ accountInfo, timeline, totalUrls, fetchedMediaType =
|
||||
GIFs ({formatNumberWithComma(mediaCounts.gif)})
|
||||
</span>
|
||||
</SelectItem>)}
|
||||
{mediaCounts.text > 0 && (<SelectItem value="text">
|
||||
<span className="flex items-center gap-2">
|
||||
<FileText className="h-4 w-4 text-orange-500"/>
|
||||
Text ({formatNumberWithComma(mediaCounts.text)})
|
||||
</span>
|
||||
</SelectItem>)}
|
||||
</SelectContent>
|
||||
</Select>)}
|
||||
|
||||
@@ -783,15 +874,17 @@ export function MediaList({ accountInfo, timeline, totalUrls, fetchedMediaType =
|
||||
const isItemFailed = failedItems.has(itemKey);
|
||||
const isItemSkipped = skippedItems.has(itemKey);
|
||||
const isItemDownloading = downloadingItem === itemKey;
|
||||
return (<div key={itemKey} className={`flex items-center gap-4 p-3 rounded-lg border-2 transition-all ${isSelected ? "border-primary bg-primary/5" : "border-transparent hover:bg-muted/50"}`}>
|
||||
<Checkbox checked={isSelected} onCheckedChange={() => toggleItem(itemKey)}/>
|
||||
<span className="text-sm text-muted-foreground w-8 text-center shrink-0">
|
||||
{index + 1}
|
||||
</span>
|
||||
<div className="w-16 h-16 rounded overflow-hidden bg-muted shrink-0 cursor-pointer hover:opacity-80 transition-opacity" onClick={() => openPreview(index)}>
|
||||
{item.type === "photo" || item.type === "animated_gif" || item.type === "gif" ? (<img src={getThumbnailUrl(item.url)} alt="" className="w-full h-full object-cover" loading="lazy"/>) : (<div className="w-full h-full flex items-center justify-center">
|
||||
{getMediaIcon(item.type)}
|
||||
</div>)}
|
||||
return (<div key={itemKey} onClick={() => openPreview(index)} className={`flex items-center gap-4 p-3 rounded-lg border-2 transition-all cursor-pointer ${isSelected ? "border-primary bg-primary/5" : "border-transparent hover:bg-muted/50"}`}>
|
||||
<Checkbox checked={isSelected} onCheckedChange={() => toggleItem(itemKey)} onClick={(e) => e.stopPropagation()}/>
|
||||
<div className="relative shrink-0">
|
||||
<span className="absolute -top-1.5 -left-1.5 z-10 flex h-5 min-w-5 items-center justify-center rounded-full bg-primary px-1 text-xs font-medium text-primary-foreground">
|
||||
{index + 1}
|
||||
</span>
|
||||
<div className="w-16 h-16 rounded overflow-hidden bg-muted">
|
||||
{item.type !== "text" && getEntryThumbnail(item) ? (<img src={getEntryThumbnail(item)} alt="" className="w-full h-full object-cover" loading="lazy"/>) : (<div className="w-full h-full flex items-center justify-center">
|
||||
{getMediaIcon(item.type)}
|
||||
</div>)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex-1 min-w-0">
|
||||
<div className="flex items-center gap-2">
|
||||
@@ -841,6 +934,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) {
|
||||
@@ -888,7 +983,10 @@ export function MediaList({ accountInfo, timeline, totalUrls, fetchedMediaType =
|
||||
return (<div key={itemKey} className={`relative group rounded-lg overflow-hidden border-2 transition-all ${isSelected ? "border-primary" : "border-transparent hover:border-muted-foreground/30"}`}>
|
||||
|
||||
<div className="aspect-square bg-muted relative cursor-pointer" onClick={() => openPreview(index)}>
|
||||
{item.type === "photo" || item.type === "animated_gif" || item.type === "gif" ? (<img src={getThumbnailUrl(item.url)} alt="" className="w-full h-full object-cover" loading="lazy"/>) : (<div className="w-full h-full flex items-center justify-center bg-muted">
|
||||
<span className="absolute top-1.5 left-1.5 z-20 flex h-5 min-w-5 items-center justify-center rounded-full bg-primary px-1 text-xs font-medium text-primary-foreground">
|
||||
{index + 1}
|
||||
</span>
|
||||
{item.type !== "text" && getEntryThumbnail(item) ? (<img src={getEntryThumbnail(item)} alt="" className="w-full h-full object-cover" loading="lazy"/>) : (<div className="w-full h-full flex items-center justify-center bg-muted">
|
||||
{getMediaIcon(item.type)}
|
||||
</div>)}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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<SettingsMediaType>(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<SettingsFetchMode>(getSettings().fetchMode);
|
||||
const [videoQuality, setVideoQuality] = useState<VideoQuality>(getSettings().videoQuality);
|
||||
const [imageSize, setImageSize] = useState<ImageSize>(getSettings().imageSize);
|
||||
const [avatarSize, setAvatarSize] = useState<AvatarSize>(getSettings().avatarSize);
|
||||
const [bannerSize, setBannerSize] = useState<BannerSize>(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<ReturnType<typeof setTimeout> | 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 (<div className="space-y-3">
|
||||
|
||||
<div className="flex justify-center gap-2">
|
||||
@@ -508,11 +489,17 @@ export function SearchBar({ username, loading, onUsernameChange, onFetch, onStop
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className="ml-auto flex items-center gap-2">
|
||||
<span className="text-muted-foreground">Total:</span>
|
||||
<span className="font-medium">
|
||||
{formatNumberWithComma(multipleAccounts.filter((acc) => acc.status === "completed" || acc.status === "incomplete" || acc.status === "failed").length)}/{formatNumberWithComma(multipleAccounts.length)}
|
||||
</span>
|
||||
<div className="ml-auto flex items-center gap-3">
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="text-muted-foreground">Total:</span>
|
||||
<span className="font-medium">
|
||||
{formatNumberWithComma(multipleAccounts.filter((acc) => acc.status === "completed" || acc.status === "incomplete" || acc.status === "failed").length)}/{formatNumberWithComma(multipleAccounts.length)}
|
||||
</span>
|
||||
</div>
|
||||
{!isFetchingAll && onOpenSavedAccounts && multipleAccounts.some((acc) => acc.status === "completed" || acc.status === "incomplete") && (<Button variant="secondary" size="sm" onClick={onOpenSavedAccounts} className="flex items-center gap-2">
|
||||
<Database className="h-3.5 w-3.5"/>
|
||||
Open Saved Accounts to Download
|
||||
</Button>)}
|
||||
</div>
|
||||
</div>
|
||||
</div>)}
|
||||
@@ -557,8 +544,8 @@ export function SearchBar({ username, loading, onUsernameChange, onFetch, onStop
|
||||
<Clock className="h-3.5 w-3.5 shrink-0 text-muted-foreground"/>
|
||||
<span className="font-mono">
|
||||
{account.remainingTime !== null && account.remainingTime >= 0
|
||||
? formatTime(account.remainingTime)
|
||||
: formatTime(account.elapsedTime)}
|
||||
? formatTime(account.remainingTime)
|
||||
: formatTime(account.elapsedTime)}
|
||||
</span>
|
||||
</div>
|
||||
<Button variant="destructive" onClick={() => onStopAccount?.(account.id)} className="flex items-center gap-2">
|
||||
@@ -640,10 +627,10 @@ export function SearchBar({ username, loading, onUsernameChange, onFetch, onStop
|
||||
<Label htmlFor="required-auth-token">Auth Token</Label>
|
||||
<div className="relative">
|
||||
<InputWithContext id="required-auth-token" type={showAuthToken ? "text" : "password"} placeholder="Enter your auth_token cookie value" value={authPromptToken} onChange={(e) => setAuthPromptToken(e.target.value)} onKeyDown={(e) => {
|
||||
if (e.key === "Enter") {
|
||||
handleAuthPromptSubmit();
|
||||
}
|
||||
}} className="pr-10"/>
|
||||
if (e.key === "Enter") {
|
||||
handleAuthPromptSubmit();
|
||||
}
|
||||
}} className="pr-10"/>
|
||||
<button type="button" aria-label={showAuthToken ? "Hide auth token" : "Show auth token"} className="absolute top-1/2 right-2 -translate-y-1/2 text-muted-foreground transition-colors hover:text-foreground" onClick={() => setShowAuthToken((prev) => !prev)}>
|
||||
{showAuthToken ? <EyeOff className="h-4 w-4"/> : <Eye className="h-4 w-4"/>}
|
||||
</button>
|
||||
@@ -690,12 +677,12 @@ export function SearchBar({ username, loading, onUsernameChange, onFetch, onStop
|
||||
</Dialog>
|
||||
|
||||
<Dialog open={showSettingsDialog} onOpenChange={setShowSettingsDialog}>
|
||||
<DialogContent className="sm:max-w-xl">
|
||||
<DialogContent className="sm:max-w-xl max-h-[85vh] flex flex-col overflow-hidden">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Fetch Settings</DialogTitle>
|
||||
</DialogHeader>
|
||||
|
||||
<div className="space-y-5">
|
||||
<div className="space-y-4 overflow-y-auto flex-1 min-h-0 -mx-2 px-2">
|
||||
<div className="space-y-2">
|
||||
<div className="flex items-center gap-2">
|
||||
<Label htmlFor="shared-auth-token" className="text-sm">Auth Token</Label>
|
||||
@@ -709,74 +696,55 @@ export function SearchBar({ username, loading, onUsernameChange, onFetch, onStop
|
||||
</Tooltip>
|
||||
</div>
|
||||
|
||||
<div className="relative">
|
||||
<InputWithContext id="shared-auth-token" type={showAuthToken ? "text" : "password"} placeholder="Enter your auth_token cookie value" value={sharedAuthToken} onChange={(e) => void handleSharedTokenChange(e.target.value)} className="pr-10"/>
|
||||
<button type="button" aria-label={showAuthToken ? "Hide auth token" : "Show auth token"} className="absolute top-1/2 right-2 -translate-y-1/2 text-muted-foreground transition-colors hover:text-foreground" onClick={() => setShowAuthToken((prev) => !prev)}>
|
||||
{showAuthToken ? <EyeOff className="h-4 w-4"/> : <Eye className="h-4 w-4"/>}
|
||||
</button>
|
||||
</div>
|
||||
<InputWithContext id="shared-auth-token" type="text" placeholder="Enter your auth_token cookie value" value={sharedAuthToken} onChange={(e) => void handleSharedTokenChange(e.target.value)}/>
|
||||
|
||||
</div>
|
||||
|
||||
<div className="space-y-3">
|
||||
<div className="flex items-center justify-between gap-4">
|
||||
<Label htmlFor="fetch-mode" className="text-sm">Fetch Mode</Label>
|
||||
<Select value={currentFetchMode} onValueChange={(value: SettingsFetchMode) => {
|
||||
updateSettings({ fetchMode: value });
|
||||
setCurrentFetchMode(value);
|
||||
}}>
|
||||
<SelectTrigger id="fetch-mode" className="w-28">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="batch">Batch</SelectItem>
|
||||
<SelectItem value="single">Single</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
{fetchType === "single" && (<div className="flex items-center justify-between gap-4">
|
||||
<Label htmlFor="retweets" className="cursor-pointer text-sm">Include Reposts</Label>
|
||||
<Checkbox id="retweets" checked={retweets} onCheckedChange={(checked) => {
|
||||
const value = checked as boolean;
|
||||
updateSettings({ includeRetweets: value });
|
||||
setRetweets(value);
|
||||
}}/>
|
||||
</div>)}
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label className="text-sm">Include Media</Label>
|
||||
<div className="grid grid-cols-4 gap-2">
|
||||
<button type="button" className={pillClass(includePhotos)} onClick={() => { updateSettings({ includePhotos: !includePhotos }); setIncludePhotos((v) => !v); }}>Photos</button>
|
||||
<button type="button" className={pillClass(includeVideos)} onClick={() => { updateSettings({ includeVideos: !includeVideos }); setIncludeVideos((v) => !v); }}>Videos</button>
|
||||
<button type="button" className={pillClass(includeGifs)} onClick={() => { updateSettings({ includeGifs: !includeGifs }); setIncludeGifs((v) => !v); }}>GIFs</button>
|
||||
<button type="button" className={pillClass(includeText)} onClick={() => { updateSettings({ includeText: !includeText }); setIncludeText((v) => !v); }}>Text</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center justify-between gap-4">
|
||||
<Label htmlFor="media-type" className="text-sm">Media Type</Label>
|
||||
<Select value={mediaType} onValueChange={(value: SettingsMediaType) => {
|
||||
updateSettings({ mediaType: value });
|
||||
setMediaType(value);
|
||||
}}>
|
||||
<SelectTrigger id="media-type" className="w-40">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="all">All Media</SelectItem>
|
||||
<SelectItem value="image">Images</SelectItem>
|
||||
<SelectItem value="video">Videos</SelectItem>
|
||||
<SelectItem value="gif">GIFs</SelectItem>
|
||||
<SelectItem value="text">Text (No Media)</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<div className="space-y-2">
|
||||
<Label className="text-sm">Video Quality</Label>
|
||||
<div className="grid grid-cols-5 gap-2">
|
||||
{VIDEO_QUALITIES.map((q) => (<button key={q.value} type="button" className={pillClass(videoQuality === q.value)} onClick={() => { updateSettings({ videoQuality: q.value }); setVideoQuality(q.value); }}>{q.label}</button>))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{fetchType === "single" && (<div className="flex items-center justify-between gap-4">
|
||||
<Label htmlFor="retweets" className="cursor-pointer text-sm">Include Retweets</Label>
|
||||
<Checkbox id="retweets" checked={retweets} onCheckedChange={(checked) => {
|
||||
const value = checked as boolean;
|
||||
updateSettings({ includeRetweets: value });
|
||||
setRetweets(value);
|
||||
}}/>
|
||||
</div>)}
|
||||
<div className="space-y-2">
|
||||
<Label className="text-sm">Image Size</Label>
|
||||
<div className="grid grid-cols-4 gap-2">
|
||||
{IMAGE_SIZES.map((s) => (<button key={s.value} type="button" className={pillClass(imageSize === s.value)} onClick={() => { updateSettings({ imageSize: s.value }); setImageSize(s.value); }}>{s.label}</button>))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{fetchType === "single" && mode === "public" && (<div className="space-y-3">
|
||||
<div className="flex items-center justify-between gap-4">
|
||||
<Label htmlFor="date-range" className="flex cursor-pointer items-center gap-2 text-sm">
|
||||
<Calendar className="h-4 w-4"/>
|
||||
Date Range
|
||||
</Label>
|
||||
<Checkbox id="date-range" checked={useDateRange} onCheckedChange={(checked) => setUseDateRange(checked as boolean)}/>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label className="text-sm">Avatar Size</Label>
|
||||
<div className="grid grid-cols-5 gap-2">
|
||||
{AVATAR_SIZES.map((s) => (<button key={s.value} type="button" className={pillClass(avatarSize === s.value)} onClick={() => { updateSettings({ avatarSize: s.value }); setAvatarSize(s.value); }}>{s.label}</button>))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{useDateRange && (<div className="grid grid-cols-1 gap-3 sm:grid-cols-2">
|
||||
<InputWithContext id="start-date" type="date" value={startDate} onChange={(e) => setStartDate(e.target.value)}/>
|
||||
<InputWithContext id="end-date" type="date" value={endDate} onChange={(e) => setEndDate(e.target.value)}/>
|
||||
</div>)}
|
||||
</div>)}
|
||||
<div className="space-y-2">
|
||||
<Label className="text-sm">Banner Size</Label>
|
||||
<div className="grid grid-cols-4 gap-2">
|
||||
{BANNER_SIZES.map((s) => (<button key={s.value} type="button" className={pillClass(bannerSize === s.value)} onClick={() => { updateSettings({ bannerSize: s.value }); setBannerSize(s.value); }}>{s.label}</button>))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -6,31 +6,28 @@ 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 { Check, Download, ExternalLink, FolderOpen, Info, MonitorCog, PackageSearch, Plus, RotateCcw, Save, Trash2 } from "lucide-react";
|
||||
import { Check, Download, ExternalLink, FolderOpen, Info, MonitorCog, PackageSearch, Plus, RotateCcw, Save, Trash2, FileSignature } from "lucide-react";
|
||||
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from "@/components/ui/dialog";
|
||||
import { Spinner } from "@/components/ui/spinner";
|
||||
import { Switch } from "@/components/ui/switch";
|
||||
import { getSettings, getSettingsWithDefaults, saveSettings, resetToDefaultSettings, applyThemeMode, applyFont, getFontOptions, parseGoogleFontUrl, loadGoogleFontUrl, loadCustomFonts, saveCustomFonts, type Settings as SettingsType, type FontFamily, type GifQuality, type GifResolution, type CustomFontFamily } from "@/lib/settings";
|
||||
import { getSettings, getSettingsWithDefaults, saveSettings, resetToDefaultSettings, applyThemeMode, applyFont, getFontOptions, parseGoogleFontUrl, loadGoogleFontUrl, loadCustomFonts, saveCustomFonts, DEFAULT_FILENAME_TEMPLATE, FILENAME_TEMPLATE_VARIABLES, renderFilenameTemplate, SAMPLE_FILENAME_DATA, DEFAULT_FOLDER_TEMPLATE, FOLDER_TEMPLATE_VARIABLES, renderFolderTemplate, SAMPLE_FOLDER_DATA, type Settings as SettingsType, type FontFamily, type GifQuality, type GifResolution, type CustomFontFamily } from "@/lib/settings";
|
||||
import { FormatEditor } from "@/components/FormatEditor";
|
||||
import { getCachedDependencyStatus, setCachedDependencyStatus } from "@/lib/runtime-cache";
|
||||
import { themes, applyTheme } from "@/lib/themes";
|
||||
import { compareVersionNumbers } from "@/lib/version";
|
||||
import { SelectFolder, IsExtractorInstalled, DownloadExtractor, IsFFmpegInstalled, DownloadFFmpeg, IsExifToolInstalled, DownloadExifTool } from "../../wailsjs/go/main/App";
|
||||
import { toastWithSound as toast } from "@/lib/toast-with-sound";
|
||||
|
||||
interface DependencyVersionStatus {
|
||||
installed: boolean;
|
||||
installed_version?: string;
|
||||
latest_version?: string;
|
||||
}
|
||||
|
||||
type DependencyVersionMethod = "GetExtractorVersionStatus" | "GetFFmpegVersionStatus" | "GetExifToolVersionStatus";
|
||||
type SettingsTab = "general" | "downloads" | "dependencies";
|
||||
|
||||
type SettingsTab = "general" | "downloads" | "naming" | "dependencies";
|
||||
interface SettingsPageProps {
|
||||
onUnsavedChangesChange?: (hasUnsavedChanges: boolean) => void;
|
||||
onResetRequest?: (resetFn: () => void) => void;
|
||||
}
|
||||
|
||||
function getDependencyVersionStatus(methodName: DependencyVersionMethod) {
|
||||
const app = (window as Window & {
|
||||
go?: {
|
||||
@@ -42,14 +39,12 @@ function getDependencyVersionStatus(methodName: DependencyVersionMethod) {
|
||||
const method = app?.[methodName];
|
||||
return method ? method() : Promise.resolve(null);
|
||||
}
|
||||
|
||||
function hasNewDependencyVersion(installedVersion: string | null, latestVersion: string | null) {
|
||||
if (!installedVersion || !latestVersion) {
|
||||
return false;
|
||||
}
|
||||
return compareVersionNumbers(latestVersion, installedVersion) > 0;
|
||||
}
|
||||
|
||||
function buildDependencyVersionText(name: string, installed: boolean, installedVersion: string | null, latestVersion: string | null, updateAvailable: boolean) {
|
||||
if (installed) {
|
||||
if (!installedVersion) {
|
||||
@@ -61,7 +56,6 @@ function buildDependencyVersionText(name: string, installed: boolean, installedV
|
||||
}
|
||||
return latestVersion ? `Latest ${name}: ${latestVersion}` : null;
|
||||
}
|
||||
|
||||
export function SettingsPage({ onUnsavedChangesChange, onResetRequest }: SettingsPageProps) {
|
||||
const cachedExtractorStatus = getCachedDependencyStatus("extractor");
|
||||
const cachedFfmpegStatus = getCachedDependencyStatus("ffmpeg");
|
||||
@@ -85,14 +79,12 @@ export function SettingsPage({ onUnsavedChangesChange, onResetRequest }: Setting
|
||||
const [exiftoolLatestVersion, setExiftoolLatestVersion] = useState<string | null>(cachedExiftoolStatus.latestVersion);
|
||||
const [downloadingExifTool, setDownloadingExifTool] = useState(false);
|
||||
const [showResetConfirm, setShowResetConfirm] = useState(false);
|
||||
|
||||
const extractorUpdateAvailable = hasNewDependencyVersion(extractorInstalledVersion, extractorLatestVersion);
|
||||
const ffmpegUpdateAvailable = hasNewDependencyVersion(ffmpegInstalledVersion, ffmpegLatestVersion);
|
||||
const exiftoolUpdateAvailable = hasNewDependencyVersion(exiftoolInstalledVersion, exiftoolLatestVersion);
|
||||
const parsedAddFont = parseGoogleFontUrl(addFontUrl);
|
||||
const fontOptions = getFontOptions(tempSettings.customFonts);
|
||||
const hasUnsavedChanges = JSON.stringify(savedSettings) !== JSON.stringify(tempSettings);
|
||||
|
||||
const resetToSaved = useCallback(() => {
|
||||
const freshSavedSettings = getSettings();
|
||||
flushSync(() => {
|
||||
@@ -100,17 +92,14 @@ export function SettingsPage({ onUnsavedChangesChange, onResetRequest }: Setting
|
||||
setIsDark(document.documentElement.classList.contains("dark"));
|
||||
});
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (onResetRequest) {
|
||||
onResetRequest(resetToSaved);
|
||||
}
|
||||
}, [onResetRequest, resetToSaved]);
|
||||
|
||||
useEffect(() => {
|
||||
onUnsavedChangesChange?.(hasUnsavedChanges);
|
||||
}, [hasUnsavedChanges, onUnsavedChangesChange]);
|
||||
|
||||
const extractorVersionText = extractorInstalled
|
||||
? extractorInstalledVersion
|
||||
? extractorUpdateAvailable && extractorLatestVersion
|
||||
@@ -120,10 +109,8 @@ export function SettingsPage({ onUnsavedChangesChange, onResetRequest }: Setting
|
||||
: extractorLatestVersion
|
||||
? `Latest: ${extractorLatestVersion}`
|
||||
: null;
|
||||
|
||||
const ffmpegVersionText = buildDependencyVersionText("FFmpeg", ffmpegInstalled, ffmpegInstalledVersion, ffmpegLatestVersion, ffmpegUpdateAvailable);
|
||||
const exiftoolVersionText = buildDependencyVersionText("ExifTool", exiftoolInstalled, exiftoolInstalledVersion, exiftoolLatestVersion, exiftoolUpdateAvailable);
|
||||
|
||||
const loadDependencyStatus = async () => {
|
||||
try {
|
||||
const [extractorVersionStatus, ffmpegVersionStatus, exiftoolVersionStatus, extractor, ffmpeg, exiftool] = await Promise.all([
|
||||
@@ -143,7 +130,6 @@ export function SettingsPage({ onUnsavedChangesChange, onResetRequest }: Setting
|
||||
const nextExiftoolInstalled = exiftoolVersionStatus?.installed ?? exiftool;
|
||||
const nextExiftoolInstalledVersion = exiftoolVersionStatus?.installed_version?.trim() || null;
|
||||
const nextExiftoolLatestVersion = exiftoolVersionStatus?.latest_version?.trim() || null;
|
||||
|
||||
setCachedDependencyStatus("extractor", {
|
||||
installed: nextExtractorInstalled,
|
||||
installedVersion: nextExtractorInstalledVersion,
|
||||
@@ -159,7 +145,6 @@ export function SettingsPage({ onUnsavedChangesChange, onResetRequest }: Setting
|
||||
installedVersion: nextExiftoolInstalledVersion,
|
||||
latestVersion: nextExiftoolLatestVersion,
|
||||
});
|
||||
|
||||
setExtractorInstalled(nextExtractorInstalled);
|
||||
setExtractorInstalledVersion(nextExtractorInstalledVersion);
|
||||
setExtractorLatestVersion(nextExtractorLatestVersion);
|
||||
@@ -174,7 +159,6 @@ export function SettingsPage({ onUnsavedChangesChange, onResetRequest }: Setting
|
||||
console.error("Failed to check dependency status:", error);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
applyThemeMode(savedSettings.themeMode);
|
||||
applyTheme(savedSettings.theme);
|
||||
@@ -188,7 +172,6 @@ export function SettingsPage({ onUnsavedChangesChange, onResetRequest }: Setting
|
||||
mediaQuery.addEventListener("change", handleChange);
|
||||
return () => mediaQuery.removeEventListener("change", handleChange);
|
||||
}, [savedSettings.themeMode, savedSettings.theme]);
|
||||
|
||||
useEffect(() => {
|
||||
applyThemeMode(tempSettings.themeMode);
|
||||
applyTheme(tempSettings.theme);
|
||||
@@ -197,13 +180,11 @@ export function SettingsPage({ onUnsavedChangesChange, onResetRequest }: Setting
|
||||
setIsDark(document.documentElement.classList.contains("dark"));
|
||||
}, 0);
|
||||
}, [tempSettings.themeMode, tempSettings.theme, tempSettings.fontFamily, tempSettings.customFonts]);
|
||||
|
||||
useEffect(() => {
|
||||
if (showAddFontDialog && parsedAddFont) {
|
||||
loadGoogleFontUrl(parsedAddFont.url, "twitter-media-add-font-preview");
|
||||
}
|
||||
}, [showAddFontDialog, parsedAddFont]);
|
||||
|
||||
useEffect(() => {
|
||||
const loadDefaults = async () => {
|
||||
if (!savedSettings.downloadPath) {
|
||||
@@ -215,7 +196,6 @@ export function SettingsPage({ onUnsavedChangesChange, onResetRequest }: Setting
|
||||
void loadDefaults();
|
||||
void loadDependencyStatus();
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const syncCustomFonts = async () => {
|
||||
const customFonts = await loadCustomFonts();
|
||||
@@ -224,14 +204,12 @@ export function SettingsPage({ onUnsavedChangesChange, onResetRequest }: Setting
|
||||
};
|
||||
void syncCustomFonts();
|
||||
}, []);
|
||||
|
||||
const handleSave = () => {
|
||||
saveSettings(tempSettings);
|
||||
setSavedSettings(tempSettings);
|
||||
toast.success("Settings saved");
|
||||
onUnsavedChangesChange?.(false);
|
||||
};
|
||||
|
||||
const handleReset = async () => {
|
||||
const defaultSettings = await resetToDefaultSettings();
|
||||
setTempSettings(defaultSettings);
|
||||
@@ -242,7 +220,6 @@ export function SettingsPage({ onUnsavedChangesChange, onResetRequest }: Setting
|
||||
setShowResetConfirm(false);
|
||||
toast.success("Settings reset to default");
|
||||
};
|
||||
|
||||
const handleBrowseFolder = async () => {
|
||||
try {
|
||||
const selectedPath = await SelectFolder(tempSettings.downloadPath || "");
|
||||
@@ -255,12 +232,10 @@ export function SettingsPage({ onUnsavedChangesChange, onResetRequest }: Setting
|
||||
toast.error(`Error selecting folder: ${error}`);
|
||||
}
|
||||
};
|
||||
|
||||
const closeAddFontDialog = () => {
|
||||
setShowAddFontDialog(false);
|
||||
setAddFontUrl("");
|
||||
};
|
||||
|
||||
const handleAddFont = async () => {
|
||||
if (!parsedAddFont) {
|
||||
toast.error("Enter a valid Google Fonts URL");
|
||||
@@ -281,7 +256,6 @@ export function SettingsPage({ onUnsavedChangesChange, onResetRequest }: Setting
|
||||
closeAddFontDialog();
|
||||
toast.success(`${parsedAddFont.label} added`);
|
||||
};
|
||||
|
||||
const handleDeleteCustomFont = async (fontValue: CustomFontFamily) => {
|
||||
const customFonts = (tempSettings.customFonts || []).filter((font) => font.value !== fontValue);
|
||||
const savedCustomFonts = await saveCustomFonts(customFonts);
|
||||
@@ -303,7 +277,6 @@ export function SettingsPage({ onUnsavedChangesChange, onResetRequest }: Setting
|
||||
}
|
||||
toast.success("Font deleted");
|
||||
};
|
||||
|
||||
const handleDownloadExtractor = async () => {
|
||||
setDownloadingExtractor(true);
|
||||
try {
|
||||
@@ -324,7 +297,6 @@ export function SettingsPage({ onUnsavedChangesChange, onResetRequest }: Setting
|
||||
setDownloadingExtractor(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleDownloadFFmpeg = async () => {
|
||||
setDownloadingFFmpeg(true);
|
||||
try {
|
||||
@@ -345,7 +317,6 @@ export function SettingsPage({ onUnsavedChangesChange, onResetRequest }: Setting
|
||||
setDownloadingFFmpeg(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleDownloadExifTool = async () => {
|
||||
setDownloadingExifTool(true);
|
||||
try {
|
||||
@@ -366,7 +337,6 @@ export function SettingsPage({ onUnsavedChangesChange, onResetRequest }: Setting
|
||||
setDownloadingExifTool(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (<div className="space-y-4">
|
||||
<div className="flex items-center justify-between">
|
||||
<h1 className="text-2xl font-bold">Settings</h1>
|
||||
@@ -391,6 +361,10 @@ export function SettingsPage({ onUnsavedChangesChange, onResetRequest }: Setting
|
||||
<Download className="h-4 w-4"/>
|
||||
Downloads
|
||||
</Button>
|
||||
<Button variant={activeTab === "naming" ? "default" : "ghost"} size="sm" onClick={() => setActiveTab("naming")} className="rounded-b-none gap-2">
|
||||
<FileSignature className="h-4 w-4"/>
|
||||
Naming
|
||||
</Button>
|
||||
<Button variant={activeTab === "dependencies" ? "default" : "ghost"} size="sm" onClick={() => setActiveTab("dependencies")} className="rounded-b-none gap-2">
|
||||
<PackageSearch className="h-4 w-4"/>
|
||||
Dependencies
|
||||
@@ -490,28 +464,54 @@ export function SettingsPage({ onUnsavedChangesChange, onResetRequest }: Setting
|
||||
</div>
|
||||
|
||||
<div className="space-y-4">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="concurrent-downloads" className="flex items-center gap-2">
|
||||
Concurrent Downloads
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<Info className="h-3.5 w-3.5 cursor-help text-muted-foreground"/>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="top">
|
||||
<p>How many media files can download at the same time.</p>
|
||||
</TooltipContent>
|
||||
<div className="flex flex-wrap gap-6">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="concurrent-downloads" className="flex items-center gap-2">
|
||||
Concurrent Downloads
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<Info className="h-3.5 w-3.5 cursor-help text-muted-foreground"/>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="top">
|
||||
<p>How many media files can download at the same time.</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
</Label>
|
||||
<Select value={String(tempSettings.concurrentDownloads || 10)} onValueChange={(value) => setTempSettings((prev) => ({ ...prev, concurrentDownloads: parseInt(value, 10) }))}>
|
||||
<SelectTrigger id="concurrent-downloads" className="w-28">
|
||||
<SelectValue placeholder="10"/>
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{[1, 2, 3, 5, 8, 10, 15, 20, 25, 30, 40, 50].map((value) => (<SelectItem key={value} value={String(value)}>
|
||||
{value}
|
||||
</SelectItem>))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<Select value={String(tempSettings.concurrentDownloads || 10)} onValueChange={(value) => setTempSettings((prev) => ({ ...prev, concurrentDownloads: parseInt(value, 10) }))}>
|
||||
<SelectTrigger id="concurrent-downloads" className="w-fit">
|
||||
<SelectValue placeholder="10"/>
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{[1, 2, 3, 5, 8, 10, 15, 20, 25, 30, 40, 50].map((value) => (<SelectItem key={value} value={String(value)}>
|
||||
{value}
|
||||
</SelectItem>))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="retry-attempts" className="flex items-center gap-2">
|
||||
Retry Attempts
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<Info className="h-3.5 w-3.5 cursor-help text-muted-foreground"/>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="top">
|
||||
<p>How many times to retry a failed download before giving up.</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
</Label>
|
||||
<Select value={String(tempSettings.retryAttempts)} onValueChange={(value) => setTempSettings((prev) => ({ ...prev, retryAttempts: parseInt(value, 10) }))}>
|
||||
<SelectTrigger id="retry-attempts" className="w-fit">
|
||||
<SelectValue placeholder="1"/>
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{[1, 2, 3, 4, 5].map((value) => (<SelectItem key={value} value={String(value)}>
|
||||
{value}
|
||||
</SelectItem>))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center justify-between gap-4">
|
||||
@@ -523,20 +523,6 @@ export function SettingsPage({ onUnsavedChangesChange, onResetRequest }: Setting
|
||||
<Label htmlFor="delete-incomplete-files" className="cursor-pointer">Delete Incomplete Files</Label>
|
||||
<Switch id="delete-incomplete-files" checked={tempSettings.deleteIncompleteFiles} onCheckedChange={(checked) => setTempSettings((prev) => ({ ...prev, deleteIncompleteFiles: checked }))}/>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center justify-between gap-4">
|
||||
<Label htmlFor="retry-attempts">Retry Attempts</Label>
|
||||
<Select value={String(tempSettings.retryAttempts)} onValueChange={(value) => setTempSettings((prev) => ({ ...prev, retryAttempts: parseInt(value, 10) }))}>
|
||||
<SelectTrigger id="retry-attempts" className="w-24">
|
||||
<SelectValue placeholder="1"/>
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{[1, 2, 3, 4, 5].map((value) => (<SelectItem key={value} value={String(value)}>
|
||||
{value}
|
||||
</SelectItem>))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -606,49 +592,56 @@ export function SettingsPage({ onUnsavedChangesChange, onResetRequest }: Setting
|
||||
</Label>
|
||||
<div className="flex items-center justify-between gap-4">
|
||||
<Label htmlFor="gif-quality" className={!ffmpegInstalled ? "text-muted-foreground" : undefined}>GIF Quality</Label>
|
||||
<Select value={tempSettings.gifQuality} onValueChange={(value: GifQuality) => {
|
||||
setTempSettings((prev) => ({
|
||||
...prev,
|
||||
gifQuality: value,
|
||||
}));
|
||||
}} disabled={!ffmpegInstalled}>
|
||||
<SelectTrigger id="gif-quality" className="w-fit">
|
||||
<SelectValue placeholder="Select quality"/>
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="fast">Fast</SelectItem>
|
||||
<SelectItem value="better">Better</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center justify-between gap-4">
|
||||
<Label htmlFor="gif-resolution" className={!ffmpegInstalled ? "text-muted-foreground" : undefined}>Resolution</Label>
|
||||
<Select value={tempSettings.gifResolution} onValueChange={(value: GifResolution) => setTempSettings((prev) => ({ ...prev, gifResolution: value }))} disabled={!ffmpegInstalled}>
|
||||
<SelectTrigger id="gif-resolution" className="w-fit">
|
||||
<SelectValue placeholder="Resolution"/>
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="original">Original</SelectItem>
|
||||
<SelectItem value="high">High (800px)</SelectItem>
|
||||
<SelectItem value="medium">Medium (600px)</SelectItem>
|
||||
<SelectItem value="low">Low (400px)</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<div className="flex items-center gap-2">
|
||||
<Select value={tempSettings.gifQuality} onValueChange={(value: GifQuality) => {
|
||||
setTempSettings((prev) => ({
|
||||
...prev,
|
||||
gifQuality: value,
|
||||
}));
|
||||
}} disabled={!ffmpegInstalled}>
|
||||
<SelectTrigger id="gif-quality" className="w-fit">
|
||||
<SelectValue placeholder="Select quality"/>
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="fast">Fast</SelectItem>
|
||||
<SelectItem value="better">Better</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<Select value={tempSettings.gifResolution} onValueChange={(value: GifResolution) => setTempSettings((prev) => ({ ...prev, gifResolution: value }))} disabled={!ffmpegInstalled}>
|
||||
<SelectTrigger id="gif-resolution" className="w-fit">
|
||||
<SelectValue placeholder="Resolution"/>
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="original">Original</SelectItem>
|
||||
<SelectItem value="high">High (800px)</SelectItem>
|
||||
<SelectItem value="medium">Medium (600px)</SelectItem>
|
||||
<SelectItem value="low">Low (400px)</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>)}
|
||||
|
||||
{activeTab === "naming" && (<div className="grid grid-cols-1 gap-6 md:grid-cols-2 md:gap-8 items-start">
|
||||
<div className="md:pr-8 md:border-r border-border">
|
||||
<FormatEditor title="Folder" value={tempSettings.folderTemplate} defaultValue={DEFAULT_FOLDER_TEMPLATE} tokens={FOLDER_TEMPLATE_VARIABLES} placeholder={DEFAULT_FOLDER_TEMPLATE} render={(t) => renderFolderTemplate(t, SAMPLE_FOLDER_DATA)} onChange={(next) => setTempSettings((prev) => ({ ...prev, folderTemplate: next }))}/>
|
||||
</div>
|
||||
<div>
|
||||
<FormatEditor title="Filename" value={tempSettings.filenameTemplate} defaultValue={DEFAULT_FILENAME_TEMPLATE} tokens={FILENAME_TEMPLATE_VARIABLES} placeholder={DEFAULT_FILENAME_TEMPLATE} suffix=".jpg" render={(t) => renderFilenameTemplate(t, SAMPLE_FILENAME_DATA)} onChange={(next) => setTempSettings((prev) => ({ ...prev, filenameTemplate: next }))}/>
|
||||
</div>
|
||||
</div>)}
|
||||
|
||||
{activeTab === "dependencies" && (<div className="grid grid-cols-1 gap-4 md:grid-cols-2">
|
||||
<div className="space-y-4">
|
||||
<div className="space-y-2">
|
||||
<Label className="flex flex-wrap items-center gap-2">
|
||||
<span>Core Xtractor</span>
|
||||
{extractorVersionText && (<span className={extractorUpdateAvailable
|
||||
? "text-xs font-normal text-amber-600 dark:text-amber-400"
|
||||
: "text-xs font-normal text-muted-foreground"}>
|
||||
? "text-xs font-normal text-amber-600 dark:text-amber-400"
|
||||
: "text-xs font-normal text-muted-foreground"}>
|
||||
{extractorVersionText}
|
||||
</span>)}
|
||||
<Tooltip>
|
||||
@@ -681,8 +674,8 @@ export function SettingsPage({ onUnsavedChangesChange, onResetRequest }: Setting
|
||||
<Label className="flex flex-wrap items-center gap-2">
|
||||
<span>GIF Conversion</span>
|
||||
{ffmpegVersionText && (<span className={ffmpegUpdateAvailable
|
||||
? "text-xs font-normal text-amber-600 dark:text-amber-400"
|
||||
: "text-xs font-normal text-muted-foreground"}>
|
||||
? "text-xs font-normal text-amber-600 dark:text-amber-400"
|
||||
: "text-xs font-normal text-muted-foreground"}>
|
||||
{ffmpegVersionText}
|
||||
</span>)}
|
||||
<Tooltip>
|
||||
@@ -715,8 +708,8 @@ export function SettingsPage({ onUnsavedChangesChange, onResetRequest }: Setting
|
||||
<Label className="flex flex-wrap items-center gap-2">
|
||||
<span>Metadata Embedding</span>
|
||||
{exiftoolVersionText && (<span className={exiftoolUpdateAvailable
|
||||
? "text-xs font-normal text-amber-600 dark:text-amber-400"
|
||||
: "text-xs font-normal text-muted-foreground"}>
|
||||
? "text-xs font-normal text-amber-600 dark:text-amber-400"
|
||||
: "text-xs font-normal text-muted-foreground"}>
|
||||
{exiftoolVersionText}
|
||||
</span>)}
|
||||
<Tooltip>
|
||||
|
||||
@@ -5,12 +5,9 @@ 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";
|
||||
|
||||
export function SupportPage() {
|
||||
const [copiedUsdt, setCopiedUsdt] = useState(false);
|
||||
|
||||
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">
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
import { X, Minus, Maximize } from "lucide-react";
|
||||
import { X, Minus, Maximize, Info, Puzzle, FileCode2, Globe } from "lucide-react";
|
||||
import { WindowMinimise, WindowToggleMaximise, Quit } from "../../wailsjs/runtime/runtime";
|
||||
import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem } from "@/components/ui/dropdown-menu";
|
||||
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" },
|
||||
];
|
||||
export function TitleBar() {
|
||||
const handleMinimize = () => {
|
||||
WindowMinimise();
|
||||
@@ -11,18 +18,31 @@ export function TitleBar() {
|
||||
Quit();
|
||||
};
|
||||
return (<>
|
||||
|
||||
|
||||
<div className="fixed top-0 left-14 right-0 h-10 z-40 bg-background/80 backdrop-blur-sm" style={{ "--wails-draggable": "drag" } as React.CSSProperties} onDoubleClick={handleMaximize}/>
|
||||
|
||||
|
||||
<div className="fixed top-1.5 right-2 z-50 flex h-7 gap-0.5">
|
||||
<button onClick={handleMinimize} className="w-8 h-7 flex items-center justify-center hover:bg-muted transition-colors rounded" style={{ "--wails-draggable": "no-drag" } as React.CSSProperties} aria-label="Minimize">
|
||||
|
||||
|
||||
<div className="fixed top-1.5 right-2 z-50 flex h-7 gap-0.5" style={{ "--wails-draggable": "no-drag" } as React.CSSProperties}>
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<button className="w-8 h-7 flex items-center justify-center hover:bg-muted transition-colors rounded" aria-label="Info">
|
||||
<Info className="w-3.5 h-3.5"/>
|
||||
</button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end">
|
||||
{INFO_LINKS.map(({ label, icon: Icon, url }) => (<DropdownMenuItem key={label} onClick={() => openExternal(url)} className="gap-2 cursor-pointer">
|
||||
<Icon className="w-4 h-4 text-muted-foreground"/>
|
||||
{label}
|
||||
</DropdownMenuItem>))}
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
<button onClick={handleMinimize} className="w-8 h-7 flex items-center justify-center hover:bg-muted transition-colors rounded" aria-label="Minimize">
|
||||
<Minus className="w-3.5 h-3.5"/>
|
||||
</button>
|
||||
<button onClick={handleMaximize} className="w-8 h-7 flex items-center justify-center hover:bg-muted transition-colors rounded" style={{ "--wails-draggable": "no-drag" } as React.CSSProperties} aria-label="Maximize">
|
||||
<button onClick={handleMaximize} className="w-8 h-7 flex items-center justify-center hover:bg-muted transition-colors rounded" aria-label="Maximize">
|
||||
<Maximize className="w-3.5 h-3.5"/>
|
||||
</button>
|
||||
<button onClick={handleClose} className="w-8 h-7 flex items-center justify-center hover:bg-destructive hover:text-white transition-colors rounded" style={{ "--wails-draggable": "no-drag" } as React.CSSProperties} aria-label="Close">
|
||||
<button onClick={handleClose} className="w-8 h-7 flex items-center justify-center hover:bg-destructive hover:text-white transition-colors rounded" aria-label="Close">
|
||||
<X className="w-3.5 h-3.5"/>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -1,19 +1,14 @@
|
||||
"use client";
|
||||
|
||||
import type { Transition, Variants } from "motion/react";
|
||||
import { AnimatePresence, motion } from "motion/react";
|
||||
import { useEffect, useState, type HTMLAttributes } from "react";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
type ReportIconMode = "bug" | "bulb";
|
||||
|
||||
interface BugReportIconProps extends HTMLAttributes<HTMLDivElement> {
|
||||
size?: number;
|
||||
loop?: boolean;
|
||||
}
|
||||
|
||||
const LOOP_INTERVAL_MS = 2200;
|
||||
|
||||
const GROUP_VARIANTS: Variants = {
|
||||
hidden: {
|
||||
opacity: 0,
|
||||
@@ -33,7 +28,6 @@ const GROUP_VARIANTS: Variants = {
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const DRAW_VARIANTS: Variants = {
|
||||
hidden: {
|
||||
pathLength: 0,
|
||||
@@ -48,7 +42,6 @@ const DRAW_VARIANTS: Variants = {
|
||||
opacity: 0,
|
||||
},
|
||||
};
|
||||
|
||||
function createDrawTransition(delay = 0, duration = 0.36): Transition {
|
||||
return {
|
||||
duration,
|
||||
@@ -57,7 +50,6 @@ function createDrawTransition(delay = 0, duration = 0.36): Transition {
|
||||
opacity: { delay },
|
||||
};
|
||||
}
|
||||
|
||||
function BugPaths() {
|
||||
return (<>
|
||||
<motion.path d="m8 2 1.88 1.88" transition={createDrawTransition(0)} variants={DRAW_VARIANTS}/>
|
||||
@@ -73,7 +65,6 @@ function BugPaths() {
|
||||
<motion.path d="M3 21a4 4 0 0 1 3.81-4" transition={createDrawTransition(0.56)} variants={DRAW_VARIANTS}/>
|
||||
</>);
|
||||
}
|
||||
|
||||
function BulbPaths() {
|
||||
return (<>
|
||||
<motion.path d="M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5" transition={createDrawTransition(0, 0.46)} variants={DRAW_VARIANTS}/>
|
||||
@@ -81,13 +72,13 @@ function BulbPaths() {
|
||||
<motion.path d="M10 22h4" transition={createDrawTransition(0.24)} variants={DRAW_VARIANTS}/>
|
||||
</>);
|
||||
}
|
||||
|
||||
function ReportIconGroup({ mode }: { mode: ReportIconMode; }) {
|
||||
function ReportIconGroup({ mode }: {
|
||||
mode: ReportIconMode;
|
||||
}) {
|
||||
return (<motion.g animate="visible" exit="exit" initial="hidden" variants={GROUP_VARIANTS}>
|
||||
{mode === "bug" ? <BugPaths /> : <BulbPaths />}
|
||||
</motion.g>);
|
||||
}
|
||||
|
||||
function StaticBugIcon() {
|
||||
return (<g>
|
||||
<path d="m8 2 1.88 1.88"/>
|
||||
@@ -103,29 +94,23 @@ function StaticBugIcon() {
|
||||
<path d="M3 21a4 4 0 0 1 3.81-4"/>
|
||||
</g>);
|
||||
}
|
||||
|
||||
function BugReportIcon({ className, size = 28, loop = false, ...props }: BugReportIconProps) {
|
||||
const [mode, setMode] = useState<ReportIconMode>("bug");
|
||||
|
||||
useEffect(() => {
|
||||
if (!loop) {
|
||||
return;
|
||||
}
|
||||
|
||||
const intervalId = window.setInterval(() => {
|
||||
setMode((currentMode) => currentMode === "bug" ? "bulb" : "bug");
|
||||
}, LOOP_INTERVAL_MS);
|
||||
|
||||
return () => window.clearInterval(intervalId);
|
||||
}, [loop]);
|
||||
|
||||
return (<div className={cn("flex items-center justify-center", className)} {...props}>
|
||||
<svg fill="none" height={size} stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" viewBox="0 0 24 24" width={size} xmlns="http://www.w3.org/2000/svg">
|
||||
{loop ? (<AnimatePresence>
|
||||
<ReportIconGroup key={mode} mode={mode} />
|
||||
<ReportIconGroup key={mode} mode={mode}/>
|
||||
</AnimatePresence>) : (<StaticBugIcon />)}
|
||||
</svg>
|
||||
</div>);
|
||||
}
|
||||
|
||||
export { BugReportIcon };
|
||||
Reference in new issue
Block a user