Skip to content

Instantly share code, notes, and snippets.

@c3kay
Last active July 31, 2023 20:09
Show Gist options
  • Save c3kay/2cd9833ef1c527e210aebf7a866336ed to your computer and use it in GitHub Desktop.
Save c3kay/2cd9833ef1c527e210aebf7a866336ed to your computer and use it in GitHub Desktop.
Hoyolab-RSS-Feeds no config example
# for more information, refer to hoyolabrssfeeds.models
from asyncio import run
import hoyolabrssfeeds as hrf
def generate_genshin_json_feed():
genshin_meta = hrf.models.FeedMeta(
# only "game" is required, others are optional
game=hrf.models.Game.GENSHIN,
category_size=10,
categories=[hrf.models.FeedItemCategory.EVENTS],
language=hrf.models.Language.ENGLISH,
title="Genshin Feed",
icon="https://example.org/favicon.ico"
)
feed_path_json = "genshin.json"
json_writer_config = hrf.models.FeedFileWriterConfig(
feed_type=hrf.models.FeedType.JSON,
path=feed_path_json,
url="https://example.org/genshin.json" # optional
)
json_writer = hrf.writers.JSONFeedFileWriter(config=json_writer_config)
# the loader is optional. if omitted, a suitable loader will be created automatically
json_loader_config = hrf.models.FeedFileConfig(
feed_type=hrf.models.FeedType.JSON,
path=feed_path_json
)
json_loader = hrf.loaders.JSONFeedFileLoader(config=json_loader_config)
genshin_feed = hrf.feeds.GameFeed(
feed_meta=genshin_meta,
feed_writers=[json_writer],
feed_loader=json_loader # optional
)
run(genshin_feed.create_feed())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment