sources: Set date added higher up
This commit is contained in:
@@ -3,7 +3,9 @@
|
||||
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
from collections.abc import Generator
|
||||
from contextlib import suppress
|
||||
from pathlib import Path
|
||||
from typing import Final, Protocol
|
||||
|
||||
@@ -53,8 +55,9 @@ def get_games() -> Generator[Game]:
|
||||
"""Installed games from all sources."""
|
||||
from . import heroic, imported, steam
|
||||
|
||||
added = int(time.time())
|
||||
for source in heroic, imported, steam:
|
||||
try:
|
||||
yield from source.get_games()
|
||||
except OSError:
|
||||
continue
|
||||
with suppress(OSError):
|
||||
for game in source.get_games():
|
||||
game.added = game.added or added
|
||||
yield game
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
# SPDX-FileCopyrightText: Copyright 2022-2025 kramo
|
||||
|
||||
import json
|
||||
import time
|
||||
from abc import ABC, abstractmethod
|
||||
from collections.abc import Generator, Iterable
|
||||
from contextlib import suppress
|
||||
@@ -113,9 +112,8 @@ class _NileSource(_StoreSource):
|
||||
|
||||
def get_games() -> Generator[Game]:
|
||||
"""Installed Heroic games."""
|
||||
added = int(time.time())
|
||||
for source in _LegendarySource, _GOGSource, _NileSource, _SideloadSource:
|
||||
yield from _games_from(source, added)
|
||||
yield from _games_from(source)
|
||||
|
||||
|
||||
def _config_dir() -> Path:
|
||||
@@ -139,7 +137,7 @@ def _hidden_app_names() -> Generator[str]:
|
||||
yield game["appName"]
|
||||
|
||||
|
||||
def _games_from(source: type[_Source], added: int) -> Generator[Game]:
|
||||
def _games_from(source: type[_Source]) -> Generator[Game]:
|
||||
try:
|
||||
with (_config_dir() / source.library_path()).open() as fp:
|
||||
library = json.load(fp)
|
||||
@@ -171,7 +169,6 @@ def _games_from(source: type[_Source], added: int) -> Generator[Game]:
|
||||
cover = None
|
||||
|
||||
yield Game(
|
||||
added=added,
|
||||
executable=f"{OPEN} heroic://launch/{entry['runner']}/{app_name}",
|
||||
game_id=f"{source_id}_{app_name}",
|
||||
source=source_id,
|
||||
|
||||
@@ -6,7 +6,6 @@ import itertools
|
||||
import logging
|
||||
import re
|
||||
import struct
|
||||
import time
|
||||
from collections import defaultdict
|
||||
from collections.abc import Generator, Sequence
|
||||
from contextlib import suppress
|
||||
@@ -109,8 +108,6 @@ class _AppInfo(NamedTuple):
|
||||
|
||||
def get_games() -> Generator[Game]:
|
||||
"""Installed Steam games."""
|
||||
added = int(time.time())
|
||||
|
||||
librarycache = _data_dir() / "appcache" / "librarycache"
|
||||
with (_data_dir() / "appcache" / "appinfo.vdf").open("rb") as fp:
|
||||
appinfo = defaultdict(_AppInfo, _parse_appinfo_vdf(fp))
|
||||
@@ -138,7 +135,6 @@ def get_games() -> Generator[Game]:
|
||||
|
||||
appids.add(appid)
|
||||
yield Game(
|
||||
added=added,
|
||||
executable=f"{OPEN} steam://rungameid/{appid}",
|
||||
game_id=f"{ID}_{appid}",
|
||||
source=ID,
|
||||
|
||||
Reference in New Issue
Block a user