[ 'name' => 'Channel URL', 'type' => 'text', 'required' => true, 'title' => 'The channel\'s URL', 'exampleValue' => 'https://dzen.ru/dream_faity_diy', ], 'limit' => [ 'name' => 'Limit', 'type' => 'number', 'required' => false, 'title' => 'Number of posts to display. Max is 20.', 'exampleValue' => '20', 'defaultValue' => 20, ], ], ]; # credit: https://github.com/teromene see #1032 const _BASE_API_URL_WITH_CHANNEL_NAME = 'https://dzen.ru/api/v3/launcher/more?channel_name='; const _BASE_API_URL_WITH_CHANNEL_ID = 'https://dzen.ru/api/v3/launcher/more?channel_id='; const _ACCOUNT_URL_WITH_CHANNEL_ID_REGEX = '#^https?://dzen\.ru/id/(?[a-z0-9]{24})#'; const _ACCOUNT_URL_WITH_CHANNEL_NAME_REGEX = '#^https?://dzen\.ru/(?[\w\.]+)#'; private $channelRealName = null; # as shown in the webpage, not in the URL public function collectData() { $channelURL = $this->getInput('channelURL'); if (preg_match(self::_ACCOUNT_URL_WITH_CHANNEL_ID_REGEX, $channelURL, $matches)) { $channelID = $matches['channelID']; $channelAPIURL = self::_BASE_API_URL_WITH_CHANNEL_ID . $channelID; } elseif (preg_match(self::_ACCOUNT_URL_WITH_CHANNEL_NAME_REGEX, $channelURL, $matches)) { $channelName = $matches['channelName']; $channelAPIURL = self::_BASE_API_URL_WITH_CHANNEL_NAME . $channelName; } else { returnClientError(<<channelRealName = $APIResponse->header->title; $limit = $this->getInput('limit'); foreach (array_slice($APIResponse->items, 0, $limit) as $post) { $item = []; $item['uri'] = $post->share_link; $item['title'] = $post->title; $publicationDateUnixTimestamp = $post->publication_date ?? null; if ($publicationDateUnixTimestamp) { $item['timestamp'] = date(DateTimeInterface::ATOM, $publicationDateUnixTimestamp); } $postImage = $post->image ?? null; $item['content'] = $post->text; if ($postImage) { $item['content'] .= "
"; $item['enclosures'] = [$postImage]; } $this->items[] = $item; } } public function getURI() { if (is_null($this->getInput('channelURL'))) { return parent::getURI(); } return $this->getInput('channelURL'); } public function getName() { if (is_null($this->channelRealName)) { return parent::getName(); } return $this->channelRealName . '\'s latest zen.yandex posts'; } } fix/node-tests'>derrick/fix/node-tests Unnamed repository; edit this file 'description' to name the repository.
aboutsummaryrefslogtreecommitdiff
AgeCommit message (Expand)AuthorFilesLines
2022-04-03wipGravatar Jarred Sumner 120-20/+8988
2022-04-03[bun.js] Expose `ImageData` globallyGravatar Jarred Sumner 12-2/+1237
2022-04-02More typesGravatar Jarred Sumner 2-39/+3998
2022-04-02Add more typingsGravatar Jarred Sumner 1-2/+416
2022-04-02Add more tests for Node FSGravatar Jarred Sumner 4-1/+60
2022-04-02[bun.js] fs.readSync & fs.writeSync should return just the numberGravatar Jarred Sumner 1-24/+57
2022-04-02[bun.js] Support `mode` and `flags` as integer args in fs.openSync (instead o...Gravatar Jarred Sumner 1-0/+6
2022-04-02Update base.zigGravatar Jarred Sumner 1-0/+1
2022-04-02Fix GC bug when reading TypedArray from user inputGravatar Jarred Sumner 1-6/+36
2022-04-02s/Buffer/TypedArrayGravatar Jarred Sumner 1-17/+17
2022-04-02Fix mmap on macOS x64Gravatar Jarred Sumner 2-29/+27