Public
Edited
Jan 18, 2023
1 fork
Importers
1 star
Insert cell
Insert cell
Insert cell
Insert cell
// BMovies = d3.json("https://legitbackend.wtf/b-movies?limit=200") // the live dataset #dead
Insert cell
BMovies = FileAttachment("latest bmovies.txt.json").json()
// BMovies = FileAttachment("b-movies.json").json() // old DB
Insert cell
Insert cell
// dups = _(BMovies.map((m) => m.id)).countBy().reduce((acc, val, key) => val > 1 ? acc.concat(key) : acc, [])
Insert cell
// What_Dupes = dups.map(d=> BMovies.filter(movie=> movie.id == d))
Insert cell
// first_dup = _.findIndex(BMovies, ['id', +dups[0]]);
Insert cell
// last_dup = _.findLastIndex(BMovies, ['id', +dups[0]]);
Insert cell
// _.isEqual(BMovies[first_dup], BMovies[last_dup]);
Insert cell
Insert cell
bmovies_noDupe = {
if (remove_dupes>0) {

let noDupsBMovies = []
let dups = _(BMovies.map((m) => m.id)).countBy().reduce((acc, val, key) => val > 1 ? acc.concat(key) : acc, [])
let What_Dupes = dups.map(d=> BMovies.filter(movie=> movie.id == d))
let first_dup = _.findIndex(BMovies, ['id', +dups[0]]);
let last_dup = _.findLastIndex(BMovies, ['id', +dups[0]]);

if(_.isEqual(BMovies[first_dup], BMovies[last_dup])) {
noDupsBMovies = BMovies.filter(function(value, index, arr) { return index != last_dup;});
}
return noDupsBMovies
}
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
jobs = _.uniq(_.flatten(BMovies.map(m => m.crew.map(c => c.job))))
Insert cell
departments = _.uniq(_.flatten(BMovies.map(m => m.crew.map(c => c.department))))
Insert cell
crew_names = _.uniq(_.flatten(BMovies.map(m => m.crew.map(c => c.name))))
Insert cell
cast_names = _.uniq(_.flatten(BMovies.map(m => m.cast.map(c => c.name))))
Insert cell
cast_known_for_department = _.uniq(_.flatten(BMovies.map(m => m.cast.map(c => c.known_for_department))))
Insert cell
crw = _.flatten(BMovies.map(m => m.crew.map(c => {
return {name:c.name,id:c.id,known_for_department:c.known_for_department,department:c.department,job:c.job}
})))
Insert cell
viewof table = Inputs.table(crw)
Insert cell
Insert cell
crew_occurences = _.uniq(_.flatten(BMovies.map(m => m.crew.map(c => c.id))))
Insert cell
crew_occurences2 = _.toPairs( _.pick(_.countBy(crw, 'id'),crew_occurences))
Insert cell
Insert cell
Insert cell
cast_occurences = _.uniq(_.flatten(BMovies.map(m => m.cast.map(c => c.id))))
Insert cell
cast_occurences2 = _.toPairs( _.pick(_.countBy(crw, 'id'),cast_occurences))
Insert cell
viewof table2 = Inputs.table(cast_occurences2)
Insert cell
Insert cell
Insert cell
teGenres = _.uniq(_.flatten(BMovies.map(m=> m.genres.map( g => g.name))))
Insert cell
Insert cell
Insert cell
Insert cell
viewof what = Inputs.table(BMovies)
Insert cell
what // view of the data from selected items in above table,
Insert cell
mo
Insert cell
Insert cell
Insert cell
no_production_country = _.compact(BMovies.map((m,i) => (m.production_countries.length == 0)?i:null))
Insert cell
md_no_pco = no_production_country.map(m =>
`${BMovies[m].original_title}
<a href="https://www.imdb.com/title/${BMovies[m].imdb_id}/fullcredits" target="_blank">idbm</a>
<a href="https://www.themoviedb.org/movie/${BMovies[m].id}" target="_blank">movedb</a><br>`
)
Insert cell
production_companies = _.uniq(_.flatten(BMovies.map(m=> m.production_companies.map( g => g.name))))
Insert cell
Insert cell
no_production_company = _.compact(BMovies.map((m,i) => (m.production_companies.length == 0)?i:null))
Insert cell
Insert cell
Insert cell
BMovies[select].original_title
Insert cell
BMovies[select].production_companies
Insert cell
BMovies[select]
Insert cell
Insert cell
Insert cell
viewof pc_text = Inputs.text({label: "Type in Production Complany name."})
Insert cell
viewof set_text = Inputs.button(`Set '${pc_text}'' to: ${BMovies[select].original_title} `)
Insert cell
{
if (set_text>0) {
BMovies[select].production_companies.push(pc_text)
return BMovies[select].original_title
}
}
Insert cell
Insert cell
Insert cell
keys = _.keysIn(BMovies[0])
Insert cell
Insert cell
Insert cell
import {toc} from "@nebrius/indented-toc"
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more