-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathversion-badge.py
33 lines (25 loc) · 890 Bytes
/
version-badge.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# This script is used in https://badgen.net/https/ashark.npkn.net/f1a682 to generate version badge.
# See how it works here: https://css-tricks.com/adding-custom-github-badges-to-your-repo/
from napkin import response # Note that it is available only in browser in napkin website
import re
import requests
import json
url = "https://raw.githubusercontent.com/Ashark/davinci-resolve-checker/master/davinci-resolve-checker.py"
file_content = requests.get(url).text
version = "Undetected"
for line in file_content.split('\n'):
if "project name" in line:
version = line
break
# print(version)
version = re.search(r'"(\d+\.\d+\.\d+.?)"', version).group(1)
# print(version)
result = """{{
"color": "green",
"status": "{v}",
"subject": "checker version"
}}""".format(v=version)
# print(result)
j = json.loads(result)
response.status_code = 200
response.body = j