Skip to content

Instantly share code, notes, and snippets.

@anarchivist
Last active November 18, 2023 23:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anarchivist/0cdde79c5a311baa4169f965e5c68ced to your computer and use it in GitHub Desktop.
Save anarchivist/0cdde79c5a311baa4169f965e5c68ced to your computer and use it in GitHub Desktop.
Wikidata query for Movies starring Nicolas Cage that are not direct to video/video on demand
# Films starring Nicolas Cage that are not direct to video/video on demand
# Intended to help making it easier to load this data into a Letterboxd list
# See https://letterboxd.com/about/importing-data/ for more info
SELECT ?item
?itemLabel
?LetterboxdURI
(?itemLabel AS ?Title)
(YEAR(MIN(?date)) AS ?Year)
(GROUP_CONCAT(DISTINCT ?directorLabel; SEPARATOR = ", ") AS ?Directors)
WHERE {
?item
# include all subclasses of film (e.g. feature film, etc.) - excludes film series
p:P31/ps:P31/wdt:P279* wd:Q11424;
# by using P161, we are implicitly excluding things where Cage is a voice actor
wdt:P161 wd:Q42869;
wdt:P57 ?director;
wdt:P577 ?date .
wd:P6127 wdt:P1630 ?formatterurl .
?director rdfs:label ?directorLabel .
OPTIONAL { ?item wdt:P6127 ?letterboxdId . }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" . }
VALUES ?distributionFilter {
wd:Q723685
wd:Q844580
}
FILTER(NOT EXISTS { ?item wdt:P437 ?distributionFilter . })
# Films without Letterboxd IDs can be safely presumed to be unavailable
FILTER(EXISTS { ?item wdt:P6127 ?letterboxdId . })
FILTER((LANG(?directorLabel)) = "en")
BIND(IRI(REPLACE(?letterboxdId, "^(.+)$", ?formatterurl)) AS ?LetterboxdURI)
}
GROUP BY ?item ?itemLabel ?LetterboxdURI
ORDER BY (?Year)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment