mirror of
https://github.com/Alvin-Zilverstand/Twitter-X-Media-Batch-Downloader.git
synced 2026-11-21 13:53:13 +01:00
v5.0.0
This commit is contained in:
1 parent
492a318399
commit
1f378bb356
5 files changed
+36
-45
No files matched your search
@@ -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
|
||||
|
||||

|
||||

|
||||
+29
-41
@@ -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 ""
|
||||
}
|
||||
@@ -1506,6 +1506,9 @@ function App() {
|
||||
</>);
|
||||
}
|
||||
};
|
||||
const usesWideContent = currentPage === "main"
|
||||
? fetchType === "multiple" || !!result
|
||||
: !["settings", "support"].includes(currentPage);
|
||||
return (<TooltipProvider>
|
||||
<div className="h-screen overflow-hidden bg-background">
|
||||
<DependencySetupDialog />
|
||||
@@ -1514,7 +1517,7 @@ function App() {
|
||||
|
||||
<div id="app-content-scroll" className="fixed top-10 right-0 bottom-0 left-14 overflow-y-auto overflow-x-hidden">
|
||||
<div className="p-4 md:p-8">
|
||||
<div className="max-w-5xl mx-auto">
|
||||
<div className={usesWideContent ? "w-full" : "max-w-5xl mx-auto"}>
|
||||
{renderPage()}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -853,7 +853,7 @@ export function MediaList({ accountInfo, timeline, totalUrls, fetchedMediaType =
|
||||
</div>
|
||||
</div>);
|
||||
})}
|
||||
</div>) : (<div className={`grid gap-3 ${viewMode === "large" ? "grid-cols-4" : "grid-cols-6"}`}>
|
||||
</div>) : (<div className={`grid gap-3 ${viewMode === "large" ? "grid-cols-[repeat(auto-fill,minmax(14rem,1fr))]" : "grid-cols-[repeat(auto-fill,minmax(10rem,1fr))]"}`}>
|
||||
{filteredTimeline.slice(0, visibleCount).map((item, index) => {
|
||||
const itemKey = getItemKey(item);
|
||||
const isSelected = selectedItems.has(itemKey);
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@
|
||||
},
|
||||
"info": {
|
||||
"productName": "Twitter/X Media Batch Downloader",
|
||||
"productVersion": "4.9"
|
||||
"productVersion": "5.0.0"
|
||||
},
|
||||
"wailsjsdir": "./frontend",
|
||||
"assetdir": "./frontend/dist",
|
||||
|
||||
Reference in new issue
Block a user