Skip to content

Commit

Permalink
feat: movies and shows
Browse files Browse the repository at this point in the history
  • Loading branch information
Princesseuh committed May 22, 2023
1 parent cfcb221 commit 672b952
Show file tree
Hide file tree
Showing 43 changed files with 447 additions and 12 deletions.
2 changes: 1 addition & 1 deletion scripts/catalogueUtils.ts
@@ -1,7 +1,7 @@
import { bold, gray, green, red, yellow } from "kleur/colors";
import fs from "node:fs";

export function getContentDirs(type: "games" | "books"): URL[] {
export function getContentDirs(type: "games" | "books" | "movies" | "shows"): URL[] {
const dirPath = new URL(`../src/content/${type}/`, import.meta.url);
const dirs = fs
.readdirSync(dirPath, { withFileTypes: true })
Expand Down
71 changes: 71 additions & 0 deletions scripts/getInfoCoverMovieShow.ts
@@ -0,0 +1,71 @@
import "dotenv/config";
import matter from "gray-matter";
import { bold, gray } from "kleur/colors";
import fs from "node:fs";
import path from "node:path";
import sharp from "sharp";
import { Logger, getContentDirs } from "./catalogueUtils";

export interface MovieData {
id: string;
title: string;
image: string;
year: string;
plot: string;
releaseDate: string;
companyList: { id: string; name: string }[];
genreList: { key: string; value: string }[];
runtimeStr: string;
}

export async function getDataForMoviesAndShows(type: "movies" | "shows") {
const apiKey = process.env.IMDB_KEY;
const moviesShowsDirs = getContentDirs(type);

for (const movieShowDir of moviesShowsDirs) {
const dirBasename = path.basename(movieShowDir.pathname);
const dataFilePath = new URL("./_data.json", movieShowDir);

Logger.info(`Getting data for ${type}/${bold(dirBasename)}...`);
if (fs.existsSync(dataFilePath)) {
Logger.info(gray(`Data already exists, skipping...`));
continue;
}

const markdownContent = fs
.readFileSync(new URL(path.basename(movieShowDir.pathname) + ".md", movieShowDir))
.toString();
const movieId = matter(markdownContent).data.imdb;
const response = (await fetch(
`https://imdb-api.com/en/API/Title/${apiKey}/${movieId}/Posters`,
).then((response) => response.json())) as MovieData;
const { image } = response;
const resultData = {
title: response.title,
id: response.id,
plot: response.plot,
releaseDate: response.releaseDate,
runtimeStr: response.runtimeStr,
year: response.year,
companies: response.companyList.map((company) => company.name),
genres: response.genreList.map((genre) => genre.value),
};

fs.writeFileSync(dataFilePath, JSON.stringify(resultData, null, 2));
Logger.success(`Data saved for ${bold(dirBasename)}!`);

const coverURL = image;
const coverData = await fetch(coverURL).then((response) => response.arrayBuffer());
const coverPath = new URL("./cover.png", movieShowDir);
if (!coverURL.endsWith("png")) {
sharp(coverData).toFile(coverPath.pathname);
} else {
fs.writeFileSync(coverPath, Buffer.from(coverData));
}

fs.writeFileSync(coverPath, Buffer.from(coverData));
Logger.success(`Cover saved for ${bold(dirBasename)}!`);
}

return moviesShowsDirs.length;
}
15 changes: 11 additions & 4 deletions scripts/update-catalogue-info.ts
Expand Up @@ -2,11 +2,18 @@ import { bold } from "kleur/colors";
import { Logger } from "./catalogueUtils";
import { getDataForBooks } from "./getInfoCoverBook";
import { getDataForGames } from "./getInfoCoverGame";
import { getDataForMoviesAndShows } from "./getInfoCoverMovieShow";

const [gameCount, bookCount] = await Promise.all([getDataForGames(), getDataForBooks()]);
const [gameCount, bookCount, moviesCount, showsCount] = await Promise.all([
getDataForGames(),
getDataForBooks(),
getDataForMoviesAndShows("movies"),
getDataForMoviesAndShows("shows"),
]);
const totalCount = gameCount + bookCount + moviesCount + showsCount;

Logger.success(
`Got data for ${bold(gameCount)} games and ${bold(bookCount)} books! Total: ${bold(
gameCount + bookCount,
)}`,
`Got data for ${bold(gameCount)} games, ${bold(bookCount)} books, ${bold(
moviesCount,
)} movies and ${bold(showsCount)} shows! Total: ${bold(totalCount)}.`,
);
2 changes: 2 additions & 0 deletions src/components/Catalogue.astro
Expand Up @@ -12,6 +12,8 @@
<option value="">Type</option>
<option value="book">Book</option>
<option value="game">Game</option>
<option value="movie">Movie</option>
<option value="show">Show</option>
</select>
</div>

Expand Down
26 changes: 26 additions & 0 deletions src/content/config.ts
Expand Up @@ -82,10 +82,36 @@ const gamesCollection = defineCollection({
}),
});

const moviesCollection = defineCollection({
schema: ({ image }) =>
z.object({
title: z.string(),
rating: ratingSchema,
finishedDate: z.date(),
cover: z.preprocess(() => "./cover.png", image()),
imdb: z.string(),
type: z.literal("movie").default("movie"),
}),
});

const showsCollection = defineCollection({
schema: ({ image }) =>
z.object({
title: z.string(),
rating: ratingSchema,
finishedDate: z.date(),
cover: z.preprocess(() => "./cover.png", image()),
imdb: z.string(),
type: z.literal("show").default("show"),
}),
});

export const collections = {
blog: blogCollection,
wiki: wikiCollection,
projects: projectCollection,
books: booksCollection,
games: gamesCollection,
movies: moviesCollection,
shows: showsCollection,
};
10 changes: 10 additions & 0 deletions src/content/movies/callmebyyourname/_data.json
@@ -0,0 +1,10 @@
{
"title": "Call Me by Your Name",
"id": "tt5726616",
"plot": "In 1980s Italy, romance blossoms between a seventeen-year-old student and the older man hired as his father's research assistant.",
"releaseDate": "2018-01-19",
"runtimeStr": "2h 12min",
"year": "2017",
"companies": ["Frenesy Film Company", "La Cinéfacture", "RT Features"],
"genres": ["Drama", "Romance"]
}
8 changes: 8 additions & 0 deletions src/content/movies/callmebyyourname/callmebyyourname.md
@@ -0,0 +1,8 @@
---
title: Call Me By Your Name
rating: "liked"
finishedDate: 2023-05-20
imdb: tt5726616
---

Loved the scene with the dad. You know the one.
Binary file added src/content/movies/callmebyyourname/cover.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions src/content/movies/carol/_data.json
@@ -0,0 +1,17 @@
{
"title": "Carol",
"id": "tt2402927",
"plot": "An aspiring photographer develops an intimate relationship with an older woman in 1950s New York.",
"releaseDate": "2016-01-15",
"runtimeStr": "1h 58min",
"year": "2015",
"companies": [
"The Weinstein Company",
"Film4",
"Number 9 Films"
],
"genres": [
"Drama",
"Romance"
]
}
6 changes: 6 additions & 0 deletions src/content/movies/carol/carol.md
@@ -0,0 +1,6 @@
---
title: "Carol"
finishedDate: 2022-07-22
rating: "okay"
imdb: "tt2402927"
---
Binary file added src/content/movies/carol/cover.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions src/content/movies/christine/_data.json
@@ -0,0 +1,17 @@
{
"title": "Christine",
"id": "tt4666726",
"plot": "The story of Christine Chubbuck, a 1970s TV reporter struggling with depression and professional frustrations as she tries to advance her career.",
"releaseDate": "2016-10-14",
"runtimeStr": "1h 59min",
"year": "2016",
"companies": [
"BorderLine Films",
"Fresh Jade",
"The Wonder Club"
],
"genres": [
"Biography",
"Drama"
]
}
6 changes: 6 additions & 0 deletions src/content/movies/christine/christine.md
@@ -0,0 +1,6 @@
---
title: "Christine"
finishedDate: 2021-08-21
rating: "liked"
imdb: "tt4666726"
---
Binary file added src/content/movies/christine/cover.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions src/content/movies/earthquakebird/_data.json
@@ -0,0 +1,18 @@
{
"title": "Earthquake Bird",
"id": "tt8178486",
"plot": "An enigmatic translator with a dark past is brought in for questioning after an ex-pat friend, who came between her and her photographer boyfriend, ends up missing and presumed dead.",
"releaseDate": "2019-11-15",
"runtimeStr": "1h 47min",
"year": "2019",
"companies": [
"Scott Free Productions",
"Trevanna Post",
"Twenty First City"
],
"genres": [
"Crime",
"Drama",
"Mystery"
]
}
Binary file added src/content/movies/earthquakebird/cover.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions src/content/movies/earthquakebird/earthquakebird.md
@@ -0,0 +1,10 @@
---
title: "Earthquake Bird"
rating: "liked"
finishedDate: 2021-03-22
imdb: "tt8178486"
---

The storyline isn't necessarily exceptional but there's SUCH a mood throughout the movie

The cinematography is amazing, everything and everyone is so pretty. I rewatched it twice now because it's just so so pretty and moody
17 changes: 17 additions & 0 deletions src/content/movies/kajillionaire/_data.json
@@ -0,0 +1,17 @@
{
"title": "Kajillionaire",
"id": "tt8143990",
"plot": "A woman's life is turned upside down when her criminal parents invite an outsider to join them on a major heist they're planning.",
"releaseDate": "2020-09-25",
"runtimeStr": "1h 44min",
"year": "2020",
"companies": [
"Annapurna Pictures",
"Plan B Entertainment"
],
"genres": [
"Comedy",
"Crime",
"Drama"
]
}
Binary file added src/content/movies/kajillionaire/cover.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions src/content/movies/kajillionaire/kajillionaire.md
@@ -0,0 +1,8 @@
---
title: Kajillionaire
finishedDate: 2023-02-12
rating: "loved"
imdb: "tt8143990"
---

Old Dolio man
18 changes: 18 additions & 0 deletions src/content/movies/rideordie/_data.json
@@ -0,0 +1,18 @@
{
"title": "Ride or Die",
"id": "tt14164234",
"plot": "Rei helps the woman she's been in love with for years escape her abusive husband. While on the run, their feelings for each other catch fire.",
"releaseDate": "2021-04-15",
"runtimeStr": "2h 22min",
"year": "2021",
"companies": [
"Kôdansha",
"Shogakukan",
"Studio3"
],
"genres": [
"Drama",
"Romance",
"Thriller"
]
}
Binary file added src/content/movies/rideordie/cover.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions src/content/movies/rideordie/rideordie.md
@@ -0,0 +1,8 @@
---
title: "Ride or Die"
finishedDate: 2021-05-22
rating: "hated"
imdb: "tt14164234"
---

I don't know if the manga it's based on is better, but man this wasn't good
10 changes: 10 additions & 0 deletions src/content/shows/breakingbad/_data.json
@@ -0,0 +1,10 @@
{
"title": "Breaking Bad",
"id": "tt0903747",
"plot": "A chemistry teacher diagnosed with inoperable lung cancer turns to manufacturing and selling methamphetamine with a former student in order to secure his family's future.",
"releaseDate": "2008-01-20",
"runtimeStr": null,
"year": "2008",
"companies": ["High Bridge Productions", "Gran Via Productions", "Sony Pictures Television"],
"genres": ["Crime", "Drama", "Thriller"]
}
6 changes: 6 additions & 0 deletions src/content/shows/breakingbad/breakingbad.md
@@ -0,0 +1,6 @@
---
title: Breaking Bad
rating: "liked"
finishedDate: 2023-05-16
imdb: "tt0903747"
---
Binary file added src/content/shows/breakingbad/cover.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions src/content/shows/castlevania/_data.json
@@ -0,0 +1,18 @@
{
"title": "Castlevania",
"id": "tt6517102",
"plot": "A vampire hunter fights to save a besieged city from an army of otherworldly creatures controlled by Dracula.",
"releaseDate": "2017-07-07",
"runtimeStr": null,
"year": "2017",
"companies": [
"Frederator Studios",
"Mua Film",
"Netflix"
],
"genres": [
"Animation",
"Action",
"Adventure"
]
}
14 changes: 14 additions & 0 deletions src/content/shows/castlevania/castlevania.md
@@ -0,0 +1,14 @@
---
title: Castlevania
finishedDate: 2021-11-17
rating: "loved"
imdb: "tt6517102"
---

I really really liked this! I found the artstyle very charming. All the characters having long faces made me simp for most of them, especially the ladies, season 4 could've been a 10 episodes Lenore fan cam and I would have liked it just as much.

The only thing that I didn't like is that I felt like there was a bit too much fighting, especially in the later seasons. I think I would've liked more talking and more casual scenes between the characters instead of endless fighting. Though, I guess the endless fighting made sense in the context of the story

Alucard was such a good character, James Callis was amazing, his voice felt so sad, so melancholic at times, wow. I really want to replay Symphony of the Night now!

I cried a few tears at the end, I loved it, I heavily recommend it
Binary file added src/content/shows/castlevania/cover.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions src/content/shows/hibyemama/_data.json
@@ -0,0 +1,10 @@
{
"title": "Hi Bye, Mama!",
"id": "tt11804034",
"plot": "It's the story of a mother who died and begins a 49-day long project of reincarnation and a husband who has barely begun to live a new life after overcoming the pain of losing his wife.",
"releaseDate": "2020-02-22",
"runtimeStr": null,
"year": "2020",
"companies": ["MI Inc."],
"genres": ["Comedy", "Drama", "Fantasy"]
}
Binary file added src/content/shows/hibyemama/cover.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions src/content/shows/hibyemama/hibyemama.md
@@ -0,0 +1,8 @@
---
title: Hi Bye, Mama!
finishedDate: 2022-03-22
rating: "loved"
imdb: "tt11804034"
---

Very good show! It starts off a bit goofy (and definitely does have its goofy moments that we love very much throughout) but it ends up being a very sad show. I did cry a few times.

1 comment on commit 672b952

@vercel
Copy link

@vercel vercel bot commented on 672b952 May 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

erika-florist – ./

erika-florist-git-main-princesseuh.vercel.app
erika-florist-princesseuh.vercel.app
erika-florist.vercel.app

Please sign in to comment.