mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-04-09 16:38:50 +00:00
[HytaleBridge] Improve bridge contents (#2912)
Co-authored-by: BuildTools <unconfigured@null.spigotmc.org>
This commit is contained in:
parent
5e52ecc3f8
commit
64c8d4ad37
@ -7,11 +7,15 @@ class HytaleBridge extends BridgeAbstract
|
|||||||
const DESCRIPTION = 'All blog posts from Hytale\'s news blog.';
|
const DESCRIPTION = 'All blog posts from Hytale\'s news blog.';
|
||||||
const MAINTAINER = 'llamasblade';
|
const MAINTAINER = 'llamasblade';
|
||||||
|
|
||||||
const _API_URL = 'https://hytale.com/api/blog/post/published';
|
const _API_URL_PUBLISHED = 'https://hytale.com/api/blog/post/published';
|
||||||
|
const _API_URL_BLOG_POST = 'https://hytale.com/api/blog/post/slug/';
|
||||||
|
const _BLOG_THUMB_URL = 'https://cdn.hytale.com/variants/blog_thumb_';
|
||||||
|
const _BLOG_COVER_URL = 'https://cdn.hytale.com/variants/blog_cover_';
|
||||||
|
const _IMG_REGEX = '#https://cdn\.hytale\.com/\w+\.(?:jpg|png)#';
|
||||||
|
|
||||||
public function collectData()
|
public function collectData()
|
||||||
{
|
{
|
||||||
$blog_posts = json_decode(file_get_contents(self::_API_URL));
|
$blog_posts = json_decode(getContents(self::_API_URL_PUBLISHED));
|
||||||
|
|
||||||
foreach ($blog_posts as $blog_post) {
|
foreach ($blog_posts as $blog_post) {
|
||||||
$item = [];
|
$item = [];
|
||||||
@ -27,7 +31,22 @@ class HytaleBridge extends BridgeAbstract
|
|||||||
$item['title'] = $blog_post->title;
|
$item['title'] = $blog_post->title;
|
||||||
$item['author'] = $blog_post->author;
|
$item['author'] = $blog_post->author;
|
||||||
$item['timestamp'] = $blog_post->publishedAt;
|
$item['timestamp'] = $blog_post->publishedAt;
|
||||||
$item['content'] = $blog_post->bodyExcerpt;
|
|
||||||
|
$blog_post_full = json_decode(getContents(self::_API_URL_BLOG_POST . $slug));
|
||||||
|
|
||||||
|
$item['content'] = $blog_post_full->body;
|
||||||
|
$blog_cover_s3_key = $blog_post_full->coverImage->s3Key;
|
||||||
|
|
||||||
|
$cover_images_urls = [
|
||||||
|
self::_BLOG_COVER_URL . $blog_cover_s3_key,
|
||||||
|
self::_BLOG_THUMB_URL . $blog_cover_s3_key,
|
||||||
|
];
|
||||||
|
|
||||||
|
if (preg_match_all(self::_IMG_REGEX, $blog_post_full->body, $body_images_urls)) {
|
||||||
|
$item['enclosures'] = array_merge($cover_images_urls, $body_images_urls[0]);
|
||||||
|
} else {
|
||||||
|
$item['enclosures'] = $cover_images_urls;
|
||||||
|
}
|
||||||
|
|
||||||
$this->items[] = $item;
|
$this->items[] = $item;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user