Fuyukai / OWAPI

Overwatch JSON API
https://owapi.net
MIT License
456 stars 74 forks source link

Playtime appears to be off #228

Open Double0negative opened 6 years ago

Double0negative commented 6 years ago

Issue

The hero playtime being returned from the API appears to be incorrect. For example,

https://owapi.net/api/v3/u/Double0-11909/blob

shows 10hr playtime on hanzo in competitive whereas

https://playoverwatch.com/en-us/career/pc/Double0-11909

shows 14. Widowmaker shows 56hrs in QP whereas playoverwatch shows 58, etc

jp1337 commented 6 years ago

OWAPI is using a more accurate Platime Calculation than Blizzard is doing on their Website. Please compare the OWAPI Values with ingame Values. If you want to use the Calculated Value Blizzard is showing on their Website you can use the "time_played" Value in Quickplay and Competitive Section. For example Widowmaker: "eu" -> "heroes" -> "stats" -> "quickplay" -> "widowmaker" -> "time_played" is showing 58 which is the Value on the Blizzard Website.

You can see the code for calculating the Hero Playtime here:

    # Loop over each one, extracting the name and hours counted.
    percent_per_second = None
    for child in reversed(hero_info):
        name, played = child.getchildren()
        name, played = util.sanitize_string(name.text), played.text.lower()

        time = 0
        if played != "--":
            time = util.try_extract(played)

        # More accurate playtime calculation
        # Requires reversing hero_info
        category_item = child.getparent().getparent()
        percent = float(category_item.attrib['data-overwatch-progress-percent'])
        if percent_per_second is None and time < 1 and time > 0:
            seconds = 3600 * time
            percent_per_second = percent / seconds

        built_dict[name] = time
        if percent_per_second != None:
            built_dict[name] = (percent / percent_per_second) / float(3600)