Skip to content

Instantly share code, notes, and snippets.

@legecha
Last active January 31, 2024 22:44
Show Gist options
  • Select an option

  • Save legecha/887c840cfeb19809acb35731edefc195 to your computer and use it in GitHub Desktop.

Select an option

Save legecha/887c840cfeb19809acb35731edefc195 to your computer and use it in GitHub Desktop.
A quick and dirty script to generate a CSV of runs for Games Done Quick events
<?php
/**
* After GDQ events, I like to make a quick spreadsheet and tick off
* all the runs I've seen, and then catch up on all the ones I've
* missed in the vods.
*
* They're using the Vercel app now and a helpful open endpoint
* exposes the data. This quick and dirty script will output a CSV
* that you can import into your favourite editor with the info you
* need to track your viewing.
*
* Donate to the Prevent Cancer Foundation if you can, and treat
* yourself to a salad :)
*/
$schedule = json_decode(file_get_contents('https://gdq-site.vercel.app/api/schedule/46'));
fputcsv(STDOUT, [
'watched',
'name',
'runner',
'category',
'console',
'youtube',
]);
foreach ($schedule as $type => $runs) {
if ($type == 'event') {
continue;
}
foreach ($runs as $run) {
if ($run->type == 'speedrun') {
fputcsv(STDOUT, [
false,
$run->display_name ?? $run->name ?? null,
is_array($run->runners)
? implode(', ', array_map(
fn ($runner) => $runner->type == 'runner' ? $runner->name : null, $run->runners
)) : null,
$run->category ?? null,
$run->console ?? null,
$run?->video_links[0]?->url ?? null,
]);
} elseif ($run->type == 'interview') {
$runner = $run->interviewers ?? null;
if ('' !== $run->subjects) {
$runner = (null === $runner) ? $run->subjects : ', '.$run->subjects;
}
fputcsv(STDOUT, [
false,
$run->topic ?? null,
$run->interviewers ?? null,
null,
null,
null,
]);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment