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