summaryrefslogtreecommitdiff
path: root/internal/image
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-07-16 21:44:28 +0300
committerPaul Buetow <paul@buetow.org>2025-07-16 21:44:28 +0300
commite2e75315e5e7c3eaccdc38881bd2fa669bb9dda5 (patch)
treec751e8c9b4d1efd858310fba54451e791c67737b /internal/image
parent6b0b4c9ce28b88ab0abbff03c5f367d89ba97c89 (diff)
only one img per card
Diffstat (limited to 'internal/image')
-rw-r--r--internal/image/download.go84
-rw-r--r--internal/image/openai.go4
2 files changed, 2 insertions, 86 deletions
diff --git a/internal/image/download.go b/internal/image/download.go
index 7083a6f..fabb1bb 100644
--- a/internal/image/download.go
+++ b/internal/image/download.go
@@ -200,48 +200,6 @@ func sanitizeFileName(name string) string {
return sanitized
}
-// DownloadMultiple downloads multiple images for a query
-func (d *Downloader) DownloadMultiple(ctx context.Context, query string, count int) ([]string, error) {
- // Search for images
- opts := DefaultSearchOptions(query)
- opts.PerPage = count * 2 // Get extra in case some fail
-
- results, err := d.searcher.Search(ctx, opts)
- if err != nil {
- return nil, fmt.Errorf("search failed: %w", err)
- }
-
- if len(results) == 0 {
- return nil, fmt.Errorf("no images found for query: %s", query)
- }
-
- // Download up to 'count' images
- var downloaded []string
- for i, result := range results {
- if len(downloaded) >= count {
- break
- }
-
- // Generate filename
- filename := d.generateFileName(query, &result, i)
- outputPath := filepath.Join(d.options.OutputDir, filename)
-
- // Try to download
- err := d.DownloadImage(ctx, &result, outputPath)
- if err == nil {
- downloaded = append(downloaded, outputPath)
- } else {
- // Log error and continue
- fmt.Fprintf(os.Stderr, "Warning: failed to download image %d: %v\n", i+1, err)
- }
- }
-
- if len(downloaded) == 0 {
- return nil, fmt.Errorf("failed to download any images for query: %s", query)
- }
-
- return downloaded, nil
-}
// DownloadBestMatchWithOptions downloads the best matching image for given search options
func (d *Downloader) DownloadBestMatchWithOptions(ctx context.Context, opts *SearchOptions) (*SearchResult, string, error) {
@@ -277,45 +235,3 @@ func (d *Downloader) DownloadBestMatchWithOptions(ctx context.Context, opts *Sea
return nil, "", fmt.Errorf("failed to download any images for query: %s", opts.Query)
}
-// DownloadMultipleWithOptions downloads multiple images for given search options
-func (d *Downloader) DownloadMultipleWithOptions(ctx context.Context, opts *SearchOptions, count int) ([]string, error) {
- // Search for images
- searchOpts := *opts // Copy to avoid modifying original
- searchOpts.PerPage = count * 2 // Get extra in case some fail
-
- results, err := d.searcher.Search(ctx, &searchOpts)
- if err != nil {
- return nil, fmt.Errorf("search failed: %w", err)
- }
-
- if len(results) == 0 {
- return nil, fmt.Errorf("no images found for query: %s", opts.Query)
- }
-
- // Download up to 'count' images
- var downloaded []string
- for i, result := range results {
- if len(downloaded) >= count {
- break
- }
-
- // Generate filename
- filename := d.generateFileName(opts.Query, &result, i)
- outputPath := filepath.Join(d.options.OutputDir, filename)
-
- // Try to download
- err := d.DownloadImage(ctx, &result, outputPath)
- if err == nil {
- downloaded = append(downloaded, outputPath)
- } else {
- // Log error and continue
- fmt.Fprintf(os.Stderr, "Warning: failed to download image %d: %v\n", i+1, err)
- }
- }
-
- if len(downloaded) == 0 {
- return nil, fmt.Errorf("failed to download any images for query: %s", opts.Query)
- }
-
- return downloaded, nil
-} \ No newline at end of file
diff --git a/internal/image/openai.go b/internal/image/openai.go
index 2fbb043..dc82b90 100644
--- a/internal/image/openai.go
+++ b/internal/image/openai.go
@@ -261,7 +261,7 @@ func (c *OpenAIClient) createEducationalPrompt(bulgarianWord, englishTranslation
if creativeStyle := c.getCreativeStyleFromOpenAI(context.Background(), englishTranslation); creativeStyle != "" {
fmt.Printf(" Using OpenAI-suggested style: %s\n", creativeStyle)
return fmt.Sprintf(
- "Generate %s of: %s. "+
+ "Generate %s of %s. "+
"The image should be educational and suitable for language learning flashcards. "+
"Requirements: single main subject, plain background, clear and recognizable. "+
"IMPORTANT: No text whatsoever. Do not include any words, letters, typography, labels, captions, or writing of any kind. Image only, without any text elements.",
@@ -331,7 +331,7 @@ func (c *OpenAIClient) createEducationalPrompt(bulgarianWord, englishTranslation
// Create a simple, clear prompt for educational images
return fmt.Sprintf(
- "Generate a %s of: %s. "+
+ "Generate a %s of %s. "+
"The image should be educational and suitable for language learning flashcards. "+
"Requirements: single main subject, plain background, clear and recognizable. "+
"IMPORTANT: No text whatsoever. Do not include any words, letters, typography, labels, captions, or writing of any kind. Image only, without any text elements.",