Skip to content

Commit

Permalink
feat: filmhallen
Browse files Browse the repository at this point in the history
  • Loading branch information
ckuijjer committed Dec 11, 2023
1 parent f3d8e3c commit c8d6fdc
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,7 @@ aws s3 sync s3://expatcinema-scrapers-output expatcinema-scrapers-output --profi
aws s3 sync s3://expatcinema-public expatcinema-public--profile casper
aws dynamodb scan --table-name expatcinema-scrapers-analytics --profile casper > expatcinema-scrapers-analytics.json
```

### Favicon

Use https://favicongrabber.com/ to grab a favicon for the cinema.json file
68 changes: 68 additions & 0 deletions cloud/scrapers/defilmhallen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { Screening } from 'types'
import { DateTime } from 'luxon'
import got from 'got'

import { logger as parentLogger } from '../powertools'

const logger = parentLogger.createChild({
persistentLogAttributes: {
scraper: 'defilmhallen',
},
})

type FkFeedItem = {
title: string
language: { label: string; value: string }
permalink: string
times: { program_start: string; program_end: string; tags: string[] }[]
}

const hasEnglishSubtitles = (
time: FkFeedItem['times'][0],
movie: FkFeedItem,
) => {
const movieHasEnglishSubtitels =
movie.language?.label === 'Subtitles' && movie.language?.value === 'English'

return movieHasEnglishSubtitels
}

// e.g. 202210181005 -> 2022-10-18T10:05:00.000Z
const extractDate = (time: string) =>
DateTime.fromFormat(time, 'yyyyMMddHHmm').toJSDate()

const extractFromMainPage = async () => {
const movies = Object.values<FkFeedItem>(
await got('https://filmhallen.nl/en/fk-feed/agenda').json(),
)

logger.info('main page', { movies })

const screenings: Screening[][] = movies
.map((movie) => {
return movie.times
?.filter((time) => hasEnglishSubtitles(time, movie))
.map((time) => {
return {
// title: decode(movie.title),
title: movie.title,
url: movie.permalink,
cinema: 'De Filmhallen',
date: extractDate(time.program_start),
}
})
})
.filter((x) => x)

logger.info('before flatten', { screenings })

return screenings.flat()
}

if (require.main === module) {
extractFromMainPage()
.then((x) => JSON.stringify(x, null, 2))
.then(console.log)
}

export default extractFromMainPage
2 changes: 2 additions & 0 deletions cloud/scrapers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import bioscopenleiden from './bioscopenleiden'
import cinecenter from './cinecenter'
import cinecitta from './cinecitta'
import cinerama from './cinerama'
import defilmhallen from './defilmhallen'
import deuitkijk from './deuitkijk'
import eyefilm from './eyefilm'
import filmhuisdenhaag from './filmhuisdenhaag'
Expand Down Expand Up @@ -49,6 +50,7 @@ const SCRAPERS = {
cinecenter,
cinecitta,
// cinerama, // scraper gets 403 while running on AWS
defilmhallen,
deuitkijk,
eyefilm,
filmhuisdenhaag,
Expand Down
6 changes: 6 additions & 0 deletions web/data/cinema.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,5 +154,11 @@
"city": "Nijmegen",
"url": "https://www.lux-nijmegen.nl",
"logo": "lux.png"
},
{
"name": "De Filmhallen",
"city": "Amsterdam",
"url": "https://www.filmhallen.nl/",
"logo": "defilmhallen.png"
}
]
Binary file added web/public/images/defilmhallen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c8d6fdc

Please sign in to comment.