replace progress percentage with actual file size

This commit is contained in:
2026-03-04 23:58:11 -05:00
parent 3cac63ba82
commit 481c8d9bb6
4 changed files with 93 additions and 68 deletions

View File

@@ -48,9 +48,8 @@ func startAsyncDownload(s *discordgo.Session, i *discordgo.InteractionCreate, ur
// Handle progress and results asynchronously
go func() {
// First update the original ephemeral message with "Processing..."
_, err := s.InteractionResponseEdit(i.Interaction, &discordgo.WebhookEdit{
Content: ptr(fmt.Sprintf("Downloading video: %s", renderProgressBar(0))),
Content: ptr("⏬ downloading: starting..."),
})
if err != nil {
log.Printf("Error updating interaction: %v", err)
@@ -63,35 +62,28 @@ func startAsyncDownload(s *discordgo.Session, i *discordgo.InteractionCreate, ur
progressChan = nil
continue
}
var content string
if prog.Phase == "post-processing" {
phaseEmoji := "⚙️"
content := fmt.Sprintf("%s %s",
phaseEmoji,
prog.Phase)
_, err := s.InteractionResponseEdit(i.Interaction, &discordgo.WebhookEdit{
Content: ptr(content),
})
if err != nil {
log.Printf("Error updating progress: %v", err)
}
content = "⚙️ post-processing"
} else {
phaseEmoji := "⏬"
content := fmt.Sprintf("%s %s: %s [eta: %s]\n📄 %s",
phaseEmoji,
prog.Phase,
renderProgressBar(prog.PercentFloat),
prog.ETA,
prog.Filename)
_, err := s.InteractionResponseEdit(i.Interaction, &discordgo.WebhookEdit{
Content: ptr(content),
})
if err != nil {
log.Printf("Error updating progress: %v", err)
var progressStr string
if prog.DownloadedBytes > 0 {
progressStr = formatBytes(prog.DownloadedBytes) + " downloaded"
} else {
progressStr = "starting..."
}
content = fmt.Sprintf("Downloading Video: %s", progressStr)
}
_, err := s.InteractionResponseEdit(i.Interaction, &discordgo.WebhookEdit{
Content: ptr(content),
})
if err != nil {
log.Printf("Error updating progress: %v", err)
}
case result := <-resultChan:
// Handle completion
if result.Success {
_, err = s.FollowupMessageCreate(i.Interaction, false, &discordgo.WebhookParams{
Content: "📥 Video downloaded: " + result.URL,