Skip to content

Search result models #993

Description

@sigma67

Part of #307. Base branch: ytmusicapi-2. Read the contributor guide from #982 before starting.

The hardest Phase 2 issue and the one that depends on all three core entity models. Best picked up once #983#985 have landed and a few other Phase 2 issues have shaken out the patterns.

Scope

  • search in mixins/search.py — results across all filters: songs, videos, albums, artists, playlists, podcasts, episodes, profiles, community playlists, featured playlists, uploads
  • get_search_suggestions, including detailed_runs=True, which currently returns list[str] | JsonList

Watch out for

  • The return type is a union discriminated by resultType. Model it so consumers can narrow on resultType and get the right fields — a single model with every field optional would defeat the point of this whole effort.
  • scope="library" and scope="uploads" return different shapes from the default scope.
  • ignore_spelling and the top-result shelf produce entries that differ from the regular result rows.
  • Podcast results without a browseId (test: skip podcast search results without a browseId #976) must stay tolerated.

Definition of done

  • Each resultType has a model and narrowing works in mypy.
  • get_search_suggestions is properly typed for both detailed_runs values, ideally via overloads like get_lyrics uses.
  • Tests cover every filter.
  • mypy --strict clean.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is neededv2-modelspydantic response models effort (#307)

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions