From 655d72e6f9a2bfdeef91e511728828eea44b62cc Mon Sep 17 00:00:00 2001 From: emkael Date: Thu, 31 Jan 2019 17:43:53 +0100 Subject: Untappd provider --- providers/Untappd.php | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 providers/Untappd.php (limited to 'providers') diff --git a/providers/Untappd.php b/providers/Untappd.php new file mode 100644 index 0000000..95c7ab7 --- /dev/null +++ b/providers/Untappd.php @@ -0,0 +1,66 @@ +find('div.beer-item') as $div) { + $details = $div->find('div.beer-details, div.details'); + if ($details) { + $texts = [ + $details->find('p.name')->text(), + $details->find('p.style')->text(), + $details->find('p.desc')->eq(1)->text(), + $details->find('p.abv')->text(), + $details->find('p.ibu')->text() + ]; + $items[] = [ + 'id' => $div->attr()['data-bid'], + 'link' => $div->find('a.label')->attr()['href'], + 'name' => $texts[0], + 'texts' => $texts, + 'time' => trim($details->find('p.date')->text()) + ]; + } + } + return array_values($items); + } + + protected function _mapItems($content) { + return array_map( + function ($obj) { + $item = new Item(); + $item->ID = $obj['id']; + $item->Link = sprintf('https://untappd.com/%s', $obj['link']); + $item->Title = sprintf('New beer by %s: %s', $this->_feed, $obj['name']); + $item->Text = implode('
', $obj['texts']); + $item->Time = strtotime(str_replace('Added ', '', $obj['time']) . ' 00:00:00'); + return $item; + }, + $content + ); + } + + public function title() { + return sprintf("%s's untappd beer list", $this->_feed); + } + +} + +?> -- cgit v1.2.3