format final video download message

This commit is contained in:
2026-03-05 19:35:13 -05:00
parent 6fd6160edf
commit 890a0dd5c9
3 changed files with 39 additions and 9 deletions

View File

@@ -93,6 +93,9 @@ func main() {
return
}
// Get requester user ID
state.Requester = i.User.ID
// Get selected video format
selectedValues := i.MessageComponentData().Values
if len(selectedValues) == 0 {
@@ -106,8 +109,19 @@ func main() {
return
}
// Store selected video format ID
// Store selected video format ID and name
state.VideoFormatID = selectedValues[0]
for _, vOpt := range state.FormatOptions.VideoOptions {
if vOpt.FormatID == selectedValues[0] {
label := fmt.Sprintf("%s (%s", vOpt.Resolution, vOpt.Ext)
if vOpt.TBR != nil {
label += fmt.Sprintf(", %.0fkbps", *vOpt.TBR)
}
label += ")"
state.VideoFormatName = label
break
}
}
setInteractionState(i.Interaction.Token, state)
// Build audio format options
@@ -240,8 +254,21 @@ func main() {
audioFormatID = selectedValues[0]
}
// Store selected audio format ID
// Store selected audio format ID and name
state.AudioFormatID = audioFormatID
for _, aOpt := range state.FormatOptions.AudioOptions {
if aOpt.FormatID == audioFormatID {
label := aOpt.Format
if aOpt.Language != nil {
label += fmt.Sprintf(" [%s]", *aOpt.Language)
}
if aOpt.TBR != nil {
label += fmt.Sprintf(" (%.0fkbps)", *aOpt.TBR)
}
state.AudioFormatName = label
break
}
}
response := ""
if state.URL != "" {
@@ -253,7 +280,7 @@ func main() {
go func() {
// Small delay to ensure response is sent first
time.Sleep(100 * time.Millisecond)
startAsyncDownload(s, i, state.URL, state.VideoFormatID, state.AudioFormatID, out_dir, temp_dir)
startAsyncDownload(s, i, state.Requester, state.URL, state.VideoFormatID, state.VideoFormatName, state.AudioFormatID, state.AudioFormatName, out_dir, temp_dir)
}()
// Clean up state after starting download