replace progress percentage with actual file size
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user