Ingest and self-host company/network logos
CI / lint (push) Canceled after 0s
CI / typecheck (push) Canceled after 0s
CI / unit-tests (push) Canceled after 0s
CI / integration-tests (push) Canceled after 0s
CI / container-build (push) Canceled after 0s
CI / dependency-audit (push) Canceled after 0s

CompanyBriefOut.logo_path and CompanyDetailOut.logo_path have existed
in the API schemas since Core 0.1's first pass, but nothing ever
actually populated them -- TMDb's production_companies/networks
entries carry a logo_path field that the normalizer simply never read,
so every response has silently returned null there.

- NormalizedCompanyRef now captures logo_path from both movie
  production_companies and series networks/production_companies.
- normalizer.company_logo_artwork() builds the single-image artwork
  entry for it (a company has exactly one logo ingested, so it's
  always is_primary) -- centralized there rather than duplicated in
  both ingestion modules, matching how movie/series artwork URLs are
  already built in one place.
- movie_ingestion.py and series_ingestion.py sync it via the same
  sync_artwork() the rest of section 10's self-hosting already uses,
  so it gets the same re-ingestion-safe upsert behavior for free.
- tasks.py cascades a download_artwork_task per referenced company
  after movie/series ingestion, same fan-out pattern as
  movie/series/season/person artwork.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
NixReaper
2026-09-05 07:46:30 -05:00
co-authored by Claude Sonnet 5
parent 69ce41d54f
commit c03a75989d
8 changed files with 133 additions and 8 deletions
+25
View File
@@ -11,6 +11,8 @@ import pytest
from sqlalchemy import select
from sqlalchemy.ext.asyncio import AsyncSession
from app.models.artwork import Artwork
from app.models.company import Company
from app.models.credit import Credit
from app.models.genre import Genre
from app.models.movie import Movie
@@ -103,3 +105,26 @@ async def test_ingest_movie_is_idempotent(db_session: AsyncSession):
)
# Credits are replaced wholesale on re-sync, not duplicated.
assert len(credits_) == 2 # 1 cast + 1 crew from FAKE_MOVIE
@pytest.mark.asyncio
async def test_ingest_movie_ingests_company_logo(db_session: AsyncSession):
provider = FakeTMDbProvider(FAKE_MOVIE)
await ingest_movie(db_session, provider, "603")
await db_session.commit()
company = (
await db_session.execute(
select(Company).where(Company.name == "Village Roadshow Pictures")
)
).scalar_one()
logo = (
await db_session.execute(
select(Artwork).where(Artwork.entity_type == "company", Artwork.entity_id == company.id)
)
).scalar_one()
assert logo.artwork_type.value == "logo"
assert logo.is_primary is True
assert logo.original_url.endswith("/village-roadshow-logo.png")