🎨 Simplified sources
This commit is contained in:
@@ -16,12 +16,6 @@
|
|||||||
<key name="steam-location" type="s">
|
<key name="steam-location" type="s">
|
||||||
<default>"~/.steam/"</default>
|
<default>"~/.steam/"</default>
|
||||||
</key>
|
</key>
|
||||||
<key name="steam-flatpak-location" type="s">
|
|
||||||
<default>"~/.var/app/com.valvesoftware.Steam/data/Steam/"</default>
|
|
||||||
</key>
|
|
||||||
<key name="steam-windows-location" type="s">
|
|
||||||
<default>"C:\Program Files (x86)\Steam"</default>
|
|
||||||
</key>
|
|
||||||
<key name="lutris" type="b">
|
<key name="lutris" type="b">
|
||||||
<default>true</default>
|
<default>true</default>
|
||||||
</key>
|
</key>
|
||||||
@@ -31,12 +25,6 @@
|
|||||||
<key name="lutris-cache-location" type="s">
|
<key name="lutris-cache-location" type="s">
|
||||||
<default>"~/.var/app/net.lutris.Lutris/cache/lutris"</default>
|
<default>"~/.var/app/net.lutris.Lutris/cache/lutris"</default>
|
||||||
</key>
|
</key>
|
||||||
<key name="lutris-flatpak-location" type="s">
|
|
||||||
<default>"~/.var/app/net.lutris.Lutris/data/lutris/"</default>
|
|
||||||
</key>
|
|
||||||
<key name="lutris-flatpak-cache-location" type="s">
|
|
||||||
<default>"~/.var/app/net.lutris.Lutris/cache/lutris"</default>
|
|
||||||
</key>
|
|
||||||
<key name="lutris-import-steam" type="b">
|
<key name="lutris-import-steam" type="b">
|
||||||
<default>false</default>
|
<default>false</default>
|
||||||
</key>
|
</key>
|
||||||
@@ -46,12 +34,6 @@
|
|||||||
<key name="heroic-location" type="s">
|
<key name="heroic-location" type="s">
|
||||||
<default>"~/.config/heroic/"</default>
|
<default>"~/.config/heroic/"</default>
|
||||||
</key>
|
</key>
|
||||||
<key name="heroic-flatpak-location" type="s">
|
|
||||||
<default>"~/.var/app/com.heroicgameslauncher.hgl/config/heroic/"</default>
|
|
||||||
</key>
|
|
||||||
<key name="heroic-windows-location" type="s">
|
|
||||||
<default>""</default>
|
|
||||||
</key>
|
|
||||||
<key name="heroic-import-epic" type="b">
|
<key name="heroic-import-epic" type="b">
|
||||||
<default>true</default>
|
<default>true</default>
|
||||||
</key>
|
</key>
|
||||||
|
|||||||
@@ -8,7 +8,12 @@ from typing import Generator, Optional, TypedDict
|
|||||||
|
|
||||||
from src import shared
|
from src import shared
|
||||||
from src.game import Game
|
from src.game import Game
|
||||||
from src.importer.sources.source import NTSource, PosixSource, Source, SourceIterator
|
from src.importer.sources.source import (
|
||||||
|
LinuxSource,
|
||||||
|
Source,
|
||||||
|
SourceIterator,
|
||||||
|
WindowsSource,
|
||||||
|
)
|
||||||
from src.utils.decorators import (
|
from src.utils.decorators import (
|
||||||
replaced_by_env_path,
|
replaced_by_env_path,
|
||||||
replaced_by_path,
|
replaced_by_path,
|
||||||
@@ -121,7 +126,6 @@ class HeroicSource(Source):
|
|||||||
"""Generic heroic games launcher source"""
|
"""Generic heroic games launcher source"""
|
||||||
|
|
||||||
name = "Heroic"
|
name = "Heroic"
|
||||||
executable_format = "xdg-open heroic://launch/{app_name}"
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def game_id_format(self) -> str:
|
def game_id_format(self) -> str:
|
||||||
@@ -132,28 +136,20 @@ class HeroicSource(Source):
|
|||||||
return HeroicSourceIterator(source=self)
|
return HeroicSourceIterator(source=self)
|
||||||
|
|
||||||
|
|
||||||
class HeroicNativeSource(HeroicSource, PosixSource):
|
class HeroicNativeSource(HeroicSource, LinuxSource):
|
||||||
variant = "native"
|
variant = "linux"
|
||||||
|
executable_format = "xdg-open heroic://launch/{app_name}"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@replaced_by_schema_key("heroic-location")
|
@replaced_by_schema_key("heroic-location")
|
||||||
|
@replaced_by_path("~/.var/app/com.heroicgameslauncher.hgl/config/heroic/")
|
||||||
@replaced_by_env_path("XDG_CONFIG_HOME", "heroic/")
|
@replaced_by_env_path("XDG_CONFIG_HOME", "heroic/")
|
||||||
@replaced_by_path("~/.config/heroic/")
|
@replaced_by_path("~/.config/heroic/")
|
||||||
def location(self) -> Path:
|
def location(self) -> Path:
|
||||||
raise FileNotFoundError()
|
raise FileNotFoundError()
|
||||||
|
|
||||||
|
|
||||||
class HeroicFlatpakSource(HeroicSource, PosixSource):
|
class HeroicWindowsSource(HeroicSource, WindowsSource):
|
||||||
variant = "flatpak"
|
|
||||||
|
|
||||||
@property
|
|
||||||
@replaced_by_schema_key("heroic-flatpak-location")
|
|
||||||
@replaced_by_path("~/.var/app/com.heroicgameslauncher.hgl/config/heroic/")
|
|
||||||
def location(self) -> Path:
|
|
||||||
raise FileNotFoundError()
|
|
||||||
|
|
||||||
|
|
||||||
class HeroicWindowsSource(HeroicSource, NTSource):
|
|
||||||
variant = "windows"
|
variant = "windows"
|
||||||
executable_format = "start heroic://launch/{app_name}"
|
executable_format = "start heroic://launch/{app_name}"
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from time import time
|
|||||||
|
|
||||||
from src import shared
|
from src import shared
|
||||||
from src.game import Game
|
from src.game import Game
|
||||||
from src.importer.sources.source import PosixSource, Source, SourceIterator
|
from src.importer.sources.source import LinuxSource, Source, SourceIterator
|
||||||
from src.utils.decorators import replaced_by_path, replaced_by_schema_key
|
from src.utils.decorators import replaced_by_path, replaced_by_schema_key
|
||||||
from src.utils.save_cover import resize_cover, save_cover
|
from src.utils.save_cover import resize_cover, save_cover
|
||||||
|
|
||||||
@@ -74,7 +74,6 @@ class LutrisSource(Source):
|
|||||||
"""Generic lutris source"""
|
"""Generic lutris source"""
|
||||||
|
|
||||||
name = "Lutris"
|
name = "Lutris"
|
||||||
executable_format = "xdg-open lutris:rungameid/{game_id}"
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def game_id_format(self):
|
def game_id_format(self):
|
||||||
@@ -84,21 +83,13 @@ class LutrisSource(Source):
|
|||||||
return LutrisSourceIterator(source=self)
|
return LutrisSourceIterator(source=self)
|
||||||
|
|
||||||
|
|
||||||
class LutrisNativeSource(LutrisSource, PosixSource):
|
class LutrisNativeSource(LutrisSource, LinuxSource):
|
||||||
variant = "native"
|
variant = "linux"
|
||||||
|
executable_format = "xdg-open lutris:rungameid/{game_id}"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@replaced_by_schema_key("lutris-location")
|
@replaced_by_schema_key("lutris-location")
|
||||||
|
@replaced_by_path("~/.var/app/net.lutris.Lutris/data/lutris/")
|
||||||
@replaced_by_path("~/.local/share/lutris/")
|
@replaced_by_path("~/.local/share/lutris/")
|
||||||
def location(self):
|
def location(self):
|
||||||
raise FileNotFoundError()
|
raise FileNotFoundError()
|
||||||
|
|
||||||
|
|
||||||
class LutrisFlatpakSource(LutrisSource, PosixSource):
|
|
||||||
variant = "flatpak"
|
|
||||||
|
|
||||||
@property
|
|
||||||
@replaced_by_schema_key("lutris-flatpak-location")
|
|
||||||
@replaced_by_path("~/.var/app/net.lutris.Lutris/data/lutris/")
|
|
||||||
def location(self):
|
|
||||||
raise FileNotFoundError()
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import os
|
import sys
|
||||||
from abc import abstractmethod
|
from abc import abstractmethod
|
||||||
from collections.abc import Iterable, Iterator
|
from collections.abc import Iterable, Iterator
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@@ -66,7 +66,7 @@ class Source(Iterable):
|
|||||||
self.location
|
self.location
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
return False
|
return False
|
||||||
return os.name in self.available_on
|
return sys.platform in self.available_on
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
@@ -83,17 +83,17 @@ class Source(Iterable):
|
|||||||
"""Get the source's iterator, to use in for loops"""
|
"""Get the source's iterator, to use in for loops"""
|
||||||
|
|
||||||
|
|
||||||
class NTSource(Source):
|
class WindowsSource(Source):
|
||||||
"""Mixin for sources available on Windows"""
|
"""Mixin for sources available on Windows"""
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.available_on.add("nt")
|
self.available_on.add("win32")
|
||||||
|
|
||||||
|
|
||||||
class PosixSource(Source):
|
class LinuxSource(Source):
|
||||||
"""Mixin for sources available on POXIX-compliant systems"""
|
"""Mixin for sources available on Linux"""
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.available_on.add("posix")
|
self.available_on.add("linux")
|
||||||
|
|||||||
@@ -5,7 +5,12 @@ from typing import Iterator
|
|||||||
|
|
||||||
from src import shared
|
from src import shared
|
||||||
from src.game import Game
|
from src.game import Game
|
||||||
from src.importer.sources.source import NTSource, PosixSource, Source, SourceIterator
|
from src.importer.sources.source import (
|
||||||
|
LinuxSource,
|
||||||
|
Source,
|
||||||
|
SourceIterator,
|
||||||
|
WindowsSource,
|
||||||
|
)
|
||||||
from src.utils.decorators import (
|
from src.utils.decorators import (
|
||||||
replaced_by_env_path,
|
replaced_by_env_path,
|
||||||
replaced_by_path,
|
replaced_by_path,
|
||||||
@@ -20,10 +25,12 @@ class SteamSourceIterator(SourceIterator):
|
|||||||
manifests: set = None
|
manifests: set = None
|
||||||
manifests_iterator: Iterator[Path] = None
|
manifests_iterator: Iterator[Path] = None
|
||||||
installed_state_mask: int = 4
|
installed_state_mask: int = 4
|
||||||
|
appid_cache: set = None
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
self.appid_cache = set()
|
||||||
self.manifests = set()
|
self.manifests = set()
|
||||||
|
|
||||||
# Get dirs that contain steam app manifests
|
# Get dirs that contain steam app manifests
|
||||||
@@ -64,8 +71,13 @@ class SteamSourceIterator(SourceIterator):
|
|||||||
if not int(local_data["stateflags"]) & self.installed_state_mask:
|
if not int(local_data["stateflags"]) & self.installed_state_mask:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# Build game from local data
|
# Skip duplicate appids
|
||||||
appid = local_data["appid"]
|
appid = local_data["appid"]
|
||||||
|
if appid in self.appid_cache:
|
||||||
|
return None
|
||||||
|
self.appid_cache.add(appid)
|
||||||
|
|
||||||
|
# Build game from local data
|
||||||
values = {
|
values = {
|
||||||
"version": shared.SPEC_VERSION,
|
"version": shared.SPEC_VERSION,
|
||||||
"added": int(time()),
|
"added": int(time()),
|
||||||
@@ -91,17 +103,18 @@ class SteamSourceIterator(SourceIterator):
|
|||||||
|
|
||||||
class SteamSource(Source):
|
class SteamSource(Source):
|
||||||
name = "Steam"
|
name = "Steam"
|
||||||
executable_format = "xdg-open steam://rungameid/{game_id}"
|
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
return SteamSourceIterator(source=self)
|
return SteamSourceIterator(source=self)
|
||||||
|
|
||||||
|
|
||||||
class SteamNativeSource(SteamSource, PosixSource):
|
class SteamNativeSource(SteamSource, LinuxSource):
|
||||||
variant = "native"
|
variant = "linux"
|
||||||
|
executable_format = "xdg-open steam://rungameid/{game_id}"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@replaced_by_schema_key("steam-location")
|
@replaced_by_schema_key("steam-location")
|
||||||
|
@replaced_by_path("~/.var/app/com.valvesoftware.Steam/data/Steam/")
|
||||||
@replaced_by_env_path("XDG_DATA_HOME", "Steam/")
|
@replaced_by_env_path("XDG_DATA_HOME", "Steam/")
|
||||||
@replaced_by_path("~/.steam/")
|
@replaced_by_path("~/.steam/")
|
||||||
@replaced_by_path("~/.local/share/Steam/")
|
@replaced_by_path("~/.local/share/Steam/")
|
||||||
@@ -109,23 +122,12 @@ class SteamNativeSource(SteamSource, PosixSource):
|
|||||||
raise FileNotFoundError()
|
raise FileNotFoundError()
|
||||||
|
|
||||||
|
|
||||||
class SteamFlatpakSource(SteamSource, PosixSource):
|
class SteamWindowsSource(SteamSource, WindowsSource):
|
||||||
variant = "flatpak"
|
|
||||||
|
|
||||||
@property
|
|
||||||
@replaced_by_schema_key("steam-flatpak-location")
|
|
||||||
@replaced_by_path("~/.var/app/com.valvesoftware.Steam/data/Steam/")
|
|
||||||
def location(self):
|
|
||||||
raise FileNotFoundError()
|
|
||||||
|
|
||||||
|
|
||||||
class SteamWindowsSource(SteamSource, NTSource):
|
|
||||||
variant = "windows"
|
variant = "windows"
|
||||||
executable_format = "start steam://rungameid/{game_id}"
|
executable_format = "start steam://rungameid/{game_id}"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@replaced_by_schema_key("steam-windows-location")
|
@replaced_by_schema_key("steam-location")
|
||||||
@replaced_by_env_path("programfiles(x86)", "Steam")
|
@replaced_by_env_path("programfiles(x86)", "Steam")
|
||||||
@replaced_by_path("C:\\Program Files (x86)\\Steam")
|
|
||||||
def location(self):
|
def location(self):
|
||||||
raise FileNotFoundError()
|
raise FileNotFoundError()
|
||||||
|
|||||||
Reference in New Issue
Block a user