Skip to content

Commit

Permalink
UPD: standardize naming
Browse files Browse the repository at this point in the history
Also prep achievement types for future update
  • Loading branch information
jshackles committed Jan 4, 2020
1 parent 2b956d4 commit 7bfdb25
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 41 deletions.
21 changes: 13 additions & 8 deletions n64_a3824d31-c2d3-4a1a-b321-7d0764da5513/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
import json, urllib.request, os, os.path
import user_config, corrections
import datetime
import logging
import time
from collections import namedtuple
from typing import Any, Callable, Dict, List, NewType, Optional
from galaxy.api.consts import LicenseType, LocalGameState, Platform
from galaxy.api.plugin import Plugin, create_and_run_plugin
from galaxy.api.types import Authentication, Game, LicenseInfo, LocalGame, GameTime
from galaxy.api.types import Achievement, Authentication, Game, LicenseInfo, LocalGame, GameTime

from version import __version__ as version

Expand Down Expand Up @@ -46,13 +50,14 @@ def update_game_cache(self):
playlist_dict = json.load(playlist_json)
for entry in playlist_dict["items"]:
if os.path.abspath(user_config.rom_path) in os.path.abspath(entry["path"]) and os.path.isfile(entry["path"]):
if entry["label"].split(" (")[0] in corrections.correction_list:
correct_name = corrections.correction_list[entry["label"].split(" (")[0]]
provided_name = entry["label"].split(" (")[0]
if provided_name in corrections.correction_list:
correct_name = corrections.correction_list[provided_name]
else:
correct_name = entry["label"].split(" (")[0]
correct_name = provided_name
game_list.append(
Game(
entry["crc32"].split("|")[0],
correct_name,
correct_name,
None,
LicenseInfo(LicenseType.SinglePurchase, None)
Expand Down Expand Up @@ -96,9 +101,9 @@ async def launch_game(self, game_id):
with open(self.playlist_path) as playlist_json:
playlist_dict = json.load(playlist_json)
for entry in playlist_dict["items"]:
if game_id == entry["crc32"].split("|")[0]:
if game_id == entry["label"].split(" (")[0]:
self.update_local_game_status(LocalGame(game_id, 2))
self.game_run = entry["crc32"].split("|")[0]
self.game_run = entry["label"].split(" (")[0]
self.proc = subprocess.Popen(os.path.abspath(user_config.emu_path + "retroarch.exe" + " -L \"" + user_config.emu_path + "cores/" + user_config.core + "\" \"" + entry["path"]))
break

Expand All @@ -112,7 +117,7 @@ async def get_game_time(self, game_id: str, context:any):
with open(self.playlist_path) as playlist_json:
playlist_dict = json.load(playlist_json)
for rom in playlist_dict["items"]:
if game_id == rom["crc32"].split("|")[0]:
if game_id == rom["label"].split(" (")[0]:
file_path = user_config.emu_path + "/playlists/logs/" + os.path.abspath(rom["path"]).split(os.path.abspath(user_config.rom_path) + "\\")[1][:-4] + ".lrtl"
if os.path.isfile(file_path):
with open(file_path) as json_data:
Expand Down
21 changes: 13 additions & 8 deletions nes_e2c630e1-3cbe-4dbd-9235-5e6a2d2955ad/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
import json, urllib.request, os, os.path
import user_config, corrections
import datetime
import logging
import time
from collections import namedtuple
from typing import Any, Callable, Dict, List, NewType, Optional
from galaxy.api.consts import LicenseType, LocalGameState, Platform
from galaxy.api.plugin import Plugin, create_and_run_plugin
from galaxy.api.types import Authentication, Game, LicenseInfo, LocalGame, GameTime
from galaxy.api.types import Achievement, Authentication, Game, LicenseInfo, LocalGame, GameTime

from version import __version__ as version

Expand Down Expand Up @@ -45,13 +49,14 @@ def update_game_cache(self):
playlist_dict = json.load(playlist_json)
for entry in playlist_dict["items"]:
if os.path.abspath(user_config.rom_path) in os.path.abspath(entry["path"]) and os.path.isfile(entry["path"]):
if entry["label"].split(" (")[0] in corrections.correction_list:
correct_name = corrections.correction_list[entry["label"].split(" (")[0]]
provided_name = entry["label"].split(" (")[0]
if provided_name in corrections.correction_list:
correct_name = corrections.correction_list[provided_name]
else:
correct_name = entry["label"].split(" (")[0]
correct_name = provided_name
game_list.append(
Game(
entry["crc32"].split("|")[0],
correct_name,
correct_name,
None,
LicenseInfo(LicenseType.SinglePurchase, None)
Expand Down Expand Up @@ -95,9 +100,9 @@ async def launch_game(self, game_id):
with open(self.playlist_path) as playlist_json:
playlist_dict = json.load(playlist_json)
for entry in playlist_dict["items"]:
if game_id == entry["crc32"].split("|")[0]:
if game_id == entry["label"].split(" (")[0]:
self.update_local_game_status(LocalGame(game_id, 2))
self.game_run = entry["crc32"].split("|")[0]
self.game_run = entry["label"].split(" (")[0]
self.proc = subprocess.Popen(os.path.abspath(user_config.emu_path + "retroarch.exe" + " -L \"" + user_config.emu_path + "cores/" + user_config.core + "\" \"" + entry["path"]))
break

Expand All @@ -111,7 +116,7 @@ async def get_game_time(self, game_id: str, context:any):
with open(self.playlist_path) as playlist_json:
playlist_dict = json.load(playlist_json)
for rom in playlist_dict["items"]:
if game_id == rom["crc32"].split("|")[0]:
if game_id == rom["label"].split(" (")[0]:
file_path = user_config.emu_path + "/playlists/logs/" + os.path.abspath(rom["path"]).split(os.path.abspath(user_config.rom_path) + "\\")[1][:-4] + ".lrtl"
if os.path.isfile(file_path):
with open(file_path) as json_data:
Expand Down
13 changes: 9 additions & 4 deletions ps1_ff02c67d-5962-4e79-a3a3-928814edb270/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
import json, urllib.request, os, os.path
import user_config, corrections
import datetime
import logging
import time
from collections import namedtuple
from typing import Any, Callable, Dict, List, NewType, Optional
from galaxy.api.consts import LicenseType, LocalGameState, Platform
from galaxy.api.plugin import Plugin, create_and_run_plugin
from galaxy.api.types import Authentication, Game, LicenseInfo, LocalGame, GameTime
from galaxy.api.types import Achievement, Authentication, Game, LicenseInfo, LocalGame, GameTime

from version import __version__ as version

Expand Down Expand Up @@ -45,10 +49,11 @@ def update_game_cache(self):
playlist_dict = json.load(playlist_json)
for entry in playlist_dict["items"]:
if os.path.abspath(user_config.rom_path) in os.path.abspath(entry["path"]) and os.path.isfile(entry["path"]):
if entry["label"].split(" (")[0] in corrections.correction_list:
correct_name = corrections.correction_list[entry["label"].split(" (")[0]]
provided_name = entry["label"].split(" (")[0]
if provided_name in corrections.correction_list:
correct_name = corrections.correction_list[provided_name]
else:
correct_name = entry["label"].split(" (")[0]
correct_name = provided_name
game_list.append(
Game(
correct_name,
Expand Down
13 changes: 9 additions & 4 deletions psp_05487532-ba29-411b-b799-784262d275bd/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
import json, urllib.request, os, os.path
import user_config, corrections
import datetime
import logging
import time
from collections import namedtuple
from typing import Any, Callable, Dict, List, NewType, Optional
from galaxy.api.consts import LicenseType, LocalGameState, Platform
from galaxy.api.plugin import Plugin, create_and_run_plugin
from galaxy.api.types import Authentication, Game, LicenseInfo, LocalGame, GameTime
from galaxy.api.types import Achievement, Authentication, Game, LicenseInfo, LocalGame, GameTime

from version import __version__ as version

Expand Down Expand Up @@ -45,10 +49,11 @@ def update_game_cache(self):
playlist_dict = json.load(playlist_json)
for entry in playlist_dict["items"]:
if os.path.abspath(user_config.rom_path) in os.path.abspath(entry["path"]) and os.path.isfile(entry["path"]):
if entry["label"].split(" (")[0] in corrections.correction_list:
correct_name = corrections.correction_list[entry["label"].split(" (")[0]]
provided_name = entry["label"].split(" (")[0]
if provided_name in corrections.correction_list:
correct_name = corrections.correction_list[provided_name]
else:
correct_name = entry["label"].split(" (")[0]
correct_name = provided_name
game_list.append(
Game(
correct_name,
Expand Down
8 changes: 7 additions & 1 deletion segag_e3ac94e7-945e-459d-bc1e-676cff8173f9/corrections.py
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
correction_list = {}
correction_list = {}

correction_list["Sonic Spinball"] = "Sonic the Hedgehog: Spinball"
correction_list["Adventures of Batman & Robin, The"] = "The Adventures of Batman & Robin (Genesis)"
correction_list["Alien 3"] = "Alien\u00b3"
correction_list["Batman - The Video Game"] = "Batman"
correction_list["Chakan"] = "Chakan: The Forever Man"
13 changes: 9 additions & 4 deletions segag_e3ac94e7-945e-459d-bc1e-676cff8173f9/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
import json, urllib.request, os, os.path
import user_config, corrections
import datetime
import logging
import time
from collections import namedtuple
from typing import Any, Callable, Dict, List, NewType, Optional
from galaxy.api.consts import LicenseType, LocalGameState, Platform
from galaxy.api.plugin import Plugin, create_and_run_plugin
from galaxy.api.types import Authentication, Game, LicenseInfo, LocalGame, GameTime
from galaxy.api.types import Achievement, Authentication, Game, LicenseInfo, LocalGame, GameTime

from version import __version__ as version

Expand Down Expand Up @@ -45,10 +49,11 @@ def update_game_cache(self):
playlist_dict = json.load(playlist_json)
for entry in playlist_dict["items"]:
if os.path.abspath(user_config.rom_path) in os.path.abspath(entry["path"]) and os.path.isfile(entry["path"]):
if entry["label"].split(" (")[0] in corrections.correction_list:
correct_name = corrections.correction_list[entry["label"].split(" (")[0]]
provided_name = entry["label"].split(" (")[0]
if provided_name in corrections.correction_list:
correct_name = corrections.correction_list[provided_name]
else:
correct_name = entry["label"].split(" (")[0]
correct_name = provided_name
game_list.append(
Game(
correct_name,
Expand Down
13 changes: 9 additions & 4 deletions sms_c6689bfb-7ba4-4d24-98e3-bd2dc339926b/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
import json, urllib.request, os, os.path
import user_config, corrections
import datetime
import logging
import time
from collections import namedtuple
from typing import Any, Callable, Dict, List, NewType, Optional
from galaxy.api.consts import LicenseType, LocalGameState, Platform
from galaxy.api.plugin import Plugin, create_and_run_plugin
from galaxy.api.types import Authentication, Game, LicenseInfo, LocalGame, GameTime
from galaxy.api.types import Achievement, Authentication, Game, LicenseInfo, LocalGame, GameTime

from version import __version__ as version

Expand Down Expand Up @@ -45,10 +49,11 @@ def update_game_cache(self):
playlist_dict = json.load(playlist_json)
for entry in playlist_dict["items"]:
if os.path.abspath(user_config.rom_path) in os.path.abspath(entry["path"]) and os.path.isfile(entry["path"]):
if entry["label"].split(" (")[0] in corrections.correction_list:
correct_name = corrections.correction_list[entry["label"].split(" (")[0]]
provided_name = entry["label"].split(" (")[0]
if provided_name in corrections.correction_list:
correct_name = corrections.correction_list[provided_name]
else:
correct_name = entry["label"].split(" (")[0]
correct_name = provided_name
game_list.append(
Game(
correct_name,
Expand Down
21 changes: 13 additions & 8 deletions snes_bc831044-f772-4391-8c22-529f42cb9799/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
import json, urllib.request, os, os.path
import user_config, corrections
import datetime
import logging
import time
from collections import namedtuple
from typing import Any, Callable, Dict, List, NewType, Optional
from galaxy.api.consts import LicenseType, LocalGameState, Platform
from galaxy.api.plugin import Plugin, create_and_run_plugin
from galaxy.api.types import Authentication, Game, LicenseInfo, LocalGame, GameTime
from galaxy.api.types import Achievement, Authentication, Game, LicenseInfo, LocalGame, GameTime

from version import __version__ as version

Expand Down Expand Up @@ -45,13 +49,14 @@ def update_game_cache(self):
playlist_dict = json.load(playlist_json)
for entry in playlist_dict["items"]:
if os.path.abspath(user_config.rom_path) in os.path.abspath(entry["path"]) and os.path.isfile(entry["path"]):
if entry["label"].split(" (")[0] in corrections.correction_list:
correct_name = corrections.correction_list[entry["label"].split(" (")[0]]
provided_name = entry["label"].split(" (")[0]
if provided_name in corrections.correction_list:
correct_name = corrections.correction_list[provided_name]
else:
correct_name = entry["label"].split(" (")[0]
correct_name = provided_name
game_list.append(
Game(
entry["crc32"].split("|")[0],
correct_name,
correct_name,
None,
LicenseInfo(LicenseType.SinglePurchase, None)
Expand Down Expand Up @@ -95,9 +100,9 @@ async def launch_game(self, game_id):
with open(self.playlist_path) as playlist_json:
playlist_dict = json.load(playlist_json)
for entry in playlist_dict["items"]:
if game_id == entry["crc32"].split("|")[0]:
if game_id == ["label"].split(" (")[0]:
self.update_local_game_status(LocalGame(game_id, 2))
self.game_run = entry["crc32"].split("|")[0]
self.game_run = ["label"].split(" (")[0]
self.proc = subprocess.Popen(os.path.abspath(user_config.emu_path + "retroarch.exe" + " -L \"" + user_config.emu_path + "cores/" + user_config.core + "\" \"" + entry["path"]))
break

Expand All @@ -111,7 +116,7 @@ async def get_game_time(self, game_id: str, context:any):
with open(self.playlist_path) as playlist_json:
playlist_dict = json.load(playlist_json)
for rom in playlist_dict["items"]:
if game_id == rom["crc32"].split("|")[0]:
if game_id == rom["label"].split(" (")[0]:
file_path = user_config.emu_path + "/playlists/logs/" + os.path.abspath(rom["path"]).split(os.path.abspath(user_config.rom_path) + "\\")[1][:-4] + ".lrtl"
if os.path.isfile(file_path):
with open(file_path) as json_data:
Expand Down

0 comments on commit 7bfdb25

Please sign in to comment.