Feature: support IMDb ID search#60
Conversation
|
@souocare is attempting to deploy a commit to the Jake Jarvis' projects Team on Vercel. A member of the Team first needs to authorize it. |
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
There was a problem hiding this comment.
2 issues found across 1 file
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/server/src/orpc/procedures/discover.ts">
<violation number="1" location="apps/server/src/orpc/procedures/discover.ts:257">
P3: This leaves stale commented-out search logic in the procedure, which makes the active IMDb branching harder to read and easier to let drift from the real implementation. Since the new ternary below replaces it, removing this block would keep the search flow clearer.</violation>
<violation number="2" location="apps/server/src/orpc/procedures/discover.ts:265">
P2: Type-filtered search can now return the wrong media kind for IMDb ID queries: with `input.type === "movie"`, a TV IMDb ID still comes back because the IMDb branch runs before the `type` branches and merges movie/TV results. Consider passing `type` into `searchByImdbId` or filtering its results to preserve the existing movie/TV search contract.</violation>
</file>
Architecture diagram
sequenceDiagram
participant UI as Client App
participant API as ORPC API Route
participant TMDB as TMDB Client
participant TMDBExt as TMDB External IDs API
Note over UI,TMDBExt: IMDB ID Search Flow
UI->>API: GET /discover/search?query=tt14688458&type=movie
API->>API: Validate query, extract search type
API->>API: Check if query matches IMDB ID pattern (alt branch)
alt IMDB ID query (e.g., tt14688458)
API->>TMDB: findByExternalId("tt14688458", "imdb_id")
TMDB->>TMDBExt: GET /find/{external_id}?external_source=imdb_id
TMDBExt-->>TMDB: { movie_results: [...], tv_results: [...] }
TMDB-->>API: Response with movie and TV results
API->>API: Map movie_results -> add media_type: "movie"
API->>API: Map tv_results -> add media_type: "tv"
API->>API: Merge results, set page=1, total_pages=1
API-->>UI: { page: 1, total_results: N, results: [...] }
else Normal text search
alt search type = movie
API->>TMDB: searchMovies("godfather", page)
TMDB-->>API: Movie search results
else search type = tv
API->>TMDB: searchTv("breaking bad", page)
TMDB-->>API: TV search results
else multi search
API->>TMDB: searchMulti("batman", page)
TMDB-->>API: Multi-type search results
end
API-->>UI: Standard paginated search results
end
Note over API: Both paths return same result shape<br/>(page, total_pages, total_results, results)
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| // ? await searchTv(query, input.page) | ||
| // : await searchMulti(query, input.page); | ||
|
|
||
| const raw = isImdbIdSearch(query) |
There was a problem hiding this comment.
P2: Type-filtered search can now return the wrong media kind for IMDb ID queries: with input.type === "movie", a TV IMDb ID still comes back because the IMDb branch runs before the type branches and merges movie/TV results. Consider passing type into searchByImdbId or filtering its results to preserve the existing movie/TV search contract.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/server/src/orpc/procedures/discover.ts, line 265:
<comment>Type-filtered search can now return the wrong media kind for IMDb ID queries: with `input.type === "movie"`, a TV IMDb ID still comes back because the IMDb branch runs before the `type` branches and merges movie/TV results. Consider passing `type` into `searchByImdbId` or filtering its results to preserve the existing movie/TV search contract.</comment>
<file context>
@@ -219,12 +254,21 @@ export const search = os.discover.search.use(authed).handler(async ({ input }) =
+ // ? await searchTv(query, input.page)
+ // : await searchMulti(query, input.page);
+
+ const raw = isImdbIdSearch(query)
+ ? await searchByImdbId(query)
+ : type === "movie"
</file context>
|
|
||
| const raw = | ||
| type === "movie" | ||
| // Old Results without seach by imdb id |
There was a problem hiding this comment.
P3: This leaves stale commented-out search logic in the procedure, which makes the active IMDb branching harder to read and easier to let drift from the real implementation. Since the new ternary below replaces it, removing this block would keep the search flow clearer.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/server/src/orpc/procedures/discover.ts, line 257:
<comment>This leaves stale commented-out search logic in the procedure, which makes the active IMDb branching harder to read and easier to let drift from the real implementation. Since the new ternary below replaces it, removing this block would keep the search flow clearer.</comment>
<file context>
@@ -219,12 +254,21 @@ export const search = os.discover.search.use(authed).handler(async ({ input }) =
- const raw =
- type === "movie"
+ // Old Results without seach by imdb id
+ // const raw =
+ // type === "movie"
</file context>
Summary
Adds support for searching by IMDb title ID in discover search.
When the query matches an IMDb title ID such as tt14688458, Sofa now uses TMDB’s external ID lookup and maps the returned movie/TV results into the same result shape used by normal discover search.
Regular text search behavior is unchanged.
Testing
Summary by cubic
Add IMDb ID search to Discover. If a query looks like an IMDb title ID (e.g., tt14688458), we use TMDB external ID lookup and return mapped movie/TV results. Regular text search is unchanged.
findByExternalId(..., "imdb_id")from@sofa/tmdb/client.movie_resultsandtv_resultsand return them in the same result shape as normal search (page, totals, media_type).Written for commit 93f5e85. Summary will update on new commits.