implement progress bar
This commit is contained in:
@@ -50,7 +50,7 @@ func startAsyncDownload(s *discordgo.Session, i *discordgo.InteractionCreate, ur
|
||||
go func() {
|
||||
// First update the original ephemeral message with "Processing..."
|
||||
_, err := s.InteractionResponseEdit(i.Interaction, &discordgo.WebhookEdit{
|
||||
Content: ptr(fmt.Sprintf("🔄 Processing download...\nURL: %s\nVideo: %s\nAudio: %s", url, videoFormatID, audioFormatID)),
|
||||
Content: ptr(fmt.Sprintf("Downloading video: %s", renderProgressBar(0))),
|
||||
})
|
||||
if err != nil {
|
||||
log.Printf("Error updating interaction: %v", err)
|
||||
@@ -63,24 +63,33 @@ func startAsyncDownload(s *discordgo.Session, i *discordgo.InteractionCreate, ur
|
||||
progressChan = nil
|
||||
continue
|
||||
}
|
||||
// Update message w/ phase and real time progress
|
||||
phaseEmoji := "⏬"
|
||||
if prog.Phase == "post-processing" {
|
||||
phaseEmoji = "⚙️"
|
||||
}
|
||||
content := fmt.Sprintf("%s %s\n%s @ %s [eta: %s]\n📄 %s",
|
||||
phaseEmoji,
|
||||
prog.Phase,
|
||||
prog.Status,
|
||||
prog.Percent,
|
||||
prog.ETA,
|
||||
prog.Filename)
|
||||
_, err := s.InteractionResponseEdit(i.Interaction, &discordgo.WebhookEdit{
|
||||
Content: ptr(content),
|
||||
})
|
||||
if err != nil {
|
||||
log.Printf("Error updating progress: %v", err)
|
||||
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)
|
||||
}
|
||||
} 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)
|
||||
}
|
||||
}
|
||||
|
||||
case result := <-resultChan:
|
||||
// Handle completion
|
||||
if result.Success {
|
||||
|
||||
Reference in New Issue
Block a user