diff options
| author | dev | 2026-06-26 18:36:46 +0200 |
|---|---|---|
| committer | dev | 2026-06-26 18:36:46 +0200 |
| commit | 2d72767874f6972726ef09082373e6ac01da169a (patch) | |
| tree | 133dcc651e20c3137e158f6a78e938df6cb44fc1 | |
| parent | b8255840d99c1d0bd81db1a40afc74ab13bf8501 (diff) | |
| download | hnimdbbot-2d72767874f6972726ef09082373e6ac01da169a.tar.gz | |
feat: add license_short from Wikipedia license identifiermain
- Extract license.identifier (e.g. CC-BY-SA-4.0) into new
license_short column
- Warn if a license array has more than 1 entry (none seen yet)
- Include license_short IS NULL in getExistingWikiArticles query
| -rw-r--r-- | src/wikiarticle.go | 5 | ||||
| -rw-r--r-- | src/wikidata.go | 6 |
2 files changed, 8 insertions, 3 deletions
diff --git a/src/wikiarticle.go b/src/wikiarticle.go index 09c2da8..19f612c 100644 --- a/src/wikiarticle.go +++ b/src/wikiarticle.go @@ -26,6 +26,7 @@ type wikiArticleEntry struct { PosterURL string Synopsis string License string + LicenseShort string LicenseURL string NumAccolades int People []wikiPerson @@ -100,8 +101,12 @@ func (a *App) queryWikiArticle(name string) (wikiArticleEntry, int, error) { // license if licList, ok := article["license"]; ok { if arr, ok := licList.([]interface{}); ok && len(arr) > 0 { + if len(arr) > 1 { + logWarn("license array has %d entries, using first (article %s)", len(arr), name) + } if lic, ok := arr[0].(map[string]interface{}); ok { entry.License = fmt.Sprintf("%v", lic["name"]) + entry.LicenseShort = fmt.Sprintf("%v", lic["identifier"]) entry.LicenseURL = fmt.Sprintf("%v", lic["url"]) } } diff --git a/src/wikidata.go b/src/wikidata.go index 3101673..5175d52 100644 --- a/src/wikidata.go +++ b/src/wikidata.go @@ -125,7 +125,7 @@ func (a *App) getExistingWikiArticles() ([]existingWikiArticle, error) { WHERE wiki_article IS NOT NULL AND wiki_status_code != 404 AND (synopsis IS NULL OR description IS NULL OR year IS NULL - OR poster_url IS NULL OR license IS NULL OR license_url IS NULL OR num_accolades IS NULL OR has_people = 0) + OR poster_url IS NULL OR license IS NULL OR license_short IS NULL OR license_url IS NULL OR num_accolades IS NULL OR has_people = 0) `) if err != nil { return nil, fmt.Errorf("query existing wiki articles: %w", err) @@ -254,10 +254,10 @@ func (a *App) wikiDataConsumer(artCh <-chan wikiArticleFetch, done chan<- struct if statusCode == 200 { a.DB.Exec(` UPDATE imdb SET synopsis = ?, description = ?, year = ?, poster_url = ?, - license = ?, license_url = ?, num_accolades = ? + license = ?, license_short = ?, license_url = ?, num_accolades = ? WHERE imdb_id = ?`, entry.Synopsis, entry.Description, entry.Year, entry.PosterURL, - entry.License, entry.LicenseURL, entry.NumAccolades, art.imdbID) + entry.License, entry.LicenseShort, entry.LicenseURL, entry.NumAccolades, art.imdbID) updated++ } |
