Commit 2e94e265 authored by Hiro's avatar Hiro 🏄
Browse files

Refactor get_links script

parent 3fabf078
...@@ -53,14 +53,13 @@ def main(): ...@@ -53,14 +53,13 @@ def main():
args = parser.parse_args() args = parser.parse_args()
abs_filename = os.path.abspath(args.filename) abs_filename = os.path.abspath(args.filename)
webFile = request.urlopen("https://lektor-staging.torproject.org/tpo/staging/projects/torbrowser/RecommendedTBBVersions/") webFile = request.urlopen("https://www.torproject.org/projects/torbrowser/RecommendedTBBVersions/")
versions = webFile.read().decode('utf-8') versions = webFile.read().decode('utf-8').translate({ord(c): None for c in '[]\n" '})
version = versions.split(""")[1] version = versions.split(",")[4]
providers = { providers = {
"osx": "https://gitlab.com/hiromipaw/torbrowser/raw/releases/", "gitlab": "https://gitlab.com/thetorproject/gettorbrowser/raw/releases/",
"windows": "https://gitlab.com/hiromipaw/torbrowser/raw/releases/", "github": "https://github.com/TheTorProject/gettorbrowser/raw/torbrowser-releases/"
"linux": "https://gitlab.com/hiromipaw/torbrowser/raw/releases/"
} }
...@@ -78,8 +77,8 @@ def main(): ...@@ -78,8 +77,8 @@ def main():
"linux": "_en-US.tar.xz" "linux": "_en-US.tar.xz"
} }
keys = set().union(suffixes, versions, prefixes) keys = {'osx', 'windows', 'linux'}
releases = {k: "".join(dic.get(k, version) for dic in (providers, prefixes, versions, suffixes)) for k in keys} releases = {k: "".join(dic.get(k, version) for dic in (prefixes, versions, suffixes)) for k in keys}
if not abs_filename: if not abs_filename:
...@@ -97,10 +96,11 @@ def main(): ...@@ -97,10 +96,11 @@ def main():
" version TEXT, provider TEXT, status TEXT)" " version TEXT, provider TEXT, status TEXT)"
) )
for k in keys: for k in keys:
c.execute( for p in providers:
"INSERT INTO links(link, platform, arch, version, provider, status)" c.execute(
"VALUES ('%s', '%s', '64', '%s', 'gitlab', 'ACTIVE')" %(releases.get(k), k, version) "INSERT INTO links(link, platform, arch, version, provider, status)"
) "VALUES ('%s', '%s', '64', '%s', '%s', 'ACTIVE')" %(providers.get(p) + releases.get(k), k, version, p))
)
if __name__ == "__main__": if __name__ == "__main__":
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment