Check-in [2f4cf1ea0f]
Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Xfer cron.job for freshcode.clb JSON feed importing. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | mirror |
Files: | files | file ages | folders |
SHA1: |
2f4cf1ea0f16b21335bd652600a8374b |
User & Date: | mario 2014-11-16 16:19:36 |
Context
2014-11-16
| ||
16:24 | Switch to manual dependency loading Leaf check-in: 45e1f25efb user: mario tags: mirror | |
16:19 | Xfer cron.job for freshcode.clb JSON feed importing. check-in: 2f4cf1ea0f user: mario tags: mirror | |
16:16 | empty default files check-in: 79e42f8f28 user: mario tags: mirror | |
Changes
Added cron.daily/xfer.php.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | <?php /** * api: cli * title: XFER import * description: fetches central feed (freshcode.club), and imports new entries * version: 0.0 * type: cron * x-cron: 0,6,12,18 * * * * * category: import * * * Fetches `http://freshcode.club/feed/xfer.json` for importing new entries. * Will forgo minor edits / t_changed entries, but import all new projects and * releases. * */ chdir(dirname(__DIR__)); include("./config.php"); // retrieve $API = "http://freshcode.club/feed/xfer.json?num=100"; $json = curl($API)->exec(); $json = json_decode($json, TRUE); // import foreach ($json["releases"] as $r) { // if name+version combo unknown if (!release::exists($r["name"], $r["version"])) { // fetch any previous data $push = new release($r["name"]); // most fields come in reusable, // some need updating: array_walk($r["urls"], function(&$v, $k) { $v = "$k = $v"; }); $r["urls"] = join("\n", $r["urls"]); // update DB fields $push->update( // newdata $r, // prefill [], // override flags [ "hidden" => intval($r["hidden"]), "t_published" => strtotime($r["published"]), "t_changed" => strtotime($r["changed"]), ], // $_partial = FALSE ); $push->store(); print_r($push); } } |