Skip to content

Instantly share code, notes, and snippets.

@15cm
Last active January 29, 2023 02:28
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save 15cm/2166f50b5818fd777ebc64a7320bf31f to your computer and use it in GitHub Desktop.
Save 15cm/2166f50b5818fd777ebc64a7320bf31f to your computer and use it in GitHub Desktop.
Huginn agents generator for bangumi subscription
#!/usr/bin/env python3
# Redirect output to *.json and upload it as a "Scenario JSON File" in huginn
# You need to add sources in agent "Send url of data to Aria2 on VPS" manually
from datetime import datetime
import uuid
import json
# Set Aria2 Config here for Aria2 RPC
aria2_config = {
"url": "https://aria2.xxx.com/jsonrpc",
"token": "abc"
}
# Add your bangumis here in format: (bangumi-title, bangumi-rss-url)
bangumis = [
("終末なにしてますか?忙しいですか?救ってもらっていいですか?",
"https://www.nyaa.se/?page=rss&term=HorribleSubs%201080p%20Shuumatsu%20Nani%20Shitemasuka%20Isogashii%20Desuka%20Sukutte%20Moratte%20Ii%20Desuka")
]
agent_dic = {
"schema_version": 1,
"name": "Bangumi Subscribe",
"description": "Check update of bangumi rss and send new items to Aria2",
"source_url": False,
"guid": uuid.uuid4().hex,
"tag_fg_color": "#ffffff",
"tag_bg_color": "#ffb3c2",
"icon": "film",
"exported_at": datetime.utcnow().isoformat(),
"agents": [{
"type": "Agents::RssAgent",
"name": bgm[0],
"disabled": False,
"guid": uuid.uuid4().hex,
"options": {
"expected_update_period_in_days": "15",
"clean": "false",
"url": bgm[1]
},
"schedule": "every_1h",
"keep_events_for": 15552000 # Keep events for 180 days
} for bgm in bangumis]
+ [{
"type": "Agents::PostAgent",
"name": "Send url of data to Aria2 on VPS",
"disabled": False,
"guid": uuid.uuid4().hex,
"options": {
"post_url": aria2_config["url"],
"expected_receive_period_in_days": "15",
"content_type": "json",
"method": "post",
"payload": {
"method": "aria2.addUri",
"params": [
"token:{0}".format(aria2_config["token"]),
[
"{{ url }}"
]
]
},
"headers": {
},
"emit_events": "false",
"no_merge": "false"
},
"schedule": "never",
"keep_events_for": 0,
"propagate_immediately": True
}],
"links": [],
"control_links": [
]
}
print(json.dumps(agent_dic, ensure_ascii = False))
@Lyukx
Copy link

Lyukx commented Apr 27, 2017

BGM竟然是ばんぐみ……

@15cm
Copy link
Author

15cm commented Apr 28, 2017

把辅音挑出来刚好一样,一般有上下文也不太容易弄混。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment