对齐zotero-chinese格式,去掉release内xpiInfo字段。
This commit is contained in:
parent
6bd1505b1f
commit
a822b3cafa
95
README.md
95
README.md
@ -9,12 +9,35 @@ This is a script repository for scraping Zotero addon collections for [Zotero](h
|
|||||||
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 new add-ons to parse, add the json information of the add-on with the name format of `repo.replace('/', '#').json` in the [addons](addons) folder with the format
|
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`
|
||||||
|
>
|
||||||
|
> 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",
|
"id": "zoteroAddons@ytshen.com",
|
||||||
"name": "Zotero Addons",
|
"name": "Zotero Addons",
|
||||||
"repo": "syt2/zotero-addons",
|
"repo": "syt2/zotero-addons",
|
||||||
|
"releases": [
|
||||||
|
{
|
||||||
|
"targetZoteroVersion": "7",
|
||||||
|
"tagName": "latest"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"targetZoteroVersion": "6",
|
||||||
|
"tagName": "0.6.0-3"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
or
|
||||||
|
``` json
|
||||||
|
{
|
||||||
|
"repo": "syt2/zotero-scipdf",
|
||||||
"releases": [
|
"releases": [
|
||||||
{
|
{
|
||||||
"targetZoteroVersion": "7",
|
"targetZoteroVersion": "7",
|
||||||
@ -24,72 +47,6 @@ If you have new add-ons to parse, add the json information of the add-on with th
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Addon Information 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), which is as follows:
|
|
||||||
```ts
|
|
||||||
export interface PluginInfo {
|
|
||||||
id?: string;
|
|
||||||
/**
|
|
||||||
* 插件名称
|
|
||||||
*/
|
|
||||||
name: string;
|
|
||||||
/**
|
|
||||||
* 插件仓库
|
|
||||||
*
|
|
||||||
* 例如:northword/zotero-format-metadata
|
|
||||||
*
|
|
||||||
* 注意前后均无 `/`
|
|
||||||
*/
|
|
||||||
repo: string;
|
|
||||||
/**
|
|
||||||
* 插件的发布地址信息
|
|
||||||
*/
|
|
||||||
releases: Array<{
|
|
||||||
/**
|
|
||||||
* 当前发布版对应的 Zotero 版本
|
|
||||||
*/
|
|
||||||
targetZoteroVersion: string;
|
|
||||||
/**
|
|
||||||
* 当前发布版对应的下载通道
|
|
||||||
*
|
|
||||||
* `latest`:最新正式发布;
|
|
||||||
* `pre`:最新预发布;
|
|
||||||
* `string`:发布对应的 `git.tag_name`;
|
|
||||||
* 注意 `git.tag_name` 有的有 `v` 而有的没有,可以通过发布链接来判断
|
|
||||||
*/
|
|
||||||
tagName: "latest" | "pre" | string;
|
|
||||||
|
|
||||||
currentVersion?: string;
|
|
||||||
xpiDownloadUrl?: {
|
|
||||||
github: string;
|
|
||||||
gitee: string;
|
|
||||||
ghProxy: string;
|
|
||||||
jsdeliver: string;
|
|
||||||
kgithub: string;
|
|
||||||
};
|
|
||||||
releaseData?: string;
|
|
||||||
downloadCount?: number;
|
|
||||||
assetId?: number;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 从插件中解析的信息
|
|
||||||
*
|
|
||||||
* TODO:后续视 zotero-chinese/zotero-plugins 的情况更新
|
|
||||||
*/
|
|
||||||
xpiInfo?: {
|
|
||||||
id?: string;
|
|
||||||
name?: string;
|
|
||||||
currentVersion?: string;
|
|
||||||
};
|
|
||||||
}>;
|
|
||||||
|
|
||||||
description?: string;
|
|
||||||
star?: number;
|
|
||||||
author?: {
|
|
||||||
name: string;
|
|
||||||
url: string;
|
|
||||||
avatar: string;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
@ -19,39 +19,29 @@ star = "star"
|
|||||||
author = "author"
|
author = "author"
|
||||||
url = "url"
|
url = "url"
|
||||||
avatar = "avatar"
|
avatar = "avatar"
|
||||||
xpiInfo = "xpiInfo"
|
|
||||||
|
|
||||||
|
|
||||||
# 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
|
||||||
# * 插件名称
|
# id?: string;
|
||||||
# */
|
#
|
||||||
# name: string;
|
# // plugin name
|
||||||
# /**
|
# name?: string;
|
||||||
# * 插件仓库
|
#
|
||||||
# *
|
# // plugin repository address on GitHub
|
||||||
# * 例如:northword/zotero-format-metadata
|
# // e.g., syt2/zotero-addons
|
||||||
# *
|
|
||||||
# * 注意前后均无 `/`
|
|
||||||
# */
|
|
||||||
# repo: string;
|
# repo: string;
|
||||||
# /**
|
#
|
||||||
# * 插件的发布地址信息
|
# // plugin releases information
|
||||||
# */
|
|
||||||
# releases: Array<{
|
# releases: Array<{
|
||||||
# /**
|
# // Zotero version corresponding to current release
|
||||||
# * 当前发布版对应的 Zotero 版本
|
|
||||||
# */
|
|
||||||
# targetZoteroVersion: string;
|
# targetZoteroVersion: string;
|
||||||
# /**
|
#
|
||||||
# * 当前发布版对应的下载通道
|
# // Download channel corresponding to the current release version
|
||||||
# *
|
# // `latest`: Latest stable release
|
||||||
# * `latest`:最新正式发布;
|
# // `pre`: Latest pre-release
|
||||||
# * `pre`:最新预发布;
|
# // `string`: Corresponding to the `git.tag_name` of the release;
|
||||||
# * `string`:发布对应的 `git.tag_name`;
|
|
||||||
# * 注意 `git.tag_name` 有的有 `v` 而有的没有,可以通过发布链接来判断
|
|
||||||
# */
|
|
||||||
# tagName: "latest" | "pre" | string;
|
# tagName: "latest" | "pre" | string;
|
||||||
#
|
#
|
||||||
# currentVersion?: string;
|
# currentVersion?: string;
|
||||||
@ -65,13 +55,6 @@ xpiInfo = "xpiInfo"
|
|||||||
# releaseData?: string;
|
# releaseData?: string;
|
||||||
# downloadCount?: number;
|
# downloadCount?: number;
|
||||||
# assetId?: number;
|
# assetId?: number;
|
||||||
#
|
|
||||||
# TODO:视 zotero-chinese/zotero-plugins情况更新
|
|
||||||
# xpiInfo?: {
|
|
||||||
# id?: string;
|
|
||||||
# name?: string;
|
|
||||||
# currentVersion?: string;
|
|
||||||
# };
|
|
||||||
# }>;
|
# }>;
|
||||||
#
|
#
|
||||||
# description?: string;
|
# description?: string;
|
||||||
@ -81,4 +64,4 @@ xpiInfo = "xpiInfo"
|
|||||||
# url: string;
|
# url: string;
|
||||||
# avatar: string;
|
# avatar: string;
|
||||||
# };
|
# };
|
||||||
# }
|
# }
|
||||||
|
|||||||
38
main.py
38
main.py
@ -144,16 +144,36 @@ 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:
|
||||||
xpi_info = {}
|
if detail_id := details.get('id'):
|
||||||
if "id" in details:
|
if plugin.get(id) and plugin[id] != detail_id:
|
||||||
xpi_info[id] = details["id"]
|
print('🆘🆘🆘🆘🆘🆘🆘🆘🆘🆘🆘🆘🆘🆘🆘🆘🆘🆘')
|
||||||
if "name" in details:
|
print(f'Addon id not matched in {plugin[repo]}')
|
||||||
xpi_info[name] = details["name"]
|
print(f'{plugin[id]} <===> {detail_id}')
|
||||||
if "version" in details:
|
print('🆘🆘🆘🆘🆘🆘🆘🆘🆘🆘🆘🆘🆘🆘🆘🆘🆘🆘')
|
||||||
xpi_info[currentVersion] = details["version"]
|
plugin[id] = detail_id
|
||||||
if xpi_info:
|
if not plugin.get(name) and (detail_name := details.get('name')):
|
||||||
release[xpiInfo] = xpi_info
|
plugin[name] = detail_name
|
||||||
|
if detail_version := details.get('version'):
|
||||||
|
release[currentVersion] = detail_version
|
||||||
|
if not plugin.get(description) and (detail_desc := details.get('description')):
|
||||||
|
if detail_desc != '__MSG_description__':
|
||||||
|
plugin[description] = detail_desc
|
||||||
|
else:
|
||||||
|
# todo: read from i18n
|
||||||
|
pass
|
||||||
release_infos.append(release)
|
release_infos.append(release)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
@ -19,7 +19,7 @@ def addon_details(addon_path):
|
|||||||
'unpack': False } # whether to unpack the addon
|
'unpack': False } # whether to unpack the addon
|
||||||
"""
|
"""
|
||||||
|
|
||||||
details = {"id": None, "unpack": False, "name": None, "version": None}
|
details = {"id": None, "unpack": False, "name": None, "version": None, "description": None}
|
||||||
|
|
||||||
def get_namespace_id(doc, url):
|
def get_namespace_id(doc, url):
|
||||||
attributes = doc.documentElement.attributes
|
attributes = doc.documentElement.attributes
|
||||||
@ -80,6 +80,7 @@ def addon_details(addon_path):
|
|||||||
if is_webext:
|
if is_webext:
|
||||||
details["version"] = manifest["version"]
|
details["version"] = manifest["version"]
|
||||||
details["name"] = manifest["name"]
|
details["name"] = manifest["name"]
|
||||||
|
details["description"] = manifest["description"]
|
||||||
# Bug 1572404 - we support two locations for gecko-specific
|
# Bug 1572404 - we support two locations for gecko-specific
|
||||||
# metadata.
|
# metadata.
|
||||||
for location in ("applications", "browser_specific_settings"):
|
for location in ("applications", "browser_specific_settings"):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user