Improve query intent handling and preview playback
build-push / docker (push) Successful in 4m52s

This commit is contained in:
AI Assistant
2026-03-16 09:55:14 +09:00
parent 6d9391bc2b
commit 9637b761bd
7 changed files with 142 additions and 12 deletions
+30
View File
@@ -229,6 +229,9 @@ func (s *SearchService) enrichArtgrid(result SearchResult) SearchResult {
if result.ThumbnailURL == "" || result.PreviewVideoURL == "" {
html, err := s.fetchText(result.Link)
if err == nil {
if !isMatchingArtgridClipPage(html, clipID) {
return result
}
result.Title = firstNonEmpty(
cleanArtgridTitle(extractMetaContent(html, "og:title")),
cleanArtgridTitle(extractMetaContent(html, "title")),
@@ -756,6 +759,33 @@ func cleanArtgridDescription(description string) string {
return strings.TrimSpace(description)
}
func isMatchingArtgridClipPage(html, clipID string) bool {
if clipID == "" {
return false
}
ogURL := extractMetaContent(html, "og:url")
canonical := extractCanonicalURL(html)
lowerHTML := strings.ToLower(html)
for _, candidate := range []string{ogURL, canonical} {
if strings.Contains(candidate, clipID) {
return true
}
}
if strings.Contains(lowerHTML, "main-clipvideo_"+clipID) || strings.Contains(lowerHTML, "/clip/"+clipID+"/") {
return true
}
return false
}
func extractCanonicalURL(html string) string {
pattern := regexp.MustCompile(`(?i)<link[^>]+rel=["']canonical["'][^>]+href=["']([^"']+)`)
matches := pattern.FindStringSubmatch(html)
if len(matches) == 2 {
return htmlUnescape(matches[1])
}
return ""
}
func deriveEnvatoPreviewFromThumbnail(thumbnail string) string {
candidate := htmlUnescape(strings.TrimSpace(thumbnail))
if candidate == "" {