Download tasks/imdb/environment/reference/clone/backend/catalog.py from TIGER-Lab/WebsiteBench: direct link, hf CLI and curl.
- Browser
- Download file 18.5 kB
-
https://huggingface.co/datasets/TIGER-Lab/WebsiteBench/resolve/main/tasks/imdb/environment/reference/clone/backend/catalog.py
- Command line
-
hf download hf://datasets/TIGER-Lab/WebsiteBench/tasks/imdb/environment/reference/clone/backend/catalog.py
-
curl -L -o catalog.py https://huggingface.co/datasets/TIGER-Lab/WebsiteBench/resolve/main/tasks/imdb/environment/reference/clone/backend/catalog.py
18.5 kB
| """Frozen, local-only IMDb directory expansion. | |
| The three task titles remain defined in :mod:`backend.db` so tasks 901–905 | |
| retain byte-for-byte identity. This module supplies the remainder of the | |
| fixed benchmark directory: 27 more movies, four series, two episodes and | |
| nineteen additional people (Danny Elfman remains the original twentieth | |
| person). All images resolve to the already-frozen local asset closure. | |
| """ | |
| from __future__ import annotations | |
| import json | |
| from pathlib import Path | |
| from typing import Any | |
| # id, title, year, type, certificate, runtime, aggregate, exact seed votes, | |
| # metascore, popularity, plot, director, stars, genres, parent, season, episode | |
| CATALOG_ROWS = ( | |
| ("tt0111161", "The Shawshank Redemption", "1994", "movie", "R", "2h 22m", 9.3, 3_100_000, "82", "47", "A banker sentenced to life in Shawshank forms an enduring friendship and finds a path to hope.", "Frank Darabont", "Tim Robbins, Morgan Freeman", ["Drama"], None, None, None), | |
| ("tt0068646", "The Godfather", "1972", "movie", "R", "2h 55m", 9.2, 2_200_000, "100", "58", "The aging patriarch of an organized crime dynasty transfers control to his reluctant son.", "Francis Ford Coppola", "Marlon Brando, Al Pacino", ["Crime", "Drama"], None, None, None), | |
| ("tt0137523", "Fight Club", "1999", "movie", "R", "2h 19m", 8.8, 2_500_000, "67", "76", "An insomniac office worker and a soap maker form an underground fight club.", "David Fincher", "Brad Pitt, Edward Norton", ["Drama"], None, None, None), | |
| ("tt0109830", "Forrest Gump", "1994", "movie", "PG-13", "2h 22m", 8.8, 2_400_000, "82", "64", "The life of a kindhearted Alabama man intersects with decades of American history.", "Robert Zemeckis", "Tom Hanks, Robin Wright", ["Drama", "Romance"], None, None, None), | |
| ("tt1375666", "Inception", "2010", "movie", "PG-13", "2h 28m", 8.8, 2_800_000, "74", "19", "A thief who steals corporate secrets through shared dreams receives an inverse assignment.", "Christopher Nolan", "Leonardo DiCaprio, Joseph Gordon-Levitt", ["Action", "Sci-Fi", "Thriller"], None, None, None), | |
| ("tt0133093", "The Matrix", "1999", "movie", "R", "2h 16m", 8.7, 2_200_000, "73", "70", "A hacker discovers that the world he knows is a simulated reality.", "Lana Wachowski, Lilly Wachowski", "Keanu Reeves, Laurence Fishburne", ["Action", "Sci-Fi"], None, None, None), | |
| ("tt0099685", "Goodfellas", "1990", "movie", "R", "2h 25m", 8.7, 1_300_000, "92", "133", "A young man grows up in the mob and works to advance through its ranks.", "Martin Scorsese", "Robert De Niro, Ray Liotta", ["Biography", "Crime", "Drama"], None, None, None), | |
| ("tt0114369", "Se7en", "1995", "movie", "R", "2h 7m", 8.6, 1_900_000, "65", "35", "Two detectives hunt a serial killer who stages crimes around the seven deadly sins.", "David Fincher", "Morgan Freeman, Brad Pitt", ["Crime", "Drama", "Mystery"], None, None, None), | |
| ("tt0102926", "The Silence of the Lambs", "1991", "movie", "R", "1h 58m", 8.6, 1_600_000, "86", "122", "A trainee seeks the insight of an imprisoned killer to catch another murderer.", "Jonathan Demme", "Jodie Foster, Anthony Hopkins", ["Crime", "Drama", "Thriller"], None, None, None), | |
| ("tt0120815", "Saving Private Ryan", "1998", "movie", "R", "2h 49m", 8.6, 1_600_000, "91", "83", "A wartime squad searches behind enemy lines for a paratrooper whose brothers have died.", "Steven Spielberg", "Tom Hanks, Matt Damon", ["Drama", "War"], None, None, None), | |
| ("tt0245429", "Spirited Away", "2001", "movie", "PG", "2h 4m", 8.6, 900_000, "96", "161", "A girl enters a world ruled by spirits and must save her parents.", "Hayao Miyazaki", "Daveigh Chase, Suzanne Pleshette", ["Animation", "Adventure", "Family"], None, None, None), | |
| ("tt0120689", "The Green Mile", "1999", "movie", "R", "3h 9m", 8.6, 1_500_000, "61", "116", "A death-row guard encounters a prisoner with an extraordinary gift.", "Frank Darabont", "Tom Hanks, Michael Clarke Duncan", ["Crime", "Drama", "Fantasy"], None, None, None), | |
| ("tt6751668", "Parasite", "2019", "movie", "R", "2h 12m", 8.5, 1_100_000, "97", "102", "A struggling family gradually enters the household of a wealthy family.", "Bong Joon Ho", "Song Kang-ho, Lee Sun-kyun", ["Drama", "Thriller"], None, None, None), | |
| ("tt0172495", "Gladiator", "2000", "movie", "R", "2h 35m", 8.5, 1_800_000, "67", "52", "A betrayed Roman general returns as a gladiator to seek justice.", "Ridley Scott", "Russell Crowe, Joaquin Phoenix", ["Action", "Adventure", "Drama"], None, None, None), | |
| ("tt0482571", "The Prestige", "2006", "movie", "PG-13", "2h 10m", 8.5, 1_500_000, "66", "91", "Two rival magicians pursue the ultimate illusion at devastating cost.", "Christopher Nolan", "Christian Bale, Hugh Jackman", ["Drama", "Mystery", "Sci-Fi"], None, None, None), | |
| ("tt2582802", "Whiplash", "2014", "movie", "R", "1h 46m", 8.5, 1_100_000, "89", "88", "An ambitious drummer is pushed to his limits by a demanding instructor.", "Damien Chazelle", "Miles Teller, J.K. Simmons", ["Drama", "Music"], None, None, None), | |
| ("tt0407887", "The Departed", "2006", "movie", "R", "2h 31m", 8.5, 1_500_000, "85", "97", "An undercover officer and a police informant try to identify one another.", "Martin Scorsese", "Leonardo DiCaprio, Matt Damon", ["Crime", "Drama", "Thriller"], None, None, None), | |
| ("tt0110357", "The Lion King", "1994", "movie", "G", "1h 28m", 8.5, 1_200_000, "88", "148", "A young lion prince flees his kingdom before learning to accept his role.", "Roger Allers, Rob Minkoff", "Matthew Broderick, Jeremy Irons", ["Animation", "Adventure", "Drama"], None, None, None), | |
| ("tt1853728", "Django Unchained", "2012", "movie", "R", "2h 45m", 8.5, 1_800_000, "81", "104", "A freed man and a bounty hunter journey to rescue his wife.", "Quentin Tarantino", "Jamie Foxx, Christoph Waltz", ["Drama", "Western"], None, None, None), | |
| ("tt0114814", "The Usual Suspects", "1995", "movie", "R", "1h 46m", 8.5, 1_200_000, "77", "152", "A survivor recounts the events that brought five criminals together.", "Bryan Singer", "Kevin Spacey, Gabriel Byrne", ["Crime", "Drama", "Mystery"], None, None, None), | |
| ("tt0253474", "The Pianist", "2002", "movie", "R", "2h 30m", 8.5, 1_000_000, "85", "172", "A Polish musician struggles to survive the destruction of Warsaw.", "Roman Polanski", "Adrien Brody, Thomas Kretschmann", ["Biography", "Drama", "Music"], None, None, None), | |
| ("tt0088763", "Back to the Future", "1985", "movie", "PG", "1h 56m", 8.5, 1_400_000, "87", "99", "A teenager is sent thirty years into the past in a time-traveling car.", "Robert Zemeckis", "Michael J. Fox, Christopher Lloyd", ["Adventure", "Comedy", "Sci-Fi"], None, None, None), | |
| ("tt0103064", "Terminator 2: Judgment Day", "1991", "movie", "R", "2h 17m", 8.6, 1_200_000, "75", "118", "A reprogrammed cyborg protects a child from a more advanced machine.", "James Cameron", "Arnold Schwarzenegger, Linda Hamilton", ["Action", "Sci-Fi"], None, None, None), | |
| ("tt0078748", "Alien", "1979", "movie", "R", "1h 57m", 8.5, 1_000_000, "89", "140", "A space crew encounters a deadly life-form aboard its ship.", "Ridley Scott", "Sigourney Weaver, Tom Skerritt", ["Horror", "Sci-Fi"], None, None, None), | |
| ("tt15398776", "Oppenheimer", "2023", "movie", "R", "3h", 8.3, 900_000, "90", "26", "The physicist who led the Manhattan Project confronts its consequences.", "Christopher Nolan", "Cillian Murphy, Florence Pugh", ["Biography", "Drama", "History"], None, None, None), | |
| ("tt15239678", "Dune: Part Two", "2024", "movie", "PG-13", "2h 46m", 8.5, 700_000, "79", "23", "Paul Atreides unites with the Fremen while seeking justice for his family.", "Denis Villeneuve", "Timothée Chalamet, Zendaya", ["Action", "Adventure", "Drama"], None, None, None), | |
| ("tt6710474", "Everything Everywhere All at Once", "2022", "movie", "R", "2h 19m", 7.8, 600_000, "81", "205", "A laundromat owner is swept into a multiverse-spanning struggle.", "Daniel Kwan, Daniel Scheinert", "Michelle Yeoh, Stephanie Hsu", ["Action", "Adventure", "Comedy"], None, None, None), | |
| ("tt0903747", "Breaking Bad", "2008–2013", "series", "TV-MA", "45m", 9.5, 2_400_000, "87", "8", "A chemistry teacher enters the drug trade after a terminal diagnosis.", "Vince Gilligan", "Bryan Cranston, Aaron Paul", ["Crime", "Drama", "Thriller"], None, None, None), | |
| ("tt7366338", "Chernobyl", "2019", "series", "TV-MA", "1h", 9.3, 950_000, "82", "29", "Responders confront the 1986 nuclear disaster and its aftermath.", "Craig Mazin", "Jessie Buckley, Jared Harris", ["Drama", "History", "Thriller"], None, None, None), | |
| ("tt0944947", "Game of Thrones", "2011–2019", "series", "TV-MA", "57m", 9.2, 2_400_000, "86", "12", "Noble families struggle for control of the Iron Throne.", "David Benioff, D.B. Weiss", "Emilia Clarke, Peter Dinklage", ["Action", "Adventure", "Drama"], None, None, None), | |
| ("tt4574334", "Stranger Things", "2016–2025", "series", "TV-14", "51m", 8.6, 1_500_000, "74", "5", "Friends uncover supernatural forces and secret experiments in their town.", "The Duffer Brothers", "Millie Bobby Brown, Finn Wolfhard", ["Drama", "Fantasy", "Horror"], None, None, None), | |
| ("tt2301451", "Ozymandias", "2013", "episode", "TV-14", "48m", 10.0, 260_000, "100", "41", "Walt faces the catastrophic consequences of the conflict in the desert.", "Rian Johnson", "Bryan Cranston, Aaron Paul", ["Crime", "Drama", "Thriller"], "tt0903747", 5, 14), | |
| ("tt4283094", "The Winds of Winter", "2016", "episode", "TV-MA", "1h 8m", 9.9, 190_000, "98", "63", "The great houses confront the aftermath of Cersei's trial.", "Miguel Sapochnik", "Emilia Clarke, Lena Headey", ["Action", "Adventure", "Drama"], "tt0944947", 6, 10), | |
| ) | |
| # id, name, professions, known for, search aliases | |
| CATALOG_PEOPLE = ( | |
| ("nm0634240", "Christopher Nolan", "Writer, Producer, Director", "Oppenheimer (2023)", ["inception", "interstellar", "dark knight"]), | |
| ("nm0000288", "Christian Bale", "Actor, Producer", "The Dark Knight (2008)", ["dark knight", "prestige"]), | |
| ("nm0005132", "Heath Ledger", "Actor, Director", "The Dark Knight (2008)", ["joker", "dark knight"]), | |
| ("nm0000190", "Matthew McConaughey", "Actor, Producer", "Interstellar (2014)", ["interstellar"]), | |
| ("nm0004266", "Anne Hathaway", "Actress, Producer", "Les Misérables (2012)", ["interstellar"]), | |
| ("nm0000354", "Matt Damon", "Actor, Producer, Writer", "Good Will Hunting (1997)", ["saving private ryan", "departed", "matt damon"]), | |
| ("nm0000233", "Quentin Tarantino", "Writer, Producer, Director", "Pulp Fiction (1994)", ["pulp fiction", "django"]), | |
| ("nm0000237", "John Travolta", "Actor, Producer", "Pulp Fiction (1994)", ["pulp fiction"]), | |
| ("nm0000235", "Uma Thurman", "Actress, Producer", "Kill Bill: Vol. 1 (2003)", ["pulp fiction"]), | |
| ("nm0000168", "Samuel L. Jackson", "Actor, Producer", "Pulp Fiction (1994)", ["pulp fiction"]), | |
| ("nm0000151", "Morgan Freeman", "Actor, Producer", "The Shawshank Redemption (1994)", ["shawshank", "se7en"]), | |
| ("nm0000209", "Tim Robbins", "Actor, Director", "The Shawshank Redemption (1994)", ["shawshank"]), | |
| ("nm0000199", "Al Pacino", "Actor, Director", "The Godfather (1972)", ["godfather"]), | |
| ("nm0186505", "Bryan Cranston", "Actor, Producer", "Breaking Bad (2008–2013)", ["breaking bad", "ozymandias"]), | |
| ("nm3592338", "Emilia Clarke", "Actress, Producer", "Game of Thrones (2011–2019)", ["game of thrones", "winds of winter"]), | |
| ("nm0614165", "Cillian Murphy", "Actor, Producer", "Oppenheimer (2023)", ["oppenheimer"]), | |
| ("nm0898288", "Denis Villeneuve", "Director, Producer, Writer", "Dune: Part Two (2024)", ["dune"]), | |
| ("nm3918035", "Zendaya", "Actress, Producer", "Dune: Part Two (2024)", ["dune"]), | |
| ("nm6073955", "Florence Pugh", "Actress, Producer", "Oppenheimer (2023)", ["oppenheimer", "dune"]), | |
| ) | |
| PERSON_CREDITS = ( | |
| ("tt0468569", "nm0634240", "Director", "Christopher Nolan"), | |
| ("tt0468569", "nm0000288", "Actor", "Bruce Wayne"), | |
| ("tt0468569", "nm0005132", "Actor", "Joker"), | |
| ("tt0816692", "nm0634240", "Director", "Christopher Nolan"), | |
| ("tt0816692", "nm0000190", "Actor", "Cooper"), | |
| ("tt0816692", "nm0004266", "Actor", "Brand"), | |
| ("tt0120815", "nm0000354", "Actor", "Private Ryan"), | |
| ("tt0407887", "nm0000354", "Actor", "Colin Sullivan"), | |
| ("tt0110912", "nm0000233", "Director", "Quentin Tarantino"), | |
| ("tt0110912", "nm0000237", "Actor", "Vincent Vega"), | |
| ("tt0110912", "nm0000235", "Actor", "Mia Wallace"), | |
| ("tt0110912", "nm0000168", "Actor", "Jules Winnfield"), | |
| ("tt0111161", "nm0000209", "Actor", "Andy Dufresne"), | |
| ("tt0111161", "nm0000151", "Actor", "Ellis Boyd Redding"), | |
| ("tt0068646", "nm0000199", "Actor", "Michael Corleone"), | |
| ("tt0114369", "nm0000151", "Actor", "Somerset"), | |
| ("tt0482571", "nm0634240", "Director", "Christopher Nolan"), | |
| ("tt0482571", "nm0000288", "Actor", "Alfred Borden"), | |
| ("tt15398776", "nm0634240", "Director", "Christopher Nolan"), | |
| ("tt15398776", "nm0614165", "Actor", "J. Robert Oppenheimer"), | |
| ("tt15398776", "nm6073955", "Actor", "Jean Tatlock"), | |
| ("tt15239678", "nm0898288", "Director", "Denis Villeneuve"), | |
| ("tt15239678", "nm3918035", "Actor", "Chani"), | |
| ("tt15239678", "nm6073955", "Actor", "Princess Irulan"), | |
| ("tt0903747", "nm0186505", "Actor", "Walter White"), | |
| ("tt2301451", "nm0186505", "Actor", "Walter White"), | |
| ("tt0944947", "nm3592338", "Actor", "Daenerys Targaryen"), | |
| ("tt4283094", "nm3592338", "Actor", "Daenerys Targaryen"), | |
| ) | |
| CATALOG_PATH = Path(__file__).resolve().parents[1] / "catalog.json" | |
| def complete_catalog_titles( | |
| existing_titles: tuple[dict[str, Any], ...], | |
| ) -> tuple[dict[str, Any], ...]: | |
| """Merge the immutable chart contracts into complete local title rows. | |
| The richer 36-title directory wins on overlap. Catalog-only rows retain | |
| exactly the title/year/rank/rating/vote/credit/poster facts present in | |
| ``catalog.json`` and use explicit unavailable copy for fields that file | |
| does not claim. | |
| """ | |
| payload = json.loads(CATALOG_PATH.read_text(encoding="utf-8")) | |
| top_by_id = {item["id"]: item for item in payload["top"]} | |
| popular_by_id = {item["id"]: item for item in payload["popular"]} | |
| merged: dict[str, dict[str, Any]] = { | |
| item["id"]: dict(item) for item in existing_titles | |
| } | |
| for row in [*payload["top"], *payload["popular"]]: | |
| title_id = row["id"] | |
| if title_id in merged: | |
| continue | |
| top = top_by_id.get(title_id) | |
| popular = popular_by_id.get(title_id) | |
| rating = row.get("rating") | |
| votes = row.get("votes") | |
| credit = str(row.get("credit") or "Credits unavailable") | |
| rank_copy = ( | |
| f"Top rated movie #{top['rank']}" | |
| if top is not None | |
| else f"Popular movie #{popular['rank']}" | |
| ) | |
| merged[title_id] = { | |
| "id": title_id, | |
| "title": row["title"], | |
| "year": str(row.get("year") or "Year unavailable"), | |
| "cert": "Certificate unavailable", | |
| "runtime": "Runtime unavailable", | |
| "imdb_rating": str(rating) if rating is not None else "Not rated", | |
| "votes": str(votes) if votes is not None else "No ratings", | |
| "metascore": "Unavailable", | |
| "popularity": str(popular["rank"] if popular is not None else top["rank"]), | |
| "watchlist_count": "Unavailable", | |
| "top_rank": rank_copy, | |
| "plot": ( | |
| f"The local catalog records {row['title']} as a {row.get('year') or 'year-unavailable'} " | |
| "movie. A synopsis was not included in the preserved catalog." | |
| ), | |
| "director": "Director unavailable", | |
| "writers": "Writers unavailable", | |
| "stars": "Unavailable", | |
| "catalog_credit": credit, | |
| "genres": ["Catalog entry"], | |
| "poster": row["poster"], | |
| "card": row["poster"], | |
| "title_type": "movie", | |
| "series_id": None, | |
| "season_number": None, | |
| "episode_number": None, | |
| "asset_group": "catalog", | |
| "seed_vote_count": int(votes) if votes is not None else None, | |
| "seed_rating_avg": float(rating) if rating is not None else None, | |
| } | |
| return tuple(merged.values()) | |
| def extra_titles(assets_base: str) -> tuple[dict[str, Any], ...]: | |
| catalog_base = f"{assets_base.rsplit('/', 1)[0]}/2026-08-10" | |
| rows: list[dict[str, Any]] = [] | |
| for index, row in enumerate(CATALOG_ROWS, start=1): | |
| ( | |
| title_id, title, year, title_type, cert, runtime, rating, | |
| votes, metascore, popularity, plot, director, stars, genres, | |
| parent, season, episode, | |
| ) = row | |
| poster = f"{catalog_base}/catalog-posters/{title_id}.svg" | |
| rows.append( | |
| { | |
| "id": title_id, | |
| "title": title, | |
| "year": year, | |
| "cert": cert, | |
| "runtime": runtime, | |
| "imdb_rating": f"{rating:.1f}", | |
| "votes": str(votes), | |
| "metascore": metascore, | |
| "popularity": popularity, | |
| "watchlist_count": f"{max(votes // 2, 50_000):,}", | |
| "top_rank": ( | |
| f"Top rated {title_type} #{index + 3}" | |
| if rating >= 8.5 else "Popular title" | |
| ), | |
| "plot": plot, | |
| "director": director, | |
| "writers": director, | |
| "stars": stars, | |
| "genres": genres, | |
| "poster": poster, | |
| "card": poster, | |
| "title_type": title_type, | |
| "series_id": parent, | |
| "season_number": season, | |
| "episode_number": episode, | |
| "seed_vote_count": votes, | |
| "seed_rating_avg": rating, | |
| "asset_group": ( | |
| "title-dark-knight" if index % 3 == 1 | |
| else "title-interstellar" if index % 3 == 2 | |
| else "title-pulp-fiction" | |
| ), | |
| } | |
| ) | |
| return tuple(rows) | |
| def extra_people(assets_base: str) -> tuple[tuple[Any, ...], ...]: | |
| catalog_base = f"{assets_base.rsplit('/', 1)[0]}/2026-08-10" | |
| return tuple( | |
| (*row[:4], f"{catalog_base}/catalog-people/{row[0]}.svg", row[4]) | |
| for row in CATALOG_PEOPLE | |
| ) | |