kody revised this gist . Go to revision
3 files changed, 1 insertion, 52 deletions
README.md(file created)
@@ -0,0 +1 @@ | |||
1 | + | See: https://git.rita.moe/kody/rss2json |
config.php (file deleted)
@@ -1,10 +0,0 @@ | |||
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 (file deleted)
@@ -1,42 +0,0 @@ | |||
1 | - | <?php | |
2 | - | require_once __DIR__ . '/config.php'; | |
3 | - | ||
4 | - | // First, login | |
5 | - | $cLogin = curl_init($base . 'api/greader.php/accounts/ClientLogin?Email=' . $user . '&Passwd=' . $pass); | |
6 | - | curl_setopt($cLogin, CURLOPT_SSL_VERIFYHOST, 0); | |
7 | - | curl_setopt($cLogin, CURLOPT_SSL_VERIFYPEER, 0); | |
8 | - | curl_setopt($cLogin, CURLOPT_RETURNTRANSFER, true); | |
9 | - | $keys = curl_exec($cLogin); | |
10 | - | curl_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'); | |
14 | - | curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); | |
15 | - | curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); | |
16 | - | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
17 | - | curl_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); | |
22 | - | curl_close($ch); | |
23 | - | ||
24 | - | // We'll now go thru the results | |
25 | - | $out = []; | |
26 | - | foreach ($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 | |
42 | - | file_put_contents('public/rss.json', json_encode($out)); |
kody revised this gist . Go to revision
1 file changed, 0 insertions, 0 deletions
gistfile1.txt renamed to config.php
File renamed without changes
kody revised this gist . Go to revision
2 files changed, 52 insertions
cron.php(file created)
@@ -0,0 +1,42 @@ | |||
1 | + | <?php | |
2 | + | require_once __DIR__ . '/config.php'; | |
3 | + | ||
4 | + | // First, login | |
5 | + | $cLogin = curl_init($base . 'api/greader.php/accounts/ClientLogin?Email=' . $user . '&Passwd=' . $pass); | |
6 | + | curl_setopt($cLogin, CURLOPT_SSL_VERIFYHOST, 0); | |
7 | + | curl_setopt($cLogin, CURLOPT_SSL_VERIFYPEER, 0); | |
8 | + | curl_setopt($cLogin, CURLOPT_RETURNTRANSFER, true); | |
9 | + | $keys = curl_exec($cLogin); | |
10 | + | curl_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'); | |
14 | + | curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); | |
15 | + | curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); | |
16 | + | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
17 | + | curl_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); | |
22 | + | curl_close($ch); | |
23 | + | ||
24 | + | // We'll now go thru the results | |
25 | + | $out = []; | |
26 | + | foreach ($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 | |
42 | + | file_put_contents('public/rss.json', json_encode($out)); |
gistfile1.txt(file created)
@@ -0,0 +1,10 @@ | |||
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 | + | ]; |