-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
73 changed files
with
1,045 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"Name": "Reinstaller", | ||
"Author": "Kezyma", | ||
"Description": "Reinstaller allows you to conveninetly backup mod installers to re-run later, without risk of them cluttering up your downloads section in Mod Organizer 2.", | ||
"NexusUrl": "https://www.nexusmods.com/skyrimspecialedition/mods/59292", | ||
"GithubUrl": "https://github.com/Kezyma/ModOrganizer-Plugins", | ||
"DownloadUrl": "https://github.com/Kezyma/ModOrganizer-Plugins/releases/download/Current/reinstaller.zip", | ||
"PluginPath": [ "reinstaller" ], | ||
"LocalePath": [], | ||
"DataPath": [ "data/reinstaller" ], | ||
"Versions": [ | ||
{ | ||
"Version": "1.0.6", | ||
"Released": "2021-12-13", | ||
"MinSupport": "2.4.2", | ||
"MaxSupport": "2.5.0", | ||
"DownloadUrl": "https://github.com/Kezyma/ModOrganizer-Plugins/releases/download/reinstaller-1.0.6/reinstaller.zip", | ||
"PluginPath": [ "reinstaller" ], | ||
"LocalePath": [], | ||
"DataPath": [ "data/reinstaller" ] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"Name": "Shortcutter", | ||
"Author": "Kezyma", | ||
"Description": "Shortcutter gives you the option of quickly creating instance and profile specific desktop shortcuts, allowing you to quickly launch your game without having to manually switch inside Mod Organizer.", | ||
"NexusUrl": "https://www.nexusmods.com/skyrimspecialedition/mods/59827", | ||
"GithubUrl": "https://github.com/Kezyma/ModOrganizer-Plugins", | ||
"DownloadUrl": "https://github.com/Kezyma/ModOrganizer-Plugins/releases/download/Current/shortcutter.zip", | ||
"PluginPath": [ "shortcutter" ], | ||
"LocalePath": [], | ||
"DataPath": [ "data/shortcutter" ], | ||
"Versions": [ | ||
{ | ||
"Version": "1.0.4", | ||
"Released": "2021-12-13", | ||
"MinSupport": "2.4.2", | ||
"MaxSupport": "2.5.0", | ||
"DownloadUrl": "https://github.com/Kezyma/ModOrganizer-Plugins/releases/download/shortcutter-1.0.4/shortcutter.zip", | ||
"PluginPath": [ "shortcutter" ], | ||
"LocalePath": [], | ||
"DataPath": [ "data/shortcutter" ] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import mobase, os | ||
from plugin_version import PluginVersion | ||
|
||
class PluginData(self): | ||
|
||
def __init__(self, jsonObject=dict): | ||
self.json = jsonObject | ||
super().__init__() | ||
|
||
def getJsonProperty(self, key=str): | ||
if key in self.json.keys(): | ||
return self.json[key] | ||
else: | ||
return None | ||
|
||
def getJsonArray(self, key=str): | ||
data = self.getJsonProperty(key) | ||
res = [] | ||
if data: | ||
try: | ||
for val in data: | ||
res.append(data) | ||
return res | ||
except: | ||
return None | ||
else: | ||
return None | ||
|
||
def identifier(self): | ||
return str(self.getJsonProperty("Identifier")) | ||
|
||
def name(self): | ||
return str(self.getJsonProperty("Name")) | ||
|
||
def description(self): | ||
return str(self.getJsonProperty("Description")) | ||
|
||
def nexusUrl(self): | ||
return str(self.getJsonProperty("NexusUrl")) | ||
|
||
def githubUrl(self): | ||
return str(self.getJsonProperty("GithubUrl")) | ||
|
||
def downloadUrl(self): | ||
return str(self.getJsonProperty("DownloadUrl")) | ||
|
||
def pluginPaths(self): | ||
paths = [] | ||
data = self.getJsonArray("PluginPath") | ||
if data: | ||
for path in data: | ||
paths.append(str(path)) | ||
return paths | ||
else: | ||
return None | ||
|
||
def localePaths(self): | ||
paths = [] | ||
data = self.getJsonArray("LocalePath") | ||
if data: | ||
for path in data: | ||
paths.append(str(path)) | ||
return paths | ||
else: | ||
return None | ||
|
||
def dataPaths(self): | ||
paths = [] | ||
data = self.getJsonArray("DataPath") | ||
if data: | ||
for path in data: | ||
paths.append(str(path)) | ||
return paths | ||
else: | ||
return None | ||
|
||
def versions(): | ||
versions = [] | ||
data = self.getJsonArray("Versions") | ||
if data: | ||
for version in data: | ||
versions.append(PluginVersion(version)) | ||
return versions | ||
else: | ||
return None |
71 changes: 71 additions & 0 deletions
71
release/pluginfinder/pluginfinder/models/plugin_version.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import mobase, os | ||
|
||
class PluginVersion(self): | ||
|
||
def __init__(self, jsonObject=dict): | ||
self.json = jsonObject | ||
super().__init__() | ||
|
||
def getJsonProperty(self, key=str): | ||
if key in self.json.keys(): | ||
return self.json[key] | ||
else: | ||
return None | ||
|
||
def getJsonArray(self, key=str): | ||
data = self.getJsonProperty(key) | ||
res = [] | ||
if data: | ||
try: | ||
for val in data: | ||
res.append(data) | ||
return res | ||
except: | ||
return None | ||
else: | ||
return None | ||
|
||
def released(self): | ||
return str(self.getJsonProperty("Released")) | ||
|
||
def minSupport(self): | ||
return str(self.getJsonProperty("MinSupport")) | ||
|
||
def maxSupport(self): | ||
return str(self.getJsonProperty("MaxSupport")) | ||
|
||
def version(self): | ||
return str(self.getJsonProperty("Version")) | ||
|
||
def downloadUrl(self): | ||
return str(self.getJsonProperty("DownloadUrl")) | ||
|
||
def pluginPaths(self): | ||
paths = [] | ||
data = self.getJsonArray("PluginPath") | ||
if data: | ||
for path in data: | ||
paths.append(str(path)) | ||
return paths | ||
else: | ||
return None | ||
|
||
def localePaths(self): | ||
paths = [] | ||
data = self.getJsonArray("LocalePath") | ||
if data: | ||
for path in data: | ||
paths.append(str(path)) | ||
return paths | ||
else: | ||
return None | ||
|
||
def dataPaths(self): | ||
paths = [] | ||
data = self.getJsonArray("DataPath") | ||
if data: | ||
for path in data: | ||
paths.append(str(path)) | ||
return paths | ||
else: | ||
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
release/pluginfinder/pluginfinder/modules/pluginfinder_search.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import mobase, os, urllib, json | ||
from pathlib import Path | ||
from datetime import datetime, timedelta | ||
from itertools import islice | ||
from pluginfinder_paths import PluginFinderPaths | ||
from pluginfinder_files import PluginFinderFiles | ||
from ...shared.shared_utilities import SharedUtilities | ||
from ..models.plugin_data import PluginData | ||
|
||
class PluginFinderSearch(): | ||
|
||
def __init__(self, organiser=mobase.IOrganizer, paths=PluginFinderPaths, files=PluginFinderFiles): | ||
self.organiser = organiser | ||
self.paths = paths | ||
self.files = files | ||
self.utilities = SharedUtilities() | ||
super().__init__() | ||
|
||
def deployInitialDirectory(self): | ||
""" Deploys the initial directory file, only happens on first run. """ | ||
if Path(self.paths.initialDirectoryPath()).exists(): | ||
self.utilities.moveTo(self.paths.initialDirectoryPath(), self.paths.directoryJsonPath()) | ||
|
||
def updateDirectory(self): | ||
""" Attempt to download a directory update from Github. """ | ||
try: | ||
data = json.loads(urllib.request.urlopen(self.paths.pluginDirectoryUrl()).read()) | ||
with open(self.paths.directoryJsonPath(), "w") as rcJson: | ||
json.dump(data, rcJson) | ||
except: | ||
qInfo("Could not download update.") | ||
urllib.request.urlcleanup() | ||
|
||
def directory(self): | ||
""" Get the directory as json. """ | ||
# Deploy if it's first run. | ||
self.deployInitialDirectory() | ||
# If the file is missing or old, update it. | ||
if not Path(self.paths.directoryJsonPath()).exists(): | ||
if datetime.fromtimestamp(os.path.getmtime(str(self.paths.directoryJsonPath()))) < (datetime.today() - timedelta(days=1)): | ||
self.updateDirectory() | ||
# Load the directory file. | ||
directory = json.load(open(self.paths.directoryJsonPath())) | ||
return directory | ||
|
||
def searchDirectory(self, searchTerms=str): | ||
""" Searches the directory by plugin name. """ | ||
results = [] | ||
for plugin in self.directory(): | ||
if "Name" in plugin: | ||
if searchTerms in plugin["Name"]: | ||
results.append(plugin) | ||
return results | ||
|
||
def updatePluginData(self, pluginId=str): | ||
""" Gets the json file for the current plugin. """ | ||
for plugin in self.directory(): | ||
if plugin["Identifier"] == str(pluginId): | ||
url = plugin["Manifest"] | ||
try: | ||
data = json.loads(urllib.request.urlopen(str(url)).read()) | ||
with open(self.paths.pluginDataCachePath(pluginId) "w") as rcJson: | ||
json.dump(data, rcJson) | ||
except: | ||
qInfo("Could not download update.") | ||
urllib.request.urlcleanup() | ||
|
||
def pluginData(self, pluginId=str): | ||
""" Loads the data for a plugin. """ | ||
# If the file is missing or old, update it. | ||
if not Path(self.paths.pluginDataCachePath(pluginId)).exists() or datetime.fromtimestamp(os.path.getmtime(str(self.paths.pluginDataCachePath(pluginId)))) < (datetime.today() - timedelta(days=1)): | ||
self.updatePluginData(pluginId) | ||
# If the file now exists (it should), load it. | ||
if Path(self.paths.pluginDataCachePath(pluginId)).exists(): | ||
try: | ||
data = json.load(open(self.paths.pluginDataCachePath(pluginId))) | ||
data["Identifier"] = str(pluginId) | ||
return PluginData(data) | ||
except: | ||
return None | ||
# Return an null if we can't load the file. | ||
return None | ||
|
||
def pagedPluginData(self, searchTerms=str, page=int, pageSize=int): | ||
""" Get a paged list of plugin data. """ | ||
manifestSearch = self.searchDirectory(searchTerms) | ||
pagedList = list(islice(manifestSearch, ((page-1)*pageSize), ((page-1)*pageSize) + pageSize)) | ||
results = [] | ||
for item in pagedList: | ||
if "Identifier" in item: | ||
results.append(self.pluginData(str(item["Identifier"]))) | ||
return results |
Oops, something went wrong.