diff --git a/bridges/SamMobileUpdateBridge.php b/bridges/SamMobileUpdateBridge.php new file mode 100644 index 00000000..ea158db7 --- /dev/null +++ b/bridges/SamMobileUpdateBridge.php @@ -0,0 +1,55 @@ + [ + 'name' => 'Model', + 'exampleValue' => 'SM-S926B', + 'required' => true, + ], + 'country' => [ + 'name' => 'Country', + 'exampleValue' => 'EUX', + 'required' => true, + ] + ] + ]; + const CACHE_TIMEOUT = 7200; // 2h + + public function collectData() + { + $model = $this->getInput('model'); + $country = $this->getInput('country'); + $uri = self::URI . $model . '/' . $country; + $html = getSimpleHTMLDOM($uri); + + $elementsDom = $html->find('.main-content-item__content.main-content-item__content-md table tbody tr'); + + foreach ($elementsDom as $elementDom) { + $item = []; + + $td = $elementDom->find('td'); + + $title = 'Security patch: ' . $td[2] . ' - Android version: ' . $td[3] . ' - PDA: ' . $td[4]; + $text = 'Model: ' . $td[0] . '
Country/Carrier: ' . $td[1] . '
Security patch: ' . $td[2] . '
OS version: Android ' . $td[3] . '
PDA: ' . $td[4]; + + $item['uri'] = $uri; + $item['title'] = $title; + $item['author'] = self::MAINTAINER; + $item['timestamp'] = (new DateTime($td[2]->innertext))->getTimestamp(); + $item['content'] = $text; + $item['uid'] = hash('sha256', $item['title']); + + $this->items[] = $item; + } + } +}