feat: add DRM search-by-name fallback for individual Spotify tracks

When SearchYoutube with the Spotify URL fails for individual tracks,
offer a 'Search on YouTube' button that lets the user enter a search
query (artist/song name) to find the content on YouTube.
This commit is contained in:
2026-06-25 16:10:37 +03:30
parent 0c27822871
commit 8408b17ca0
2 changed files with 25 additions and 1 deletions

View File

@@ -70,7 +70,15 @@ func (h *Handler) handleURLInput(ctx context.Context, chatID int64, text string,
if strings.Contains(errMsg, "DRM") {
youtubeURL, ytTitle, searchErr := h.YtDlp.SearchYoutube(text)
if searchErr != nil {
h.sendText(ctx, chatID, fmt.Sprintf("This content is DRM protected and no YouTube alternative was found: %s", errMsg))
kb := models.InlineKeyboardMarkup{
InlineKeyboard: [][]models.InlineKeyboardButton{
{{Text: "Search on YouTube", CallbackData: "drm_search"}},
{{Text: "Cancel", CallbackData: "pending_cancel"}},
},
}
h.Bot.SendMessage(ctx, &tgbot.SendMessageParams{
ChatID: chatID, Text: "This content is DRM protected and no YouTube alternative was found automatically. Try searching by name:", ReplyMarkup: kb,
})
return
}
h.sendText(ctx, chatID, fmt.Sprintf("This content is DRM protected. Found on YouTube: %s", ytTitle))