refactor: remove all playlist support, fix message ordering
All checks were successful
CI / build (push) Successful in 54s
All checks were successful
CI / build (push) Successful in 54s
- Remove playlist handler, keyboard, and all related callback routing - Strip playlist parameter from YouTube Music radio URLs, reject pure playlists - Send media preview before format selection prompt (correct ordering) - Remove DetectPlaylist/GetPlaylistInfo methods (no longer needed) - Remove IsPlaylist, PlaylistCount, PlaylistEntries from MediaInfo - Remove PlaylistState struct, keep PlaylistEntry for search results - Update README to reflect removal of playlist feature
This commit is contained in:
@@ -4,8 +4,6 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/go-telegram/bot/models"
|
||||
|
||||
"uptodownBot/internal/domain"
|
||||
)
|
||||
|
||||
func mainKeyboard() models.InlineKeyboardMarkup {
|
||||
@@ -82,87 +80,6 @@ func progressKeyboard(pct float64, speed, eta string) models.InlineKeyboardMarku
|
||||
}
|
||||
}
|
||||
|
||||
// playlistNavKeyboard builds the paginated navigation for playlist selection.
|
||||
func playlistNavKeyboard(state *domain.PlaylistState, selectedCount int) models.InlineKeyboardMarkup {
|
||||
totalPages := (len(state.Entries) + state.PerPage - 1) / state.PerPage
|
||||
if totalPages < 1 {
|
||||
totalPages = 1
|
||||
}
|
||||
|
||||
// Build entry rows (2 per row)
|
||||
rows := [][]models.InlineKeyboardButton{}
|
||||
start := state.Page * state.PerPage
|
||||
end := start + state.PerPage
|
||||
if end > len(state.Entries) {
|
||||
end = len(state.Entries)
|
||||
}
|
||||
|
||||
for i := start; i < end; i += 2 {
|
||||
row := []models.InlineKeyboardButton{}
|
||||
// First entry
|
||||
e := state.Entries[i]
|
||||
prefix := " "
|
||||
if state.Selected[e.ID] {
|
||||
prefix = "> "
|
||||
}
|
||||
// Truncate title for button
|
||||
title := e.Title
|
||||
if len(title) > 30 {
|
||||
title = title[:27] + "..."
|
||||
}
|
||||
row = append(row, models.InlineKeyboardButton{
|
||||
Text: prefix + title, CallbackData: "pl_entry_" + e.ID,
|
||||
})
|
||||
// Second entry if available
|
||||
if i+1 < end {
|
||||
e2 := state.Entries[i+1]
|
||||
prefix2 := " "
|
||||
if state.Selected[e2.ID] {
|
||||
prefix2 = "> "
|
||||
}
|
||||
title2 := e2.Title
|
||||
if len(title2) > 30 {
|
||||
title2 = title2[:27] + "..."
|
||||
}
|
||||
row = append(row, models.InlineKeyboardButton{
|
||||
Text: prefix2 + title2, CallbackData: "pl_entry_" + e2.ID,
|
||||
})
|
||||
}
|
||||
rows = append(rows, row)
|
||||
}
|
||||
|
||||
// Navigation row
|
||||
navRow := []models.InlineKeyboardButton{}
|
||||
navRow = append(navRow, models.InlineKeyboardButton{
|
||||
Text: "<", CallbackData: fmt.Sprintf("pl_page_%d", state.Page-1),
|
||||
})
|
||||
navRow = append(navRow, models.InlineKeyboardButton{
|
||||
Text: fmt.Sprintf("Page %d/%d", state.Page+1, totalPages), CallbackData: "noop",
|
||||
})
|
||||
navRow = append(navRow, models.InlineKeyboardButton{
|
||||
Text: ">", CallbackData: fmt.Sprintf("pl_page_%d", state.Page+1),
|
||||
})
|
||||
rows = append(rows, navRow)
|
||||
|
||||
// Action row
|
||||
actionRow := []models.InlineKeyboardButton{
|
||||
{Text: "Select All", CallbackData: "pl_select_all"},
|
||||
}
|
||||
if selectedCount > 0 {
|
||||
actionRow = append(actionRow, models.InlineKeyboardButton{
|
||||
Text: fmt.Sprintf("Confirm (%d)", selectedCount), CallbackData: "pl_confirm",
|
||||
})
|
||||
}
|
||||
rows = append(rows, actionRow)
|
||||
|
||||
// Cancel
|
||||
rows = append(rows, []models.InlineKeyboardButton{
|
||||
{Text: "Cancel", CallbackData: "cancel_dl"},
|
||||
})
|
||||
|
||||
return models.InlineKeyboardMarkup{InlineKeyboard: rows}
|
||||
}
|
||||
|
||||
// deleteConfirmKeyboard builds the confirmation prompt for account deletion.
|
||||
func deleteConfirmKeyboard(userID int64) models.InlineKeyboardMarkup {
|
||||
return models.InlineKeyboardMarkup{
|
||||
|
||||
Reference in New Issue
Block a user