From 9d6d544e0a9537c65902426acc9fddbaad3923ef Mon Sep 17 00:00:00 2001 From: Sunpy Date: Thu, 24 May 2018 12:57:38 +0200 Subject: [PATCH] Added base for version_scraper --- memory.json | 3 +++ version_scrape.py | 31 +++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 version_scrape.py diff --git a/memory.json b/memory.json index d3d8fb6..020a8d5 100644 --- a/memory.json +++ b/memory.json @@ -3,6 +3,9 @@ "last": 0, "failed": [] }, + "version_scrape": { + "last": 0 + }, "downloader": { "last": 0, "failed": [] diff --git a/version_scrape.py b/version_scrape.py new file mode 100644 index 0000000..5f5edc7 --- /dev/null +++ b/version_scrape.py @@ -0,0 +1,31 @@ +#Used for scraping osu version names from osu.ppy.sh and storing them into self database + +import urllib.request, json +import MySQLdb +import MySQLdb.cursors +import time, calendar +import atexit + +with open("config.json", "r") as f: + config = json.load(f) + +with open("memory.json", "r") as f: + memory = json.load(f) + +sql = MySQLdb.connect(**config["sql"], cursorclass = MySQLdb.cursors.DictCursor) + +cur = sql.cursor() + +def on_close(): + with open("memory.json", "w") as f: + json.dump(memory, f) + print("Closing...") + +atexit.register(on_close) + +URL = "https://osu.ppy.sh/web/get-internal-version.php?v={}" +VERSIONS = urllib.request.urlopen(URL.format("_")) # Gets all versions + +BEGINNING = memory["version_scrape"]["last"] +for i in range(VERSIONS): + pass #Unfinished \ No newline at end of file