Last active 1694371828

config.php Raw
1<?php
2$base = 'https://rss.do.kdy.ch/';
3$user = '<USER>';
4$pass = '<PASS>';
5$exclude = [
6 'YouTube',
7 'YouTube (VT)',
8 'YouTube Subscriptions Feed',
9 'Patreon'
10];
cron.php Raw
1<?php
2require_once __DIR__ . '/config.php';
3
4// First, login
5$cLogin = curl_init($base . 'api/greader.php/accounts/ClientLogin?Email=' . $user . '&Passwd=' . $pass);
6curl_setopt($cLogin, CURLOPT_SSL_VERIFYHOST, 0);
7curl_setopt($cLogin, CURLOPT_SSL_VERIFYPEER, 0);
8curl_setopt($cLogin, CURLOPT_RETURNTRANSFER, true);
9$keys = curl_exec($cLogin);
10curl_close($cLogin);
11
12// Then we fetch our feed (max 1000 elements) excluding those marked as read
13$ch = curl_init($base . 'api/greader.php/reader/api/0/stream/contents/reading-list?n=1000&xt=user/-/state/com.google/read');
14curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
15curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
16curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
17curl_setopt($ch, CURLOPT_HTTPHEADER, array(
18 'Authorization:GoogleLogin ' . str_replace('Auth=','auth=', explode("\n", $keys)[2])
19));
20$out = curl_exec($ch);
21$json = json_decode($out);
22curl_close($ch);
23
24// We'll now go thru the results
25$out = [];
26foreach ($json->items as $item) {
27 // If the source matches the exclude list, ignore
28 if (in_array($item->origin->title, $exclude)) continue;
29 // If it has a Newsletters label, ignore
30 if (in_array('user/-/label/Newsletters', $item->categories)) continue;
31
32 $u = $item->alternate[0]->href;
33 $out[] = array(
34 'id' => $item->id,
35 'title' => $item->title,
36 'source' => $item->origin->title,
37 'link' => empty($u) ? $base . 'i/' : $u
38 );
39}
40
41// And we save the results as json
42file_put_contents('public/rss.json', json_encode($out));