Exemplo n.º 1
0
def parse_dates():
    """Parse all release dates into actual dates."""

    formats = (
        '%d %b %Y',
        '%d %b, %Y',
        '%b %Y',
    )

    def parse_d(val, i=0):
        if i >= len(formats):
            return None
        try:
            return datetime.strptime(val, formats[i]).date()
        except ValueError:
            return parse_d(val, i + 1)

    for app_id, app_info, update_time in steamdb.load_all_raw_app_details():
        val = app_info[b'release_date'][b'date'].decode('ascii')
        release_date = parse_d(val)
        #if release_date is not None and release_date > date.today():
        #    release_date = None

        if release_date is None and val != '':
            print(release_date, repr(val), app_id)
Exemplo n.º 2
0
def count_keys(type=None):

    ct = 0
    d = {}

    for app_id, app_info, update_time in steamdb.load_all_raw_app_details():
        if type is not None and app_info.get(b'type') != type:
            continue
        ct += 1
        for k in app_info.keys():
            d[k] = 1 + d.get(k, 0)

    print(ct)
    pprint(list(reversed(sorted([(v / ct, k) for k, v in d.items()]))))
Exemplo n.º 3
0
def count_keys(type=None):

    ct = 0
    d = {}

    for app_id, app_info, update_time in steamdb.load_all_raw_app_details():
        if type is not None and app_info.get(b'type') != type:
            continue
        ct += 1
        for k in app_info.keys():
            d[k] = 1 + d.get(k, 0)

    print(ct)
    pprint(list(reversed(sorted([(v / ct, k) for k, v in d.items()]))))
Exemplo n.º 4
0
def count_values(key, number=None, type=None):

    if number is None:
        number = 9999999

    d = {}
    ct = 0

    for app_id, app_info, update_time in steamdb.load_all_raw_app_details():
        if type is not None and app_info.get(b'type') != type:
            continue
        ct += 1
        vkey = str(app_info.get(key))
        d[vkey] = 1 + d.get(vkey, 0)

    print(ct)
    pprint(list(reversed(sorted([(v, k) for k, v in d.items()])))[:number])
Exemplo n.º 5
0
def read_genres(number=None):
    """Find the IDs of the available genres."""

    if number is None:
        number = 9999999

    d = {}
    ct = 0

    for app_id, app_info, update_time in steamdb.load_all_raw_app_details():
        ct += 1
        genres = app_info.get(b'genres', [])
        for genre in genres:
            vkey = genre.get(b'id')
            vval = genre.get(b'description')
            countdict = d.get(vkey, {})
            countdict[vval] = 1 + countdict.get(vval, 0)
            d[vkey] = countdict

    print(ct)
    pprint(d)
Exemplo n.º 6
0
def read_genres(number=None):
    """Find the IDs of the available genres."""

    if number is None:
        number = 9999999
    
    d = {}
    ct = 0

    for app_id, app_info, update_time in steamdb.load_all_raw_app_details():
        ct += 1
        genres = app_info.get(b'genres', [])
        for genre in genres:
            vkey = genre.get(b'id')
            vval = genre.get(b'description')
            countdict = d.get(vkey, {})
            countdict[vval] = 1 + countdict.get(vval, 0)
            d[vkey] = countdict

    print(ct)
    pprint(d)
Exemplo n.º 7
0
def read_categories():
    """Find the IDs of the available categories."""
    d = {}
    ct = 0

    for app_id, app_info, update_time in steamdb.load_all_raw_app_details():
        ct += 1
        categories = app_info.get(b'categories', [])
        for category in categories:
            vkey = category.get(b'id')
            vval = category.get(b'description')
            countdict = d.get(vkey, {})
            countdict[vval] = 1 + countdict.get(vval, 0)
            d[vkey] = countdict

    print(ct)
    categories = {}
    for ct_id in d:
        name = max((v, k) for k, v in d[ct_id].items())[1]
        print(name)
        categories[ct_id] = name.decode('ascii')

    pprint(categories)
Exemplo n.º 8
0
def parse_dates():
    """Parse all release dates into actual dates."""

    formats = (
        '%d %b %Y', '%d %b, %Y',
        '%b %Y',
    )
    def parse_d(val, i=0):
        if i >= len(formats):
            return None
        try:
            return datetime.strptime(val, formats[i]).date()
        except ValueError:
            return parse_d(val, i + 1)

    for app_id, app_info, update_time in steamdb.load_all_raw_app_details():
        val = app_info[b'release_date'][b'date'].decode('ascii')
        release_date = parse_d(val)
        #if release_date is not None and release_date > date.today():
        #    release_date = None

        if release_date is None and val != '':
            print(release_date, repr(val), app_id)
Exemplo n.º 9
0
def count_values(key, number=None, type=None):

    if number is None:
        number = 9999999
    
    d = {}
    ct = 0

    for app_id, app_info, update_time in steamdb.load_all_raw_app_details():
        if type is not None and app_info.get(b'type') != type:
            continue
        ct += 1
        vkey = str(app_info.get(key))
        d[vkey] = 1 + d.get(vkey, 0)

    print(ct)
    pprint(
        list(
            reversed(
                sorted([(v, k) for k, v in d.items()])
            )
        )[:number]
    )
Exemplo n.º 10
0
def read_categories():
    """Find the IDs of the available categories."""
    d = {}
    ct = 0

    for app_id, app_info, update_time in steamdb.load_all_raw_app_details():
        ct += 1
        categories = app_info.get(b'categories', [])
        for category in categories:
            vkey = category.get(b'id')
            vval = category.get(b'description')
            countdict = d.get(vkey, {})
            countdict[vval] = 1 + countdict.get(vval, 0)
            d[vkey] = countdict

    print(ct)
    categories = {}
    for ct_id in d:
        name = max((v,k) for k,v in d[ct_id].items())[1]
        print(name)
        categories[ct_id] = name.decode('ascii')

    pprint(categories)