diff --git a/app/app.py b/app/app.py index 146d2c6..edf0f55 100644 --- a/app/app.py +++ b/app/app.py @@ -153,12 +153,26 @@ def get_all_titles(): title.update(library_status) title['title_id_name'] = title['name'] if title['type'] == APP_TYPE_DLC: + dlc_has_latest_version = None all_dlc_existing_versions = get_all_dlc_existing_versions(title['app_id']) - if title['version'] == all_dlc_existing_versions[-1]: - title['has_latest_version'] = True + if all_dlc_existing_versions is not None and len(all_dlc_existing_versions): + if title['version'] == all_dlc_existing_versions[-1]: + dlc_has_latest_version = True + else: + dlc_has_latest_version = False + else: - title['has_latest_version'] = False + app_id_version_from_versions_txt = get_app_id_version_from_versions_txt(title['app_id']) + if app_id_version_from_versions_txt is not None: + if title['version'] == int(app_id_version_from_versions_txt): + dlc_has_latest_version = True + else: + dlc_has_latest_version = False + + + if dlc_has_latest_version is not None: + title['has_latest_version'] = dlc_has_latest_version titleid_info = get_game_info(title['title_id']) title['title_id_name'] = titleid_info['name'] diff --git a/app/titles.py b/app/titles.py index 3f28b48..ca638ac 100644 --- a/app/titles.py +++ b/app/titles.py @@ -99,6 +99,7 @@ def load_titledb(app_settings): global cnmts_db global titles_db global versions_db + global versions_txt_db with open(os.path.join(TITLEDB_DIR, 'cnmts.json')) as f: cnmts_db = json.load(f) @@ -108,6 +109,13 @@ def load_titledb(app_settings): with open(os.path.join(TITLEDB_DIR, 'versions.json')) as f: versions_db = json.load(f) + versions_txt_db = {} + with open(os.path.join(TITLEDB_DIR, 'versions.txt')) as f: + for line in f: + line_strip = line.rstrip("\n") + app_id, rightsId, version = line_strip.split('|') + versions_txt_db[app_id] = version + def identify_file_from_filename(filename): version = get_version_from_filename(filename) if version is None: @@ -225,11 +233,18 @@ def get_all_dlc_existing_versions(app_id): app_id = app_id.lower() if app_id in cnmts_db: versions_from_cnmts_db = cnmts_db[app_id].keys() - return sorted(versions_from_cnmts_db) + if len(versions_from_cnmts_db): + return sorted(versions_from_cnmts_db) + else: + print(f'No keys in cnmts.json for DLC app ID: {app_id.upper()}') + return None else: print(f'DLC app ID not in cnmts.json: {app_id.upper()}') return None +def get_app_id_version_from_versions_txt(app_id): + return versions_txt_db.get(app_id, None) + def get_all_existing_dlc(title_id): title_id = title_id.lower() dlcs = []