Skip to content
This repository was archived by the owner on Apr 30, 2021. It is now read-only.

Commit b5f1f7c

Browse files
committed
Update to new c2corg api
1 parent 860615c commit b5f1f7c

File tree

2 files changed

+21
-30
lines changed

2 files changed

+21
-30
lines changed

get_data

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ download () {
5454

5555
download skitour "http://www.skitour.fr/topos/dernieres-sorties.php?nbr=100" &
5656
download volo "http://www.volopress.net/volo/spip.php?rubrique2" &
57-
download c2c "http://localhost/outings/list/act/1/layout/light/npp/60" www.camptocamp.org &
57+
download c2c "https://api.camptocamp.org/outings?act=skitouring&pl=fr" &
5858
download SNGM "http://www.montagneinfo.net/flux/activites.php?NoIDActivite=11" &
5959
download gulliver.sr "http://www.gulliver.it/sci-ripido/" &
6060
download gulliver.sa "http://www.gulliver.it/scialpinismo/" &

sites.inc.php

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -803,36 +803,27 @@ function parse_SNGM(&$textall)
803803
function parse_Skirando(&$textall,$last_id)
804804
{
805805
global $dlim;
806-
// on garde que la partie interessante.
807-
$entries = explode('</tr>',substr($textall,strpos($textall,'<tbody>')));
808-
$textall = '';
809-
$new_id = $last_id;
810806

811-
$n = count($entries)-1;
812-
for ($i = 0;$i<$n; $i++)
813-
{
814-
$items = explode('</td>',$entries[$i]);
815-
$lien = substr($items[1],strpos($items[1],'<a href="..')+9);
816-
$lien = substr($lien,0,strpos($lien,'">'));
817-
ereg('/outings/([0-9]+)',$lien,$regs); $id = $regs[1];
818-
if ($id > $last_id)
819-
{
820-
$nom = trim(strip_tags($items[1]));
821-
$date = trim(strip_tags($items[2]));
822-
$cot = trim(strip_tags($items[6]));
823-
$reg = trim(strip_tags($items[9]));
824-
$part = trim(strip_tags($items[12]));
825-
// interprete la date :
826-
$jma = explode(' ',$date);
827-
if (strlen($jma[0]) == 1) $jma[0] = "0{$jma[0]}";
828-
$date = "{$jma[2]}-" . get_mois($jma[1]) . "-{$jma[0]}";
829-
// pour etre ecrit plus tard :
830-
if ($date < $dlim) break; // pas plus vieux que 1 mois.
831-
$textall .= "c2c $id\n$date $cot\n$nom\nhttp://www.camptocamp.org/outings/$id\n$reg\n$part\n";
832-
if ($id > $new_id) $new_id = $id;
833-
}
834-
}
835-
return $new_id;
807+
$obj = json_decode($textall, true);
808+
$outings = $obj['documents'];
809+
$textall = '';
810+
811+
$new_id = $last_id;
812+
813+
foreach ($outings as $outing) {
814+
$id = $outing['document_id'];
815+
$date = $outing['date_start'];
816+
$name = $outing['locales'][0]['title'];
817+
$link = 'https://www.camptocamp.org/outings/' . $id;
818+
$area = get_area($outing);
819+
$cotation = ""; // TODO get_cotation($outing);
820+
$author = $outing['author']['name'];
821+
if ($date < $dlim) break; // not older than one month
822+
$textall .= "c2c $id\n$date $cotation\n$name\n$link\n$area\n$author\n";
823+
if ($id > $new_id) $new_id = $id;
824+
}
825+
826+
return $new_id;
836827
}
837828

838829
// cherche la cot d'une volo-course si dispo (et ajoute les participants !)

0 commit comments

Comments
 (0)