Skip to content

Commit

Permalink
add scripts for fetching cinema data
Browse files Browse the repository at this point in the history
  • Loading branch information
vorant94 committed Dec 1, 2024
1 parent 1680ea1 commit bacdf7a
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
},
"dependencies": {
"@hono/zod-validator": "^0.4.1",
"date-fns": "^4.1.0",
"drizzle-orm": "^0.36.1",
"drizzle-zod": "^0.5.1",
"grammy": "^1.31.2",
Expand Down
35 changes: 35 additions & 0 deletions scripts/fetch-hot-cinema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import console from "node:console";
import { inspect, parseArgs } from "node:util";
import { addDays, format } from "date-fns";
import { z } from "zod";

const { cinemaId, date } = z
.object({
cinemaId: z.coerce.number().default(1),
date: z.coerce.date().default(addDays(new Date(), 1)),
})
.parse(
parseArgs({
options: {
cinemaId: {
type: "string",
},
date: {
type: "string",
},
},
}).values,
);

const response = await fetch(
`https://www.hotcinema.co.il/tickets/TheaterEvents2?date=${format(date, "dd/MM/yyyy")}&theatreid=${cinemaId}`,
);
const json = await response.json();

console.info(
inspect(json, {
colors: true,
depth: Number.POSITIVE_INFINITY,
maxArrayLength: Number.POSITIVE_INFINITY,
}),
);
39 changes: 39 additions & 0 deletions scripts/fetch-planet.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import console from "node:console";
import { inspect, parseArgs } from "node:util";
import { addDays, format } from "date-fns";
import { z } from "zod";

const { tenantId, cinemaId, date } = z
.object({
tenantId: z.coerce.number().default(10100),
cinemaId: z.coerce.number().default(1072),
date: z.coerce.date().default(addDays(new Date(), 1)),
})
.parse(
parseArgs({
options: {
tenantId: {
type: "string",
},
cinemaId: {
type: "string",
},
date: {
type: "string",
},
},
}).values,
);

const response = await fetch(
`https://www.planetcinema.co.il/il/data-api-service/v1/quickbook/${tenantId}/film-events/in-cinema/${cinemaId}/at-date/${format(date, "yyyy-MM-dd")}`,
);
const json = await response.json();

console.info(
inspect(json, {
colors: true,
depth: Number.POSITIVE_INFINITY,
maxArrayLength: Number.POSITIVE_INFINITY,
}),
);
39 changes: 39 additions & 0 deletions scripts/fetch-rav-hen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import console from "node:console";
import { inspect, parseArgs } from "node:util";
import { addDays, format } from "date-fns";
import { z } from "zod";

const { tenantId, cinemaId, date } = z
.object({
tenantId: z.coerce.number().default(10104),
cinemaId: z.coerce.number().default(1058),
date: z.coerce.date().default(addDays(new Date(), 1)),
})
.parse(
parseArgs({
options: {
tenantId: {
type: "string",
},
cinemaId: {
type: "string",
},
date: {
type: "string",
},
},
}).values,
);

const response = await fetch(
`https://www.rav-hen.co.il/rh/data-api-service/v1/quickbook/${tenantId}/film-events/in-cinema/${cinemaId}/at-date/${format(date, "yyyy-MM-dd")}`,
);
const json = await response.json();

console.info(
inspect(json, {
colors: true,
depth: Number.POSITIVE_INFINITY,
maxArrayLength: Number.POSITIVE_INFINITY,
}),
);

0 comments on commit bacdf7a

Please sign in to comment.