-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve hydration hits and output summary after run
- Loading branch information
1 parent
28f7eec
commit 079e9b3
Showing
8 changed files
with
201 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
const knownRemovablePhrases = require("./known-removable-phrases.json"); | ||
|
||
function normalizeTitle(title) { | ||
title = title.toLowerCase(); | ||
|
||
const removablePrefixes = [ | ||
"Scared To Dance -", | ||
"Hitchcock: The Gainsborough Days -", | ||
]; | ||
|
||
removablePrefixes.forEach((phrase) => { | ||
title = title.replace(phrase.toLowerCase(), ""); | ||
}); | ||
|
||
const hasPresents = title.match(/\s+presents?:?\s+(.*?)$/i); | ||
if (hasPresents) { | ||
title = hasPresents[1]; | ||
} | ||
|
||
const hasPresented = title.match(/^(.*?)\s+presented\s+/i); | ||
if (hasPresented) { | ||
title = hasPresented[1]; | ||
} | ||
|
||
const hasSeparator = title.match(/^(.*?)\s+(?:\+|\-)\s*/); | ||
if (hasSeparator) { | ||
title = hasSeparator[1]; | ||
} | ||
|
||
const hasSquareBracketDate = title.trim().match(/^(.*?)\[(\d{4})\](.*?)$/); | ||
if (hasSquareBracketDate) { | ||
title = `${hasSquareBracketDate[1]}(${hasSquareBracketDate[2]})${hasSquareBracketDate[3]}`; | ||
} | ||
|
||
const hasBrackets = title.match(/^(.*?)\s+\[/); | ||
if (hasBrackets) { | ||
title = hasBrackets[1]; | ||
} | ||
|
||
knownRemovablePhrases.forEach((phrase) => { | ||
title = title.replace(phrase.toLowerCase(), ""); | ||
}); | ||
|
||
const hasYear = title.trim().match(/\(\d{4}\)$/); | ||
if (!hasYear) { | ||
title = title.replace(/\([^(]*\)$/, "").trim(); | ||
title = title.replace(/\([^(]*\)$/, "").trim(); // Do it twice in case there's more paraenthesis | ||
} | ||
|
||
return title | ||
.replace(/\s*:\s+/g, ": ") | ||
.trim() | ||
.replace(/:$/, "") | ||
.replace(/'|’/g, "") | ||
.replace(/\s+(-|–)(\s|$)/g, " ") | ||
.replace(/\s+/g, " ") | ||
.trim(); | ||
} | ||
|
||
module.exports = normalizeTitle; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,8 @@ | |
"scripts": { | ||
"test": "jest", | ||
"format": "prettier \"./**/*.js(on)?\" --write && prettier \"./**/*.md\" --write --prose-wrap=always", | ||
"generate": "TZ=Europe/London node index.js" | ||
"generate": "TZ=Europe/London node index.js", | ||
"output:highlight-hydration-misses-for-review": "node ./scripts/highlight-hydration-misses-for-review.js" | ||
}, | ||
"author": "Alistair Brown <[email protected]>", | ||
"license": "MIT", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
REPO_URL='https://api.github.com/repos/alistairjcbrown/hackney-cinema-calendar/releases/latest' | ||
|
||
RESPONSE_LIST=$(curl -L -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" $REPO_URL) | ||
|
||
for f in $(echo "$RESPONSE_LIST" | grep browser_download | grep json | cut -d\" -f4); | ||
do | ||
wget "$f" -P ./output/ | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
const path = require("node:path"); | ||
const getSites = require("../common/get-sites"); | ||
const normalizeTitle = require("../common/normalize-title"); | ||
|
||
const termsExpectedToNotMatch = [ | ||
// Multiple films | ||
/All\-Nighter/i, | ||
/Marathon/i, | ||
/Double Feature/i, | ||
/Trilogy/i, | ||
/Mystery Movie/i, | ||
|
||
// Non feature film events | ||
/Comedy Night/i, | ||
/\s+Comedy$/i, | ||
/Concert/i, | ||
/Quiz/i, | ||
/Filmmakers.*?Club/i, | ||
/TV Preview:/i, | ||
/short Film/i, | ||
/ shorts: /i, | ||
/^Behind the Scenes:/i, | ||
/^Member Exclusive: .* Tour$/i, | ||
/Session \d+/i, | ||
/Season \d+/i, | ||
/Programme \d+/i, | ||
/Live in 3D/i, | ||
/New Writings/i, | ||
/Lecture:/i, | ||
/Animation Workshop/i, | ||
/Poetry Slam/i, | ||
/ in conversation/i, | ||
/Stunt Saturday/i, | ||
/the art of /i, | ||
|
||
// Comunity events | ||
/Library Talk/i, | ||
/Library Research Session/i, | ||
/Women’s Voices Forum/i, | ||
/Free Talk:/i, | ||
/Raising Awareness of/i, | ||
|
||
// Film festival | ||
/Opening Gala/i, | ||
/Film Awards/i, | ||
|
||
// Live recordings | ||
/^NT Live:/i, | ||
/^RBO[^:]*:/i, | ||
/^The Royal Ballet:/i, | ||
/^Met Opera[^:]*:/i, | ||
/^The Metropolitan Opera:/i, | ||
/^The Royal Opera:/i, | ||
/^MACBETH:/i, | ||
/EXHIBITION ON SCREEN:/i, | ||
/^Play for Today:/i, | ||
/^Performance:/i, | ||
|
||
// Music | ||
/at The Ritzy/i, | ||
/Live Sessions/i, | ||
/Pitchblack Playback/i, | ||
/Dub Me Always:/i, | ||
/Your Gospel Night/i, | ||
/Funky Stuff/i, | ||
/Vinyl Sisters/i, | ||
]; | ||
|
||
const expectedMatch = ({ title }) => { | ||
const notExpectedToMatch = termsExpectedToNotMatch.some( | ||
(term) => !!title.toLowerCase().match(term), | ||
); | ||
if (notExpectedToMatch) return false; | ||
return true; | ||
}; | ||
|
||
const data = getSites().reduce( | ||
(mapping, site) => ({ | ||
...mapping, | ||
[site]: require(path.join(__dirname, "..", "output", `${site}-shows.json`)), | ||
}), | ||
{}, | ||
); | ||
|
||
const flaggedForReview = {}; | ||
Object.keys(data).forEach((site) => { | ||
const siteData = data[site]; | ||
siteData.forEach((show) => { | ||
if (!show.moviedb && expectedMatch(show)) { | ||
flaggedForReview[show.title] = flaggedForReview[show.title] || []; | ||
flaggedForReview[show.title].push({ site, show }); | ||
} | ||
}); | ||
}); | ||
|
||
Object.keys(flaggedForReview).forEach((key, index) => { | ||
const matches = flaggedForReview[key]; | ||
const normalizedTitle = normalizeTitle(key); | ||
const year = matches[0].show.overview.year; | ||
console.log(`${index + 1}. "${normalizedTitle}"${year ? ` (${year})` : ""}`); | ||
console.log(` - Original: "${key}"`); | ||
console.log( | ||
` - Search for matches: https://www.themoviedb.org/search/movie?query=${encodeURIComponent(normalizedTitle)}`, | ||
); | ||
console.log(` - Source: ${matches[0].show.url}`); | ||
console.log(" "); | ||
}); |