diff options
author | crupest <crupest@outlook.com> | 2022-11-01 17:10:08 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-11-01 17:10:08 +0800 |
commit | a12a4441c75d239876fb3cb6d18427b972964f52 (patch) | |
tree | c92d03f91a2fee3605e575238ebed24f3efef307 /docker/arch-code-server/china-magic-for-pkgbuild.py | |
parent | 0714f98ff8fa890aaa80a3a8b05246698211cb1c (diff) | |
download | crupest-a12a4441c75d239876fb3cb6d18427b972964f52.tar.gz crupest-a12a4441c75d239876fb3cb6d18427b972964f52.tar.bz2 crupest-a12a4441c75d239876fb3cb6d18427b972964f52.zip |
Take good care of China.
Diffstat (limited to 'docker/arch-code-server/china-magic-for-pkgbuild.py')
-rwxr-xr-x | docker/arch-code-server/china-magic-for-pkgbuild.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/docker/arch-code-server/china-magic-for-pkgbuild.py b/docker/arch-code-server/china-magic-for-pkgbuild.py new file mode 100755 index 0000000..43a4d89 --- /dev/null +++ b/docker/arch-code-server/china-magic-for-pkgbuild.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python3 + +# In China? Good for you! + +import sys +import re + +# read STDIN until EOF +content = sys.stdin.read() + +url = re.search(r"url=(.+)", content).group(1) +if url.startswith('"') and url.endswith('"'): + url = url[1:-1] + +if url.startswith("https://github.com"): # yah, it's github! + content = re.sub(r"\$\{\s*url\s*\}|\$url", url, content) + content = content.replace("https://raw.githubusercontent.com", "https://gh.api.99988866.xyz/https://raw.githubusercontent.com") + content = re.sub(r'https://github\.com/(.+)/(.+)/releases/download', lambda match: f'https://gh.api.99988866.xyz/{match.group(0)}', content) + +# now print the result +print(content) |