Mastodon github.com/rknightuk proven.lol/aaecd5

DoubleShift

posts 2023-11-27

I have watched Scrubs more times than I can count and I am currently re-watching Grey's Anatomy for the third (maybe fourth?) time. I noticed there are a lot of actors who have appeared in both and it seemed like it was every other episode. After some data-wrangling I have an actual answer: 28 actors have appeared in both series.

The Idea

I thought it would be fun to show this on a site along with highlighting what I'm calling "double doctors": that is, actors who have played a doctor in both shows. The site is called DoubleShift and it has this nifty logo I whipped up:

DoubleShift logo

I mentioned this idea to David and he asked what the numbers were like against House. So I added House to my dataset: 78 actors have appeared in Grey's and House, and 48 have appeared in Scrubs and House. I also added ER because that had a lot of crossover too.

I briefly added General Hospital because of how long it has been running but there was just one actress who has been in any of the other shows so I removed it again. Also, adding even one more show generates so many more permutations.

Handling the Data

To fetch the actor data for each show I used The Movie Database API which has a handy "Aggregate Credits" endpoint for fetching all actors who have been in a show across all seasons. I then mapped that data to a keyed object by their TMDB ID:

const res = await fetch(`https://api.themoviedb.org/3/tv/${show.id}/aggregate_credits?&series_id=1416&language=en-US`, {
headers: {
'Authorization': `Bearer ${process.env.API_KEY}`,
'accept': 'application/json'
}
})
const json = await res.json()
const data = {}

json.cast.forEach((actor) => {
data[actor.id] = {
...actor,
}
})

To find the actors who have been in both shows a filter did the trick:

const intersection = Object.keys(showData[showOne]).filter(element => Object.keys(showData[showTwo]).includes(element))

// console.log(intersection)
// [123, 3456, 3456]

I used Eleventy like I always do because it's data files are perfect at handling this kind of thing and using nunjucks is easy-peasy to output what I want. I decided to avoid using javascript on the site itself here so I used CSS and radio buttons to show and hide each combination of show.

#show-greys-scrubs {
display: none;
}

#greys-scrubs:checked ~ #show-greys-scrubs {
display: none;
}

It's worth noting that when using the subsequent-sibling combinator (~) the two elements must be children of the same parent so I couldn't have the radio buttons inside their own container which made styling them slightly harder, but a small price to pay to not rely on JS here.

View the DoubleShift site here and you can view the source on GitHub

  • Update 2023-11-28: Added four more shows and leaderboards
  • Update 2023-11-30: Check out Crossover to compare any two TV shows

Popular Posts

Analytics powered by Fathom