- id in plugin => id in release

- remove `currentVersion`
- chage `tagName` to real GitHub tag name
- add `xpiVersion`
- remove all `id` in json
This commit is contained in:
ytshen 2023-12-14 21:41:30 +08:00
parent 586c2bb3a1
commit 266490b59f
45 changed files with 45 additions and 92 deletions

View File

@ -2,50 +2,47 @@
![GitHub Build Status](https://img.shields.io/github/actions/workflow/status/syt2/zotero-addons-scraper/main.yml) ![GitHub Build Status](https://img.shields.io/github/actions/workflow/status/syt2/zotero-addons-scraper/main.yml)
![GitHub Last Commit Time](https://img.shields.io/github/last-commit/syt2/zotero-addons-scraper/publish) ![GitHub Last Commit Time](https://img.shields.io/github/last-commit/syt2/zotero-addons-scraper/publish)
This is a script repository for scraping Zotero addon collections for [Zotero](https://www.zotero.org), intended for use with [Zotero addons](https://github.com/syt2/zotero-addons). This is a script repository for scraping Zotero addon collections for [Zotero](https://www.zotero.org), intended for use with [Zotero addons](https://github.com/syt2/zotero-addons).
> Switch to `(addon-scraper)` source in [Zotero addons](https://github.com/syt2/zotero-addons) to use this repository.
*Switch to `(addon-scraper)` source in [Zotero addons](https://github.com/syt2/zotero-addons) to use this repository.*
The script utilizes the GitHub API and GitHub Actions to automatically scrape and parse addon information from the [addons](addons) folder, and publish to [`publish`](https://github.com/syt2/zotero-addons-scraper/blob/publish/addon_infos.json) branch and the latest release every day. The script utilizes the GitHub API and GitHub Actions to automatically scrape and parse addon information from the [addons](addons) folder, and publish to [`publish`](https://github.com/syt2/zotero-addons-scraper/blob/publish/addon_infos.json) branch and the latest release every day.
## Contributing New Addons ## Contributing New Addons
If you have a new add-on to add, add an add-on information file in the [addons](addons) folder. If you have a new add-on to add, add an add-on information file in the [addons](addons) folder.
> typically, name it with `repo.replace('/', '#').json` The file format should be as follows:
>
> If an add-on has different IDs for different Zotero versions, split them into multiple JSON files with different filename.
The file format should be as follows:
``` json ``` json
{ {
"id": "zoteroAddons@ytshen.com",
"name": "Zotero Addons", "name": "Zotero Addons",
"repo": "syt2/zotero-addons", "repo": "syt2/zotero-addons",
"releases": [ "releases": [
{ {
"targetZoteroVersion": "7", "targetZoteroVersion": "7",
"tagName": "latest" "tagName": "latest"
}, },
{ {
"targetZoteroVersion": "6", "targetZoteroVersion": "6",
"tagName": "0.6.0-3" "tagName": "0.6.0-3"
} }
] ]
} }
``` ```
or
``` json - `name`(optional):
{ The name of the plugin.
"repo": "syt2/zotero-scipdf", If not provided, the name will be extracted automatically from the XPI provided in release.
"releases": [ - `repo`(required):
{ The GitHub repository address of the plugin.
"targetZoteroVersion": "7", - `releases`(required):
"tagName": "latest" Information about the plugin's XPI releases.
} Provide at least one valid plugin release information.
] - `targetZoteroVersion`(required):
} The Zotero compatibility version for the plugin.
``` Supports `"6"` or `"7"`.
- `tagName`(required):
The release information in the GitHub repository.
Supports `"latest"`, `"pre"` or a specified tag name.
If `"latest"` or `"pre"` is used, the script will automatically retrieve the latest release information.
## Generated Format ## Generated Format
The output format for add-on information follows the format specified in [zotero-chinese/zotero-plugins](https://github.com/zotero-chinese/zotero-plugins). The output format for add-on information follows the format specified in [zotero-chinese/zotero-plugins](https://github.com/zotero-chinese/zotero-plugins).

View File

@ -1,4 +1,3 @@
id = "id"
name = "name" name = "name"
repo = "repo" repo = "repo"
releases = "releases" releases = "releases"
@ -14,6 +13,8 @@ kgithub = "kgithub"
releaseData = "releaseData" releaseData = "releaseData"
downloadCount = "downloadCount" downloadCount = "downloadCount"
assetId = "assetId" assetId = "assetId"
id = "id"
xpiVersion = "xpiVersion"
description = "description" description = "description"
star = "star" star = "star"
author = "author" author = "author"
@ -24,6 +25,7 @@ avatar = "avatar"
# from https://github.com/zotero-chinese/zotero-plugins/blob/main/src/plugins.ts # from https://github.com/zotero-chinese/zotero-plugins/blob/main/src/plugins.ts
# export interface PluginInfo { # export interface PluginInfo {
# // plugin id # // plugin id
# // @deprecated This property is deprecated. Use the id in releases instead.
# id?: string; # id?: string;
# #
# // plugin name # // plugin name
@ -43,7 +45,7 @@ avatar = "avatar"
# // `pre`: Latest pre-release # // `pre`: Latest pre-release
# // `string`: Corresponding to the `git.tag_name` of the release; # // `string`: Corresponding to the `git.tag_name` of the release;
# tagName: "latest" | "pre" | string; # tagName: "latest" | "pre" | string;
# # // @deprecated This property is deprecated. Use tagName instead.
# currentVersion?: string; # currentVersion?: string;
# xpiDownloadUrl?: { # xpiDownloadUrl?: {
# github: string; # github: string;
@ -55,6 +57,10 @@ avatar = "avatar"
# releaseData?: string; # releaseData?: string;
# downloadCount?: number; # downloadCount?: number;
# assetId?: number; # assetId?: number;
# // plugin xpi id
# id?: string;
# // plugin xpi version
# xpiVersion?: string;
# }>; # }>;
# #
# description?: string; # description?: string;

View File

@ -1,5 +1,4 @@
{ {
"id": "zoterozotcard@018.ai",
"name": "ZotCard", "name": "ZotCard",
"repo": "018/zotcard", "repo": "018/zotcard",
"releases": [ "releases": [

View File

@ -1,5 +1,4 @@
{ {
"id": "zoplicate@chenglongma.com",
"name": "Zoplicate", "name": "Zoplicate",
"repo": "ChenglongMa/zoplicate", "repo": "ChenglongMa/zoplicate",
"releases": [ "releases": [

View File

@ -1,5 +1,4 @@
{ {
"id": "reading-list@hotmail.com",
"name": "Reading List for Zotero", "name": "Reading List for Zotero",
"repo": "Dominic-DallOsto/zotero-reading-list", "repo": "Dominic-DallOsto/zotero-reading-list",
"releases": [ "releases": [

View File

@ -1,5 +1,4 @@
{ {
"id": "zoterostyle@polygon.org",
"name": "Ethereal Style", "name": "Ethereal Style",
"repo": "MuiseDestiny/ZoteroStyle", "repo": "MuiseDestiny/ZoteroStyle",
"releases": [ "releases": [

View File

@ -1,5 +1,4 @@
{ {
"id": "zoterocitation@polygon.org",
"name": "Eaiser Citation", "name": "Eaiser Citation",
"repo": "MuiseDestiny/eaiser-citation", "repo": "MuiseDestiny/eaiser-citation",
"releases": [ "releases": [

View File

@ -1,5 +1,4 @@
{ {
"id": "zoterofigure@polygon.org",
"name": "PDF Figure", "name": "PDF Figure",
"repo": "MuiseDestiny/zotero-figure", "repo": "MuiseDestiny/zotero-figure",
"releases": [ "releases": [

View File

@ -1,5 +1,4 @@
{ {
"id": "zoterogpt@polygon.org",
"name": "Awesome GPT", "name": "Awesome GPT",
"repo": "MuiseDestiny/zotero-gpt", "repo": "MuiseDestiny/zotero-gpt",
"releases": [ "releases": [

View File

@ -1,5 +1,4 @@
{ {
"id": "zoteroreference@polygon.org",
"name": "Crush Reference", "name": "Crush Reference",
"repo": "MuiseDestiny/zotero-reference", "repo": "MuiseDestiny/zotero-reference",
"releases": [ "releases": [

View File

@ -1,5 +1,4 @@
{ {
"id": "zotero-ocr@bib.uni-mannheim.de",
"name": "Zotero OCR", "name": "Zotero OCR",
"repo": "UB-Mannheim/zotero-ocr", "repo": "UB-Mannheim/zotero-ocr",
"releases": [ "releases": [

View File

@ -1,5 +1,4 @@
{ {
"id": "mdnotes@mdnotes.github.io",
"name": "Mdnotes for Zotero", "name": "Mdnotes for Zotero",
"repo": "argenos/zotero-mdnotes", "repo": "argenos/zotero-mdnotes",
"releases": [ "releases": [

View File

@ -1,5 +1,4 @@
{ {
"id": "zoteroshortdoi@wiernik.org",
"name": "Zotero ShortDOI", "name": "Zotero ShortDOI",
"repo": "bwiernik/zotero-shortdoi", "repo": "bwiernik/zotero-shortdoi",
"releases": [ "releases": [

View File

@ -1,15 +1,14 @@
{ {
"id": "daeda@mit.edu",
"name": "MarkDBConnect", "name": "MarkDBConnect",
"repo": "daeh/zotero-obsidian-citations", "repo": "daeh/zotero-obsidian-citations",
"releases": [ "releases": [
{
"targetZoteroVersion": "6",
"tagName": "latest"
},
{ {
"targetZoteroVersion": "7", "targetZoteroVersion": "7",
"tagName": "pre" "tagName": "pre"
},
{
"targetZoteroVersion": "6",
"tagName": "latest"
} }
] ]
} }

View File

@ -1,5 +1,4 @@
{ {
"id": "notero@vanoni.dev",
"name": "Notero", "name": "Notero",
"repo": "dvanoni/notero", "repo": "dvanoni/notero",
"releases": [ "releases": [

View File

@ -1,5 +1,4 @@
{ {
"id": "schnetter@gmail.com",
"name": "Zotero Citation Counts Manager", "name": "Zotero Citation Counts Manager",
"repo": "eschnett/zotero-citationcounts", "repo": "eschnett/zotero-citationcounts",
"releases": [ "releases": [

View File

@ -1,5 +1,4 @@
{ {
"id": "scihub@example.com",
"name": "Sci-Hub Plugin for Zotero", "name": "Sci-Hub Plugin for Zotero",
"repo": "ethanwillis/zotero-scihub", "repo": "ethanwillis/zotero-scihub",
"releases": [ "releases": [

View File

@ -1,5 +1,4 @@
{ {
"id": "zoteroinspire@itp.ac.cn",
"name": "Zotero Inspire", "name": "Zotero Inspire",
"repo": "fkguo/zotero-inspire", "repo": "fkguo/zotero-inspire",
"releases": [ "releases": [

View File

@ -1,5 +1,4 @@
{ {
"id": "betterauthors@github.com",
"name": "Zotero Better Authors", "name": "Zotero Better Authors",
"repo": "github-young/zotero-better-authors", "repo": "github-young/zotero-better-authors",
"releases": [ "releases": [

View File

@ -1,5 +1,4 @@
{ {
"id": "zotfile@columbia.edu",
"name": "ZotFile", "name": "ZotFile",
"repo": "jlegewie/zotfile", "repo": "jlegewie/zotfile",
"releases": [ "releases": [

View File

@ -1,5 +1,4 @@
{ {
"id": "jasminum@linxzh.com",
"name": "Jasminum", "name": "Jasminum",
"repo": "l0o0/jasminum", "repo": "l0o0/jasminum",
"releases": [ "releases": [

View File

@ -1,5 +1,4 @@
{ {
"id": "tara@linxzh.com",
"name": "Tara", "name": "Tara",
"repo": "l0o0/tara", "repo": "l0o0/tara",
"releases": [ "releases": [

View File

@ -1,5 +1,4 @@
{ {
"id": "zotfile@columbia.edu",
"name": "ZotFile 汉化版", "name": "ZotFile 汉化版",
"repo": "lychichem/zotfile", "repo": "lychichem/zotfile",
"releases": [ "releases": [

View File

@ -1,5 +1,4 @@
{ {
"id": "zotero-format-metadata@northword.cn",
"name": "Linter for Zotero", "name": "Linter for Zotero",
"repo": "northword/zotero-format-metadata", "repo": "northword/zotero-format-metadata",
"releases": [ "releases": [

View File

@ -1,5 +1,4 @@
{ {
"id": "delitemwithatt@redleaf.me",
"name": "DelItemWithAtt", "name": "DelItemWithAtt",
"repo": "redleafnew/delitemwithatt", "repo": "redleafnew/delitemwithatt",
"releases": [ "releases": [

View File

@ -1,5 +1,4 @@
{ {
"id": "zoteroupdateifs@redleafnew.me",
"name": "Zotero 更新影响因子", "name": "Zotero 更新影响因子",
"repo": "redleafnew/zotero-updateifs", "repo": "redleafnew/zotero-updateifs",
"releases": [ "releases": [

View File

@ -1,5 +1,4 @@
{ {
"id": "greenfrog@redleafnew.me",
"name": "Green Frog", "name": "Green Frog",
"repo": "redleafnew/zotero-updateifsE", "repo": "redleafnew/zotero-updateifsE",
"releases": [ "releases": [

View File

@ -1,5 +1,4 @@
{ {
"id": "better-bibtex@iris-advies.com",
"name": "Better BibTex for Zotero", "name": "Better BibTex for Zotero",
"repo": "retorquere/zotero-better-bibtex", "repo": "retorquere/zotero-better-bibtex",
"releases": [ "releases": [

View File

@ -1,5 +1,4 @@
{ {
"id": "open-pdf@iris-advies.com",
"name": "Open PDF", "name": "Open PDF",
"repo": "retorquere/zotero-open-pdf", "repo": "retorquere/zotero-open-pdf",
"releases": [ "releases": [

View File

@ -1,5 +1,4 @@
{ {
"id": "pmcid-fetcher@iris-advies.com",
"name": "PMCID fetcher for Zotero", "name": "PMCID fetcher for Zotero",
"repo": "retorquere/zotero-pmcid-fetcher", "repo": "retorquere/zotero-pmcid-fetcher",
"releases": [ "releases": [

View File

@ -1,5 +1,4 @@
{ {
"id": "storage-scanner@iris-advies.com",
"name": "Zotero Storage Scanner", "name": "Zotero Storage Scanner",
"repo": "retorquere/zotero-storage-scanner", "repo": "retorquere/zotero-storage-scanner",
"releases": [ "releases": [

View File

@ -1,5 +1,4 @@
{ {
"id": "scite@scite.ai",
"name": "scite Plugin for Zotero", "name": "scite Plugin for Zotero",
"repo": "scitedotai/scite-zotero-plugin", "repo": "scitedotai/scite-zotero-plugin",
"releases": [ "releases": [

View File

@ -1,5 +1,4 @@
{ {
"id": "zoterotldr@syt.com",
"name": "Zotero TL;DR", "name": "Zotero TL;DR",
"repo": "syt2/Zotero-TLDR", "repo": "syt2/Zotero-TLDR",
"releases": [ "releases": [

View File

@ -1,5 +1,4 @@
{ {
"id": "zoteroAddons@ytshen.com",
"name": "Zotero Addons", "name": "Zotero Addons",
"repo": "syt2/zotero-addons", "repo": "syt2/zotero-addons",
"releases": [ "releases": [

View File

@ -1,5 +1,4 @@
{ {
"id": "scipdf@ytshen.com",
"name": "Sci-PDF", "name": "Sci-PDF",
"repo": "syt2/zotero-scipdf", "repo": "syt2/zotero-scipdf",
"releases": [ "releases": [

View File

@ -1,5 +1,4 @@
{ {
"id": "night@tefkah.com",
"name": "Night for Zotero", "name": "Night for Zotero",
"repo": "tefkah/zotero-night", "repo": "tefkah/zotero-night",
"releases": [ "releases": [

View File

@ -1,5 +1,4 @@
{ {
"id": "chartero@volatile.static",
"name": "Chartero", "name": "Chartero",
"repo": "volatile-static/Chartero", "repo": "volatile-static/Chartero",
"releases": [ "releases": [

View File

@ -1,5 +1,4 @@
{ {
"id": "zoterotag@euclpts.com",
"name": "Actions and Tags for Zotero", "name": "Actions and Tags for Zotero",
"repo": "windingwind/zotero-actions-tags", "repo": "windingwind/zotero-actions-tags",
"releases": [ "releases": [

View File

@ -1,5 +1,4 @@
{ {
"id": "Knowledge4Zotero@windingwind.com",
"name": "Better Notes for Zotero", "name": "Better Notes for Zotero",
"repo": "windingwind/zotero-better-notes", "repo": "windingwind/zotero-better-notes",
"releases": [ "releases": [

View File

@ -1,5 +1,4 @@
{ {
"id": "pdfpreview@windingwind.com",
"name": "Preview for Zotero", "name": "Preview for Zotero",
"repo": "windingwind/zotero-pdf-preview", "repo": "windingwind/zotero-pdf-preview",
"releases": [ "releases": [

View File

@ -1,5 +1,4 @@
{ {
"id": "zoteropdftranslate@euclpts.com",
"name": "Translate for Zotero", "name": "Translate for Zotero",
"repo": "windingwind/zotero-pdf-translate", "repo": "windingwind/zotero-pdf-translate",
"releases": [ "releases": [

View File

@ -1,5 +1,4 @@
{ {
"id": "zutilo@www.wesailatdawn.com",
"name": "Zutilo Utility for Zotero", "name": "Zutilo Utility for Zotero",
"repo": "wshanks/Zutilo", "repo": "wshanks/Zutilo",
"releases": [ "releases": [

View File

@ -1,5 +1,4 @@
{ {
"id": "lyz@zotero.org",
"name": "LyZ", "name": "LyZ",
"repo": "wshanks/lyz", "repo": "wshanks/lyz",
"releases": [ "releases": [

View File

@ -1,5 +1,4 @@
{ {
"id": "keepzotero@yhmtsai",
"name": "KeepZotero", "name": "KeepZotero",
"repo": "yhmtsai/KeepZotero", "repo": "yhmtsai/KeepZotero",
"releases": [ "releases": [

30
main.py
View File

@ -108,6 +108,10 @@ def parse(plugin, **kwargs):
else: else:
continue continue
if 'tag_name' in release_info: if 'tag_name' in release_info:
release[tagName] = release_info['tag_name']
# todo: 删除currentVersion
# zotero-addons插件相关:
# 等待影响降低后再删除 (影响2023-12-14日之前的版本)
release[currentVersion] = release_info['tag_name'] release[currentVersion] = release_info['tag_name']
if 'assets' not in release_info: if 'assets' not in release_info:
@ -152,30 +156,18 @@ def parse(plugin, **kwargs):
details = addon_details(xpi_filepath) details = addon_details(xpi_filepath)
except Exception as e: except Exception as e:
print(f'fetch addon detail of {plugin[repo]} failed: {e}') print(f'fetch addon detail of {plugin[repo]} failed: {e}')
# 对齐zotero-chinese的格式
# if details:
# xpi_info = {}
# if "id" in details:
# xpi_info[id] = details["id"]
# if "name" in details:
# xpi_info[name] = details["name"]
# if "version" in details:
# xpi_info[currentVersion] = details["version"]
# if xpi_info:
# release[xpiInfo] = xpi_info
if details: if details:
if detail_id := details.get('id'): if detail_id := details.get('id'):
if plugin.get(id) and plugin[id] != detail_id: release[id] = detail_id
print('🆘🆘🆘🆘🆘🆘🆘🆘🆘🆘🆘🆘🆘🆘🆘🆘🆘🆘') # todo: 删除plugin外层的id
print(f'Addon id not matched in {plugin[repo]}') # zotero-addons插件相关:
print(f'{plugin[id]} <===> {detail_id}') # 等待影响降低后再删除 (影响2023-12-14日之前的版本)
print('🆘🆘🆘🆘🆘🆘🆘🆘🆘🆘🆘🆘🆘🆘🆘🆘🆘🆘')
plugin[id] = detail_id plugin[id] = detail_id
if not plugin.get(name) and (detail_name := details.get('name')): if not plugin.get(name) and (detail_name := details.get('name')):
plugin[name] = detail_name plugin[name] = detail_name
if not release.get(currentVersion) and (detail_version := details.get('version')): if detail_version := details.get('version'):
release[currentVersion] = detail_version release[xpiVersion] = detail_version
if not plugin.get(description) and (detail_desc := details.get('description')): if not plugin.get(description) and (detail_desc := details.get('description')):
if detail_desc != '__MSG_description__': if detail_desc != '__MSG_description__':
plugin[description] = detail_desc plugin[description] = detail_desc
@ -260,7 +252,7 @@ def create_release(github_repository, **kwargs):
'tag_name': f'{cur_time}', 'tag_name': f'{cur_time}',
'target_commitish': 'master', 'target_commitish': 'master',
'name': f'{cur_time}', 'name': f'{cur_time}',
'body': 'publish addon_infos.json', 'body': f'![](https://img.shields.io/github/downloads/{github_repository}/{cur_time}/total?label=downloads)\npublish addon_infos.json',
'draft': False, 'draft': False,
'prerelease': False, 'prerelease': False,
'generate_release_notes': False, 'generate_release_notes': False,