reko-beep / hsr-data

Honkai star rail data from starrailstation.com
MIT License
60 stars 13 forks source link

O_VALUE (Version 1.2.0) #13

Closed Vocaloid2048 closed 5 months ago

Vocaloid2048 commented 1 year ago

Sorry for asking a dummy question, is that there have any possible way to get O_VALUE by user/myself? It seems O_VALUE has changed again (Since Version 1.2.0 updated) ... Thx for your help if possible Also sorry again if it's silly

Vocaloid2048 commented 1 year ago

API key : 37160d77fb2a075191bee3ec30c09687 U can get from starrailstation's -> choose one character -> main.ce34ec5f.js -> Search "Live"

reko-beep commented 1 year ago

Oh thanks for telling, sorry I have been busy irl, so I have not contributed or looked at the project at all, you can use this from automating.

import re
import json

def getAllOValues():
    URL = 'https://starrailstation.com/static/js/main.ce34ec5f.js'

    content_text = get(URL).text

    o_values = {}
    pattern = 'JSON\.parse\(.*?\)'

    results = re.findall(pattern, content_text)
    for result in results:
        if 'Live' in result:
            dict_ = json.loads(result[result.find("{"): result.find('}')+1])
            for key in dict_:
                sub_key = key.split('/')
                if sub_key[0].lower() not in o_values:
                    o_values[sub_key[0].lower()] = {}
                o_values[sub_key[0].lower()][sub_key[1].lower().replace('v', '', 1)] =  dict_[key]

    return o_values

print(getAllOValues())