Add GitHub stats for custom nodes (#533)

* Add GitHub stats fetching feature
- Added PyGithub package to requirements.txt for GitHub API interaction
- Updated .gitignore to ignore github-stats-cache.json
- Produced github-stats.json for storing GitHub stats
- Modified scanner.py to include the GitHub stats fetching process

* Add sorting for 'GitHub Stars' and 'Last Update' columns

- Fetch 'GitHub Stars' and 'Last Update' data when getting the custom node list.
- Display 'GitHub Stars' and 'Last Update' information in the UI.
- Implement sorting functionality for these two columns, allowing users to sort both in descending and ascending order.

* fix: scanner - prevent stuck when exceed rate limit

---------

Co-authored-by: Dr.Lt.Data <dr.lt.data@gmail.com>
This commit is contained in:
Liu Sida
2024-04-02 19:56:09 +08:00
committed by GitHub
parent 9f2323d1fb
commit abae9638ac
6 changed files with 2915 additions and 79 deletions

View File

@@ -621,6 +621,20 @@ async def get_data(uri, silent=False):
json_obj = json.loads(json_text)
return json_obj
async def populate_github_stats(json_obj, filename, silent=False):
uri = os.path.join(comfyui_manager_path, filename)
with open(uri, "r", encoding='utf-8') as f:
github_stats = json.load(f)
if 'custom_nodes' in json_obj:
for i, node in enumerate(json_obj['custom_nodes']):
url = node['reference']
if url in github_stats:
json_obj['custom_nodes'][i]['stars'] = github_stats[url]['stars']
json_obj['custom_nodes'][i]['last_update'] = github_stats[url]['last_update']
else:
json_obj['custom_nodes'][i]['stars'] = -1
json_obj['custom_nodes'][i]['last_update'] = -1
return json_obj
def setup_js():
import nodes
@@ -1005,6 +1019,7 @@ async def fetch_customnode_list(request):
channel = get_config()['channel_url']
json_obj = await get_data_by_mode(request.rel_url.query["mode"], 'custom-node-list.json')
json_obj = await populate_github_stats(json_obj, "github-stats.json")
def is_ignored_notice(code):
global version