mirror of
https://github.com/Alvin-Zilverstand/Twitter-X-Media-Batch-Downloader.git
synced 2026-11-27 16:47:56 +01:00
v4.9
This commit is contained in:
1 parent
3fb8bda2ff
commit
2ada5da9bf
12 files changed
+164
-116
No files matched your search
+20
-22
@@ -340,34 +340,32 @@ func DownloadMediaWithMetadataProgressAndStatus(items []MediaItem, outputDir str
|
||||
}
|
||||
|
||||
filenameIndexes := make(map[string]int, len(filenameCounts))
|
||||
tasks := make([]downloadTask, 0, len(pendingTasks))
|
||||
tasks := make([]downloadTask, 0, len(pendingTasks))
|
||||
|
||||
for _, pending := range pendingTasks {
|
||||
key := filenameCollisionKey(pending.typeDir, pending.baseName, pending.ext)
|
||||
for _, pending := range pendingTasks {
|
||||
key := filenameCollisionKey(pending.typeDir, pending.baseName, pending.ext)
|
||||
|
||||
filenameIndexes[key]++
|
||||
filenameIndexes[key]++
|
||||
|
||||
filename := formatDownloadFilename(
|
||||
pending.baseName,
|
||||
pending.ext,
|
||||
filenameCounts[key],
|
||||
filenameIndexes[key],
|
||||
)
|
||||
filename := formatDownloadFilename(
|
||||
pending.baseName,
|
||||
pending.ext,
|
||||
filenameCounts[key],
|
||||
filenameIndexes[key],
|
||||
)
|
||||
|
||||
// If skipping existing files, first check the canonical filename.
|
||||
// This prevents existing files from being downloaded again as _01, _02, etc.
|
||||
if options.SkipExistingFiles {
|
||||
canonicalPath := filepath.Join(pending.typeDir, formatDownloadFilename(pending.baseName, pending.ext, 1, 1))
|
||||
if exists, err := fileExists(canonicalPath); err == nil && exists {
|
||||
pending.task.outputPath = canonicalPath
|
||||
tasks = append(tasks, pending.task)
|
||||
continue
|
||||
if options.SkipExistingFiles {
|
||||
canonicalPath := filepath.Join(pending.typeDir, formatDownloadFilename(pending.baseName, pending.ext, 1, 1))
|
||||
if exists, err := fileExists(canonicalPath); err == nil && exists {
|
||||
pending.task.outputPath = canonicalPath
|
||||
tasks = append(tasks, pending.task)
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pending.task.outputPath = filepath.Join(pending.typeDir, filename)
|
||||
tasks = append(tasks, pending.task)
|
||||
}
|
||||
pending.task.outputPath = filepath.Join(pending.typeDir, filename)
|
||||
tasks = append(tasks, pending.task)
|
||||
}
|
||||
|
||||
var downloadedCount int64
|
||||
var skippedCount int64
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
func OpenFolderInExplorer(path string) error {
|
||||
os.WriteFile(filepath.Join(os.TempDir(), "openfolder.txt"), []byte(path), 0644)
|
||||
os.WriteFile(filepath.Join(os.TempDir(), "openfolder.txt"), []byte(path), 0644)
|
||||
info, err := os.Stat(path)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
+2
-3
@@ -698,11 +698,10 @@ func ExtractTimeline(req TimelineRequest) (*TwitterResponse, error) {
|
||||
}
|
||||
|
||||
includeText := req.IncludeText
|
||||
wantsRetweets := req.Retweets
|
||||
|
||||
timelineType := req.TimelineType
|
||||
if timelineType == "" {
|
||||
if includeText || wantsRetweets {
|
||||
if includeText {
|
||||
timelineType = "tweets"
|
||||
} else {
|
||||
timelineType = "media"
|
||||
@@ -725,7 +724,7 @@ func ExtractTimeline(req TimelineRequest) (*TwitterResponse, error) {
|
||||
args = append(args, "--limit", fmt.Sprintf("%d", req.BatchSize))
|
||||
}
|
||||
|
||||
if timelineType == "tweets" || timelineType == "timeline" {
|
||||
if timelineType == "tweets" || timelineType == "timeline" || timelineType == "media" {
|
||||
if req.Retweets {
|
||||
args = append(args, "--retweets", "include")
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user