Skip to content

Commit 650ae37

Browse files
authored
Merge pull request #480 from cibere/update-plugin-metadata-info-fields
Sync plugin metadata info fields during plugin update
2 parents e4160aa + aae7cba commit 650ae37

File tree

59 files changed

+113
-83
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+113
-83
lines changed

ci/src/updater.py

Lines changed: 44 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# -*-coding: utf-8 -*-
22
import asyncio
33
import aiohttp
4+
from zipfile import ZipFile
45
import re
6+
from io import BytesIO
57
from typing import List
68
from os import getenv
79
from sys import argv
@@ -68,14 +70,29 @@ async def batch_github_plugin_info(
6870
browser_download_url or assets[0]["browser_download_url"]
6971
)
7072

71-
if webhook_url:
72-
await send_notification(
73-
info,
74-
clean(latest_rel["tag_name"], "v"),
75-
latest_rel,
76-
webhook_url,
73+
latest_ver = clean(latest_rel["tag_name"], "v")
74+
if version_tuple(info[version]) != version_tuple(latest_ver):
75+
tqdm.write(f"Update detected: {info[plugin_name]} {latest_ver}")
76+
77+
metadata = await get_plugin_dot_json(
78+
info[url_download], session=session
7779
)
78-
info[version] = clean(latest_rel["tag_name"], "v")
80+
for key in (
81+
description,
82+
author,
83+
language_name,
84+
website,
85+
):
86+
info[key] = metadata[key]
87+
88+
if webhook_url:
89+
await send_notification(
90+
info,
91+
latest_ver,
92+
latest_rel,
93+
webhook_url,
94+
)
95+
info[version] = latest_ver
7996

8097
tags[info[id_name]] = res.headers.get(etag, "")
8198

@@ -86,6 +103,21 @@ async def batch_github_plugin_info(
86103
return info
87104

88105

106+
async def get_plugin_dot_json(download_url: str, *, session: aiohttp.ClientSession):
107+
async with session.get(download_url) as res:
108+
data = await res.read()
109+
110+
with ZipFile(BytesIO(data)) as zip:
111+
for fileinfo in zip.filelist:
112+
if not fileinfo.filename.endswith("plugin.json"):
113+
continue
114+
115+
with zip.open(fileinfo, "r") as file:
116+
return json.loads(file.read())
117+
118+
raise ValueError(f"plugin.json file not found. Download Url: {download_url}")
119+
120+
89121
async def batch_plugin_infos(
90122
plugin_infos: Ps, tags: ETagsType, github_token, webhook_url: str | None = None
91123
) -> Ps:
@@ -114,17 +146,15 @@ def remove_unused_etags(plugin_infos: PluginsType, etags: ETagsType) -> ETagsTyp
114146

115147

116148
async def send_notification(
117-
info: PluginType, latest_ver, release, webhook_url: str | None = None
149+
info: PluginType, latest_ver: str, release, webhook_url: str | None = None
118150
) -> None:
119151
if not webhook_url:
120152
return
121153

122-
if version_tuple(info[version]) != version_tuple(latest_ver):
123-
tqdm.write(f"Update detected: {info[plugin_name]} {latest_ver}")
124-
try:
125-
await update_hook(webhook_url, info, latest_ver, release)
126-
except Exception as e:
127-
tqdm.write(str(e))
154+
try:
155+
await update_hook(webhook_url, info, latest_ver, release)
156+
except Exception as e:
157+
tqdm.write(str(e))
128158

129159

130160
async def main():

plugins/Amazing Marvin-90f799c3-c04e-443b-bce8-eec5fbcba1e9.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"ID": "90f799c3-c04e-443b-bce8-eec5fbcba1e9",
33
"Name": "Amazing Marvin",
4-
"Description": "Communication with Amazing Marvin over API",
4+
"Description": "Plugin to run Amazing Marvin",
55
"Author": "RrobertRr",
66
"Version": "0.2.0",
77
"Language": "python",
8-
"Website": "https://github.com/rrFlowLauncher/amazing_marvin",
8+
"Website": "https://github.com/rrFlowLauncher/amazing_marvin/",
99
"UrlDownload": "https://github.com/rrFlowLauncher/amazing_marvin/releases/download/v0.2.0/amazing_marvin.zip",
1010
"UrlSourceCode": "https://github.com/rrFlowLauncher/amazing_marvin",
1111
"IcoPath": "https://github.com/rrFlowLauncher/amazing_marvin/blob/main/Images/Amazing_Marvin.09233c09.png",

plugins/Anilist-08AF784C-A014-4A03-822F-6C2F3665A843.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"ID": "08AF784C-A014-4A03-822F-6C2F3665A843",
33
"Name": "Anilist",
4-
"Description": "an anilist plugin for Flow-Launcher",
4+
"Description": "An Anilist plugin for Flow-Launcher",
55
"Author": "DiekoMA",
66
"Version": "1.0.7",
77
"Language": "csharp",

plugins/AppsSnapshoter-0F7232DB70E54C9B91205480C0C56D1F.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"ID": "0F7232DB70E54C9B91205480C0C56D1F",
33
"Name": "AppsSnapshoter",
4-
"Description": "Snapshot opened apps with help of plugin for Flow-Launcher for future open",
4+
"Description": "Snapshot opened apps with help of plugin for Flow-Launcher",
55
"Author": "spinozanilast",
66
"Version": "1.2.1",
77
"Language": "csharp",
8-
"Website": "https://github.com/Spinozanilast/Flow.Launcher.Plugin.AppsSnapshoter",
8+
"Website": "https://github.com/spinozanilast/Flow.Launcher.Plugin.AppsSnapshoter",
99
"UrlDownload": "https://github.com/Spinozanilast/Flow.Launcher.Plugin.AppsSnapshoter/releases/download/v1.2.1/AppsSnapshoter-1.2.1.zip",
1010
"UrlSourceCode": "https://github.com/Spinozanilast/Flow.Launcher.Plugin.AppsSnapshoter/tree/master",
1111
"IcoPath": "https://cdn.jsdelivr.net/gh/Spinozanilast/Flow.Launcher.Plugin.AppsSnapshoter@master/icon.png",

plugins/Astro-d429a0ef-94e5-4ba6-8eba-b4dd0e69dc48.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"ID": "d429a0ef-94e5-4ba6-8eba-b4dd0e69dc48",
33
"Name": "Astro",
44
"Description": "Search Astro Docs",
5-
"Author": "palmiak",
5+
"Author": "Maciek Palmowski",
66
"Version": "0.0.2",
77
"Language": "javascript",
88
"Website": "https://github.com/palmiak/astro-flow-launcher-plugin",

plugins/Audio Device Selector-C04175CF5284406DAA9E30A85EC7DA76.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"ID": "C04175CF5284406DAA9E30A85EC7DA76",
33
"Name": "Audio Device Selector",
4-
"Description": "Easily change your playback device",
4+
"Description": "Easy change your playback device",
55
"Author": "AttilaKapostyak",
66
"Version": "1.0.3",
77
"Language": "csharp",

plugins/BinancePrice-9E3D73EA-6618-40B4-AA2A-60F6F60CDD15.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"Author": "SUPEROLEJKAAA",
66
"Version": "1.0.0",
77
"Language": "JavaScript",
8-
"Website": "https://github.com/SUPEROLEJKAAA/Flow.Launcher.Plugin.BinancePrice",
8+
"Website": "https://github.com/SUPEROLEJKAAA/flow-binance-price",
99
"UrlDownload": "https://github.com/SUPEROLEJKAAA/Flow.Launcher.Plugin.BinancePrice/releases/download/v1.0.0/Flow.Launcher.Plugin.BinancePrice.zip",
1010
"UrlSourceCode": "https://github.com/SUPEROLEJKAAA/Flow.Launcher.Plugin.BinancePrice",
1111
"IcoPath": "https://cdn.jsdelivr.net/gh/SUPEROLEJKAAA/Flow.Launcher.Plugin.BinancePrice@master/icons/app.png",

plugins/Bulk URL Opener-2d5036e2-eccc-4254-b88e-de78580e2195.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"ID": "2d5036e2-eccc-4254-b88e-de78580e2195",
33
"Name": "Bulk URL Opener",
4-
"Description": "Opens groups of tabs",
4+
"Description": "Opens groups of tabs. To edit the tab groups, edit the tab_groups.yaml file in the plugin directory.",
55
"Author": "Tarik Jaber",
66
"Version": "2.0.0",
77
"Language": "python",

plugins/CPPreference-28b1bc8d-06e1-4bda-8311-f36e8d4f9915.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"ID": "28b1bc8d-06e1-4bda-8311-f36e8d4f9915",
33
"Name": "CPPreference",
44
"Description": "Search cppreference.com efficiently",
5-
"Author": "Peter Schussheim",
5+
"Author": "Peter Schussheim, Jonas de Bruin",
66
"Version": "1.1.0",
77
"Language": "csharp",
88
"Website": "https://github.com/peterschussheim/CPPreference-flow-plugin",

plugins/Cider-4e2018ca-4ed0-11ed-bdc3-0242ac120002.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"Author": "Monochromish",
66
"Version": "1.1.1",
77
"Language": "javascript",
8-
"Website": "https://github.com/Monochromish/Flow.Launcher.Plugin.Cider",
8+
"Website": "https://github.com/Monchromish/Flow.Launcher.Plugin.Cider",
99
"UrlDownload": "https://github.com/Monochromish/Flow.Launcher.Plugin.Cider/releases/download/v1.1.1/Flow.Launcher.Plugin.Cider.zip",
1010
"UrlSourceCode": "https://github.com/Monochromish/Flow.Launcher.Plugin.Cider/tree/main",
1111
"IcoPath": "https://cdn.jsdelivr.net/gh/Monochromish/Flow.Launcher.Plugin.Cider@main/Assets/app.png",

0 commit comments

Comments
 (0)