From 1f378bb3567db52613cde785a4623b55b976f125 Mon Sep 17 00:00:00 2001 From: afkarxyz Date: Wed, 29 Jul 2026 14:59:28 +0700 Subject: [PATCH] v5.0.0 --- README.md | 2 +- backend/twitter.go | 70 +++++++++++---------------- frontend/src/App.tsx | 5 +- frontend/src/components/MediaList.tsx | 2 +- wails.json | 2 +- 5 files changed, 36 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index 4612ecb..931a053 100644 --- a/README.md +++ b/README.md @@ -50,4 +50,4 @@ 5. Find and copy the `auth_token` value 6. Do not log out of your account, as a new `auth_token` will be generated by Twitter -![image](https://github.com/user-attachments/assets/8e81dd8f-f8be-4254-9cf6-cacfa97743e9) +![image](https://github.com/user-attachments/assets/8e81dd8f-f8be-4254-9cf6-cacfa97743e9) \ No newline at end of file diff --git a/backend/twitter.go b/backend/twitter.go index ee0cc86..9ec71d2 100644 --- a/backend/twitter.go +++ b/backend/twitter.go @@ -41,21 +41,33 @@ func unregisterExtractorCommand(cmd *exec.Cmd) { activeExtractorCommands.Unlock() } -func runTrackedExtractorCommand(cmd *exec.Cmd) ([]byte, error) { - var output bytes.Buffer - cmd.Stdout = &output - cmd.Stderr = &output +func runTrackedExtractorCommand(cmd *exec.Cmd) (stdout, stderr []byte, err error) { + var stdoutBuffer bytes.Buffer + var stderrBuffer bytes.Buffer + cmd.Stdout = &stdoutBuffer + cmd.Stderr = &stderrBuffer hideWindow(cmd) if err := cmd.Start(); err != nil { - return nil, err + return nil, nil, err } registerExtractorCommand(cmd) defer unregisterExtractorCommand(cmd) - err := cmd.Wait() - return output.Bytes(), err + err = cmd.Wait() + return stdoutBuffer.Bytes(), stderrBuffer.Bytes(), err +} + +func extractorErrorOutput(stdout, stderr []byte) string { + parts := make([]string, 0, 2) + if text := strings.TrimSpace(string(stderr)); text != "" { + parts = append(parts, text) + } + if text := strings.TrimSpace(string(stdout)); text != "" { + parts = append(parts, text) + } + return strings.Join(parts, "\n") } func getExecutableName() string { @@ -745,10 +757,10 @@ func ExtractTimeline(req TimelineRequest) (*TwitterResponse, error) { "PYTHONIOENCODING=utf-8", "PYTHONUTF8=1", ) - output, err := runTrackedExtractorCommand(cmd) + stdout, stderr, err := runTrackedExtractorCommand(cmd) if err != nil { - outputStr := string(output) + outputStr := extractorErrorOutput(stdout, stderr) if strings.TrimSpace(outputStr) == "" { return nil, fmt.Errorf("xtractor process terminated before returning data") } @@ -756,13 +768,12 @@ func ExtractTimeline(req TimelineRequest) (*TwitterResponse, error) { return nil, fmt.Errorf("%s", errorMsg) } - jsonStr := extractJSON(string(output)) + jsonStr := strings.TrimSpace(string(stdout)) if jsonStr == "" { - outputStr := string(output) - if strings.TrimSpace(outputStr) == "" { + if strings.TrimSpace(string(stderr)) == "" { return nil, fmt.Errorf("empty_response: Xtractor returned no data. The timeline may be empty or inaccessible") } - return nil, fmt.Errorf("parse_error: Could not parse xtractor output. Raw output: %s", outputStr) + return nil, fmt.Errorf("empty_response: Xtractor returned no JSON. Logs: %s", strings.TrimSpace(string(stderr))) } resp, err := parseRichResponse(jsonStr) @@ -847,10 +858,10 @@ func ExtractDateRange(req DateRangeRequest) (*TwitterResponse, error) { "PYTHONIOENCODING=utf-8", "PYTHONUTF8=1", ) - output, err := runTrackedExtractorCommand(cmd) + stdout, stderr, err := runTrackedExtractorCommand(cmd) if err != nil { - outputStr := string(output) + outputStr := extractorErrorOutput(stdout, stderr) if strings.TrimSpace(outputStr) == "" { return nil, fmt.Errorf("xtractor process terminated before returning data") } @@ -858,13 +869,12 @@ func ExtractDateRange(req DateRangeRequest) (*TwitterResponse, error) { return nil, fmt.Errorf("%s", errorMsg) } - jsonStr := extractJSON(string(output)) + jsonStr := strings.TrimSpace(string(stdout)) if jsonStr == "" { - outputStr := string(output) - if strings.TrimSpace(outputStr) == "" { + if strings.TrimSpace(string(stderr)) == "" { return nil, fmt.Errorf("empty_response: Xtractor returned no data. The timeline may be empty or inaccessible") } - return nil, fmt.Errorf("parse_error: Could not parse xtractor output. Raw output: %s", outputStr) + return nil, fmt.Errorf("empty_response: Xtractor returned no JSON. Logs: %s", strings.TrimSpace(string(stderr))) } resp, err := parseRichResponse(jsonStr) @@ -905,25 +915,3 @@ func getExtractorPath() string { baseDir := filepath.Join(homeDir, ".twitterxmediabatchdownloader") return filepath.Join(baseDir, getExecutableName()) } - -func extractJSON(output string) string { - - start := strings.Index(output, "{") - if start == -1 { - return "" - } - - depth := 0 - for i := start; i < len(output); i++ { - if output[i] == '{' { - depth++ - } else if output[i] == '}' { - depth-- - if depth == 0 { - return output[start : i+1] - } - } - } - - return "" -} diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 9f5f5cd..708d683 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1506,6 +1506,9 @@ function App() { ); } }; + const usesWideContent = currentPage === "main" + ? fetchType === "multiple" || !!result + : !["settings", "support"].includes(currentPage); return (
@@ -1514,7 +1517,7 @@ function App() {
-
+
{renderPage()}
diff --git a/frontend/src/components/MediaList.tsx b/frontend/src/components/MediaList.tsx index 8b11304..3f93376 100644 --- a/frontend/src/components/MediaList.tsx +++ b/frontend/src/components/MediaList.tsx @@ -853,7 +853,7 @@ export function MediaList({ accountInfo, timeline, totalUrls, fetchedMediaType =
); })} -
) : (
+
) : (
{filteredTimeline.slice(0, visibleCount).map((item, index) => { const itemKey = getItemKey(item); const isSelected = selectedItems.has(itemKey); diff --git a/wails.json b/wails.json index 87e63e2..1c32b8a 100644 --- a/wails.json +++ b/wails.json @@ -11,7 +11,7 @@ }, "info": { "productName": "Twitter/X Media Batch Downloader", - "productVersion": "4.9" + "productVersion": "5.0.0" }, "wailsjsdir": "./frontend", "assetdir": "./frontend/dist",