Improve source parsing from Envato and Artgrid HTML
build-push / docker (push) Successful in 4m28s

This commit is contained in:
AI Assistant
2026-03-13 19:03:21 +09:00
parent 06ea4f3ecd
commit ae091c5a7d
3 changed files with 141 additions and 3 deletions
+19
View File
@@ -30,3 +30,22 @@ func TestIsUsefulGoogleVideoResultRejectsMusicResults(t *testing.T) {
t.Fatal("expected bgm/music result to be rejected")
}
}
func TestExtractVideoObjectJSONLD(t *testing.T) {
html := `<script type="application/ld+json">{"@context":"https://schema.org","@type":"VideoObject","name":"Smiling Man and Woman Waving at Camera","description":"Close up shot of a smiling couple waving.","thumbnailUrl":"https://elements-resized.envatousercontent.com/example/video_preview/video_preview_0001.jpg","contentUrl":"https://video-previews.elements.envatousercontent.com/example/watermarked_preview/watermarked_preview.mp4"}</script>`
meta := extractVideoObjectJSONLD(html)
if meta.Name != "Smiling Man and Woman Waving at Camera" {
t.Fatalf("unexpected name: %#v", meta)
}
if meta.ContentURL == "" || meta.ThumbnailURL == "" || meta.Description == "" {
t.Fatalf("expected full video object metadata, got %#v", meta)
}
}
func TestCleanArtgridTitle(t *testing.T) {
got := cleanArtgridTitle("movie film moving slowly from a reel by Arthur Cauty | Royalty Free Stock Footage Artgrid.io")
want := "movie film moving slowly from a reel"
if got != want {
t.Fatalf("expected %q, got %q", want, got)
}
}