Skip to content

Commit 9fd33c0

Browse files
authored
Merge pull request #462 from cibere/fix-updater-with-shared-repos
Fix wrong download urls with shared repos
2 parents 44d2e39 + 5c5e08c commit 9fd33c0

File tree

4 files changed

+33
-7
lines changed

4 files changed

+33
-7
lines changed

.github/workflows/links.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,5 @@ jobs:
3030
with:
3131
args: --verbose --no-progress plugins.json
3232
fail: true
33+
failIfEmpty: false
3334
token: ${{ secrets.LINKCHECKER }}

ci/src/updater.py

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# -*-coding: utf-8 -*-
22
import asyncio
33
import aiohttp
4+
import re
45
from typing import List
5-
from unicodedata import name
66
from os import getenv
77
from sys import argv
88
import traceback
@@ -12,6 +12,11 @@
1212
from _utils import *
1313
from discord import update_hook
1414

15+
github_download_url_regex = re.compile(
16+
r"https://github\.com/(?P<author>[a-zA-Z0-9-]+)/(?P<repo>[a-zA-Z0-9\.\-\_]*)/releases/download/(?P<version>[a-zA-Z\.0-9]+)/(?P<filename>.*)\.zip"
17+
)
18+
19+
1520
async def batch_github_plugin_info(
1621
info: P, tags: ETagsType, github_token=None, webhook_url: str | None = None
1722
) -> P:
@@ -44,11 +49,31 @@ async def batch_github_plugin_info(
4449

4550
if info.get(release_date, "") != latest_rel.get("published_at"):
4651
info[release_date] = latest_rel.get("published_at")
52+
4753
if assets:
48-
info[url_download] = assets[0]["browser_download_url"]
54+
browser_download_url = None
55+
56+
if len(assets) > 1:
57+
match = github_download_url_regex.match(info[url_download])
58+
if not match:
59+
raise ValueError(
60+
f"Download URL did not mach regex: {info[url_download]!r}"
61+
)
62+
filename = f"{match['filename']}.zip"
63+
for asset in assets:
64+
if asset["browser_download_url"].endswith(filename):
65+
browser_download_url = asset["browser_download_url"]
66+
67+
info[url_download] = (
68+
browser_download_url or assets[0]["browser_download_url"]
69+
)
70+
4971
if webhook_url:
5072
await send_notification(
51-
info, clean(latest_rel["tag_name"], "v"), latest_rel, webhook_url
73+
info,
74+
clean(latest_rel["tag_name"], "v"),
75+
latest_rel,
76+
webhook_url,
5277
)
5378
info[version] = clean(latest_rel["tag_name"], "v")
5479

@@ -77,7 +102,6 @@ def remove_unused_etags(plugin_infos: PluginsType, etags: ETagsType) -> ETagsTyp
77102
plugin_ids = [info.get("ID") for info in plugin_infos]
78103

79104
for id, tag in etags.items():
80-
81105
if id not in plugin_ids:
82106
print(
83107
f"Plugin with ID {id} has been removed. The associated ETag will be also removed now."
@@ -94,14 +118,15 @@ async def send_notification(
94118
) -> None:
95119
if not webhook_url:
96120
return
97-
121+
98122
if version_tuple(info[version]) != version_tuple(latest_ver):
99123
tqdm.write(f"Update detected: {info[plugin_name]} {latest_ver}")
100124
try:
101125
await update_hook(webhook_url, info, latest_ver, release)
102126
except Exception as e:
103127
tqdm.write(str(e))
104128

129+
105130
async def main():
106131
webhook_url = None
107132
if len(argv) > 1:

plugins/Search Unicode – Identify-B9EE77F84A9141C3850BB329D45B8D9A.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"Website": "https://github.com/blueset/flow-search-unicode",
99
"IcoPath": "https://cdn.jsdelivr.net/gh/blueset/flow-search-unicode@master/Flow.Launcher.Plugin.SearchUnicode.Identify/icon.png?raw=true",
1010
"UrlSourceCode": "https://github.com/blueset/flow-search-unicode",
11-
"UrlDownload": "https://github.com/blueset/flow-search-unicode/releases/download/v1.0.4/SearchUnicode.Emoji.zip",
11+
"UrlDownload": "https://github.com/blueset/flow-search-unicode/releases/download/v1.0.4/SearchUnicode.Identify.zip",
1212
"LatestReleaseDate": "2025-02-06T03:49:37Z",
1313
"DateAdded": "2025-01-19T01:42:28Z"
1414
}

plugins/Search Unicode – Search-10DB6EB0939443BCA556ACCF93AA98BF.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"Website": "https://github.com/blueset/flow-search-unicode",
99
"IcoPath": "https://cdn.jsdelivr.net/gh/blueset/flow-search-unicode@master/Flow.Launcher.Plugin.SearchUnicode.Search/icon.png?raw=true",
1010
"UrlSourceCode": "https://github.com/blueset/flow-search-unicode",
11-
"UrlDownload": "https://github.com/blueset/flow-search-unicode/releases/download/v1.0.4/SearchUnicode.Emoji.zip",
11+
"UrlDownload": "https://github.com/blueset/flow-search-unicode/releases/download/v1.0.4/SearchUnicode.Search.zip",
1212
"LatestReleaseDate": "2025-02-06T03:49:37Z",
1313
"DateAdded": "2025-01-19T01:42:28Z"
1414
}

0 commit comments

Comments
 (0)