diff --git a/README.md b/README.md index 5eaa49f7..c58aa305 100644 --- a/README.md +++ b/README.md @@ -189,6 +189,7 @@ Use this script to generate the list automatically (using the GitHub API): * [hunhejj](https://github.com/hunhejj) * [husim0](https://github.com/husim0) * [IceWreck](https://github.com/IceWreck) +* [imagoiq](https://github.com/imagoiq) * [j0k3r](https://github.com/j0k3r) * [JackNUMBER](https://github.com/JackNUMBER) * [jacquesh](https://github.com/jacquesh) @@ -223,7 +224,7 @@ Use this script to generate the list automatically (using the GitHub API): * [m0zes](https://github.com/m0zes) * [Mar-Koeh](https://github.com/Mar-Koeh) * [marcus-at-localhost](https://github.com/marcus-at-localhost) -* [marius851000](https://github.com/marius851000) +* [marius8510000-bot](https://github.com/marius8510000-bot) * [matthewseal](https://github.com/matthewseal) * [mcbyte-it](https://github.com/mcbyte-it) * [mdemoss](https://github.com/mdemoss) @@ -238,6 +239,7 @@ Use this script to generate the list automatically (using the GitHub API): * [mro](https://github.com/mro) * [mschwld](https://github.com/mschwld) * [mxmehl](https://github.com/mxmehl) +* [Mynacol](https://github.com/Mynacol) * [nel50n](https://github.com/nel50n) * [niawag](https://github.com/niawag) * [Niehztog](https://github.com/Niehztog) @@ -294,6 +296,8 @@ Use this script to generate the list automatically (using the GitHub API): * [thezeroalpha](https://github.com/thezeroalpha) * [timendum](https://github.com/timendum) * [TitiTestScalingo](https://github.com/TitiTestScalingo) +* [tomaszkane](https://github.com/tomaszkane) +* [TReKiE](https://github.com/TReKiE) * [triatic](https://github.com/triatic) * [VerifiedJoseph](https://github.com/VerifiedJoseph) * [WalterBarrett](https://github.com/WalterBarrett) diff --git a/bridges/CdactionBridge.php b/bridges/CdactionBridge.php index 5b751a5b..6712faf6 100644 --- a/bridges/CdactionBridge.php +++ b/bridges/CdactionBridge.php @@ -2,21 +2,50 @@ class CdactionBridge extends BridgeAbstract { const NAME = 'CD-ACTION bridge'; - const URI = 'https://cdaction.pl/newsy'; - const DESCRIPTION = 'Fetches the latest news.'; + const URI = 'https://cdaction.pl'; + const DESCRIPTION = 'Fetches the latest posts from given category.'; const MAINTAINER = 'tomaszkane'; + const PARAMETERS = array( array( + 'category' => array( + 'name' => 'Kategoria', + 'type' => 'list', + 'values' => array( + 'Najnowsze (wszystkie)' => 'najnowsze', + 'Newsy' => 'newsy', + 'Recenzje' => 'recenzje', + 'Teksty' => array( + 'Publicystyka' => 'publicystyka', + 'Zapowiedzi' => 'zapowiedzi', + 'Już graliśmy' => 'juz-gralismy', + 'Poradniki' => 'poradniki', + ), + 'Kultura' => 'kultura', + 'Wideo' => 'wideo', + 'Czasopismo' => 'czasopismo', + 'Technologie' => array( + 'Artykuły' => 'artykuly', + 'Testy' => 'testy', + ), + 'Na luzie' => array( + 'Konkursy' => 'konkursy', + 'Nadgodziny' => 'nadgodziny', + ) + ) + )) + ); public function collectData() { - $html = getSimpleHTMLDOM($this->getURI()); + $html = getSimpleHTMLDOM($this->getURI() . '/' . $this->getInput('category')); $newsJson = $html->find('script#__NEXT_DATA__', 0)->innertext; if (!$newsJson = json_decode($newsJson)) { return; } - foreach ($newsJson->props->pageProps->dehydratedState->queries[1]->state->data->results as $news) { + $queriesIndex = $this->getInput('category') === 'najnowsze' ? 0 : 1; + foreach ($newsJson->props->pageProps->dehydratedState->queries[$queriesIndex]->state->data->results as $news) { $item = array(); - $item['uri'] = $this->getURI() . '/' . $news->slug; + $item['uri'] = $this->getURI() . '/' . $news->category->slug . '/' . $news->slug; $item['title'] = $news->title; $item['timestamp'] = $news->publishedAt; $item['author'] = $news->editor->fullName;