Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import os
- import re
- DIRECTORY = os.path.dirname(os.path.realpath(__file__))
- UNITS = "http://optc-db.github.io/common/data/units.js"
- def decode(link=""):
- if link == "":
- raise Exception("Empty link provided")
- url = link.replace("http://", "").split("/")
- if url[0] != "optc-db.github.io" or url[1] != "damage":
- raise Exception("Invalid link provided")
- chars = re.search(r'transfer/D([^C]+)C', "/".join(url[-2:])).groups(1)[0].split(",")
- char_name = []
- r = requests.get(UNITS)
- _chars = r.text.split('\n')
- for char in chars:
- char_id = int(char.split(":")[0])
- info = _chars[char_id]
- items = re.findall(r'"([^"]+)"', info)
- character_name = "{2} - [{0}](/{1})".format(items[0], items[1].lower(), char_id)
- char_name.append(character_name)
- print(char_name)
- decode("http://optc-db.github.io/damage/#/transfer/D1751:99:100:0:0,1751:99:100:0:0,831:99,1043:99,575:99,984:99C10,10B0D0E0Q0L0G0R0S100H")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement