Merge remote-tracking branch 'origin'
This commit is contained in:
commit
e94f3a189c
53 changed files with 538 additions and 678 deletions
4
Batch Scripts/ConvertHEIC.bat
Normal file
4
Batch Scripts/ConvertHEIC.bat
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
@REM Converts a given JPEG to HEIC
|
||||||
|
cd "C:\Users\Jose\Documents\Code\Scripts\Shell Scripts\python"
|
||||||
|
pip install -r requirements.txt
|
||||||
|
python.exe convert_heic.py "%1"
|
||||||
61
OBS/PlexAmp/main.css
Normal file
61
OBS/PlexAmp/main.css
Normal file
|
|
@ -0,0 +1,61 @@
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
background-color: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
:root {
|
||||||
|
font-family: "Montserrat";
|
||||||
|
--teal: #00e7a9;
|
||||||
|
--height: 64px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
|
||||||
|
width: 384px;
|
||||||
|
height: var(--height);
|
||||||
|
padding: 1rem;
|
||||||
|
border-radius: 8px;
|
||||||
|
|
||||||
|
color: white;
|
||||||
|
/* background-color: #252525; */
|
||||||
|
background-color: transparent;
|
||||||
|
|
||||||
|
outline: 4px solid var(--teal);
|
||||||
|
outline-offset: -8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main img {
|
||||||
|
width: auto;
|
||||||
|
height: var(--height);
|
||||||
|
margin-right: 1rem;
|
||||||
|
border-radius: 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main .text {
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main .text b {
|
||||||
|
font-size: 1.15rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
#artist,
|
||||||
|
#album {
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.row-text {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
justify-content: space-between;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.row-text div {
|
||||||
|
width: 50%;
|
||||||
|
}
|
||||||
25
OBS/PlexAmp/main.html
Normal file
25
OBS/PlexAmp/main.html
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title> </title>
|
||||||
|
<script src="./main.js"></script>
|
||||||
|
<link rel="stylesheet" href="./main.css">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div class="main">
|
||||||
|
<img id="art" />
|
||||||
|
<div class="text">
|
||||||
|
<b id="name"></b>
|
||||||
|
<div id="second-row">
|
||||||
|
<div class="row-text" id="artist-album">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
123
OBS/PlexAmp/main.js
Normal file
123
OBS/PlexAmp/main.js
Normal file
|
|
@ -0,0 +1,123 @@
|
||||||
|
let intvl = null;
|
||||||
|
let lastSongData = null;
|
||||||
|
|
||||||
|
const PLEX_TOKEN = "hisKts9QfWyfLsAhkwDu";
|
||||||
|
const sessionUrl = `http://172.16.1.3:32400/status/sessions?X-Plex-Token=${PLEX_TOKEN}`;
|
||||||
|
|
||||||
|
const marqueeify = (text, elementType, amt) => {
|
||||||
|
if (text.length > amt) {
|
||||||
|
return `<marquee><${elementType}>${text}</${elementType}></marquee>`;
|
||||||
|
} else {
|
||||||
|
return `<${elementType}>${text}</${elementType}>`;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const parseXml = (xml, arrayTags) => {
|
||||||
|
let dom = null;
|
||||||
|
if (window.DOMParser) dom = new DOMParser().parseFromString(xml, "text/xml");
|
||||||
|
else if (window.ActiveXObject) {
|
||||||
|
dom = new ActiveXObject("Microsoft.XMLDOM");
|
||||||
|
dom.async = false;
|
||||||
|
if (!dom.loadXML(xml))
|
||||||
|
throw dom.parseError.reason + " " + dom.parseError.srcText;
|
||||||
|
} else throw new Error("cannot parse xml string!");
|
||||||
|
|
||||||
|
const parseNode = (xmlNode, result) => {
|
||||||
|
if (xmlNode.nodeName == "#text") {
|
||||||
|
let v = xmlNode.nodeValue;
|
||||||
|
if (v.trim()) result["#text"] = v;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let jsonNode = {},
|
||||||
|
existing = result[xmlNode.nodeName];
|
||||||
|
if (existing) {
|
||||||
|
if (!Array.isArray(existing))
|
||||||
|
result[xmlNode.nodeName] = [existing, jsonNode];
|
||||||
|
else result[xmlNode.nodeName].push(jsonNode);
|
||||||
|
} else {
|
||||||
|
if (arrayTags && arrayTags.indexOf(xmlNode.nodeName) != -1)
|
||||||
|
result[xmlNode.nodeName] = [jsonNode];
|
||||||
|
else result[xmlNode.nodeName] = jsonNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (xmlNode.attributes)
|
||||||
|
for (let attribute of xmlNode.attributes)
|
||||||
|
jsonNode[attribute.nodeName] = attribute.nodeValue;
|
||||||
|
|
||||||
|
for (let node of xmlNode.childNodes) parseNode(node, jsonNode);
|
||||||
|
};
|
||||||
|
|
||||||
|
let result = {};
|
||||||
|
for (let node of dom.childNodes) {
|
||||||
|
parseNode(node, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
|
const getTrackData = async () => {
|
||||||
|
const resp = await fetch(sessionUrl);
|
||||||
|
if (!resp.ok) return;
|
||||||
|
|
||||||
|
const xml = await resp.text();
|
||||||
|
const data = parseXml(xml);
|
||||||
|
|
||||||
|
// Tracks need to be normalized into an array for the sake of my own sanity
|
||||||
|
const tracks = Array.isArray(data.MediaContainer.Track)
|
||||||
|
? data.MediaContainer.Track
|
||||||
|
: [data.MediaContainer.Track];
|
||||||
|
|
||||||
|
if (tracks.length === 0) return null;
|
||||||
|
if (tracks.length === 1) return tracks[0];
|
||||||
|
|
||||||
|
const [bestMatch] = data.MediaContainer.Track.filter((track) => {
|
||||||
|
return (
|
||||||
|
track.User.title === "oitsjustjose" &&
|
||||||
|
track.Player.product === "Chromatix"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
return bestMatch;
|
||||||
|
};
|
||||||
|
|
||||||
|
const getData = async () => {
|
||||||
|
const track = await getTrackData();
|
||||||
|
if (!track) return;
|
||||||
|
|
||||||
|
const songData = {
|
||||||
|
song: track.title,
|
||||||
|
artist: track.grandparentTitle,
|
||||||
|
album: track.parentTitle,
|
||||||
|
art: `http://172.16.1.3:32400${track.thumb}?X-Plex-Token=${PLEX_TOKEN}`,
|
||||||
|
state: track.Player.state,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Same as last time, nothing to do here
|
||||||
|
if (JSON.stringify(songData) === lastSongData) return;
|
||||||
|
|
||||||
|
const art = document.getElementById("art");
|
||||||
|
art.setAttribute("src", songData.art);
|
||||||
|
art.style.filter = songData.state === "playing" ? "none" : "saturate(0)";
|
||||||
|
|
||||||
|
document.getElementById("name").innerHTML = marqueeify(
|
||||||
|
songData.song,
|
||||||
|
"b",
|
||||||
|
45
|
||||||
|
);
|
||||||
|
document.getElementById("artist-album").innerHTML = marqueeify(
|
||||||
|
`${songData.album} by ${songData.artist}`,
|
||||||
|
"p",
|
||||||
|
45
|
||||||
|
);
|
||||||
|
|
||||||
|
lastSongData = JSON.stringify(songData);
|
||||||
|
};
|
||||||
|
|
||||||
|
document.addEventListener("DOMContentLoaded", async () => {
|
||||||
|
intvl = setInterval(async () => await getData(), 250);
|
||||||
|
});
|
||||||
|
|
||||||
|
document.addEventListener("beforeunload", () => {
|
||||||
|
clearInterval(intvl);
|
||||||
|
});
|
||||||
1
OBS/ResolutionUtils/Normal.xml
Normal file
1
OBS/ResolutionUtils/Normal.xml
Normal file
File diff suppressed because one or more lines are too long
16
OBS/ResolutionUtils/Py/OBS.py
Normal file
16
OBS/ResolutionUtils/Py/OBS.py
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
from subprocess import Popen
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
cwd = Path(__file__).parent.parent.resolve()
|
||||||
|
print(f"cwd={cwd}")
|
||||||
|
|
||||||
|
def on_event(event):
|
||||||
|
if event == obspython.OBS_FRONTEND_EVENT_SCRIPTING_SHUTDOWN:
|
||||||
|
proc = Popen(["MonitorSwitcher.exe", "-load:Normal.xml"], cwd=cwd, shell=True)
|
||||||
|
_ = proc.communicate()
|
||||||
|
|
||||||
|
|
||||||
|
def script_load(settings):
|
||||||
|
obspython.obs_frontend_add_event_callback(on_event)
|
||||||
|
proc = Popen(["MonitorSwitcher.exe", "-load:Recording.xml"], cwd=cwd, shell=True)
|
||||||
|
_ = proc.communicate()
|
||||||
BIN
OBS/ResolutionUtils/Py/__pycache__/OBS.cpython-310.pyc
Normal file
BIN
OBS/ResolutionUtils/Py/__pycache__/OBS.cpython-310.pyc
Normal file
Binary file not shown.
1
OBS/ResolutionUtils/Recording.xml
Normal file
1
OBS/ResolutionUtils/Recording.xml
Normal file
File diff suppressed because one or more lines are too long
19
Shell Scripts/python/convert_heic.py
Normal file
19
Shell Scripts/python/convert_heic.py
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
from PIL import Image
|
||||||
|
from pillow_heif import register_heif_opener
|
||||||
|
from pathlib import Path
|
||||||
|
from sys import argv
|
||||||
|
|
||||||
|
def main() -> None:
|
||||||
|
if len(argv) < 2:
|
||||||
|
return
|
||||||
|
|
||||||
|
path = Path(argv[1]).resolve()
|
||||||
|
if path.suffix.lower() != ".heic":
|
||||||
|
return
|
||||||
|
|
||||||
|
register_heif_opener()
|
||||||
|
im = Image.open(path)
|
||||||
|
im.save(path.with_suffix(".jpeg"), quality=100)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
2
Shell Scripts/python/requirements.txt
Normal file
2
Shell Scripts/python/requirements.txt
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
pillow==11.3.0
|
||||||
|
pillow_heif==1.1.1
|
||||||
0
linux/setup/setup_jarscan.sh → Shell Scripts/setup/setup_jarscan.sh
Executable file → Normal file
0
linux/setup/setup_jarscan.sh → Shell Scripts/setup/setup_jarscan.sh
Executable file → Normal file
0
linux/setup/setup_makerand.sh → Shell Scripts/setup/setup_makerand.sh
Executable file → Normal file
0
linux/setup/setup_makerand.sh → Shell Scripts/setup/setup_makerand.sh
Executable file → Normal file
0
linux/setup/setup_uuid.sh → Shell Scripts/setup/setup_uuid.sh
Executable file → Normal file
0
linux/setup/setup_uuid.sh → Shell Scripts/setup/setup_uuid.sh
Executable file → Normal file
0
linux/setup/setup_wifiqr.sh → Shell Scripts/setup/setup_wifiqr.sh
Executable file → Normal file
0
linux/setup/setup_wifiqr.sh → Shell Scripts/setup/setup_wifiqr.sh
Executable file → Normal file
|
|
@ -1,156 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# --------------------------------------------------------- #
|
|
||||||
# RC-file discovery #
|
|
||||||
# --------------------------------------------------------- #
|
|
||||||
|
|
||||||
# Try to use zshrc, but if no zsh use bash
|
|
||||||
RC_FILE=$(realpath ~/.zshrc)
|
|
||||||
IS_ZSH=true
|
|
||||||
|
|
||||||
if [ ! -f $RC_FILE ] ;
|
|
||||||
then
|
|
||||||
RC_FILE=$(realpath ~/.bashrc)
|
|
||||||
IS_ZSH=false
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Using ${RC_FILE} as rcfile"
|
|
||||||
|
|
||||||
# --------------------------------------------------------- #
|
|
||||||
# bat -- a syntax-aware, themable cat replacement #
|
|
||||||
# --------------------------------------------------------- #
|
|
||||||
|
|
||||||
|
|
||||||
BAT_VERSION="0.18.1"
|
|
||||||
BAT_THEME="Nord"
|
|
||||||
|
|
||||||
echo "Installing Bat Version ${BAT_VERSION}"
|
|
||||||
wget -q "https://github.com/sharkdp/bat/releases/download/v${BAT_VERSION}/bat-musl_${BAT_VERSION}_amd64.deb" 2>&1>/dev/null
|
|
||||||
sudo dpkg -i "bat-musl_${BAT_VERSION}_amd64.deb" 2>&1>/dev/null
|
|
||||||
rm "bat-musl_${BAT_VERSION}_amd64.deb"
|
|
||||||
|
|
||||||
# Add the nord theme variable
|
|
||||||
if /bin/cat "$RC_FILE" | grep -i "export BAT_THEME=" > /dev/null;
|
|
||||||
then
|
|
||||||
echo "Theme is already installed -- NOT overriden"
|
|
||||||
else
|
|
||||||
echo "export BAT_THEME=${BAT_THEME}" >> ~/.zshrc
|
|
||||||
echo "Set bat theme to ${BAT_THEME}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
# --------------------------------------------------------- #
|
|
||||||
# delta -- a replacement for `git diff` #
|
|
||||||
# --------------------------------------------------------- #
|
|
||||||
|
|
||||||
DELTA_VERSION="0.8.0"
|
|
||||||
|
|
||||||
echo "Installing Delta Version ${DELTA_VERSION}"
|
|
||||||
wget -q "https://github.com/dandavison/delta/releases/download/${DELTA_VERSION}/git-delta-musl_${DELTA_VERSION}_amd64.deb"
|
|
||||||
sudo dpkg -i "git-delta-musl_${DELTA_VERSION}_amd64.deb" 2>&1>/dev/null
|
|
||||||
rm "git-delta-musl_${DELTA_VERSION}_amd64.deb"
|
|
||||||
|
|
||||||
# Alias diff to delta
|
|
||||||
if /bin/cat "$RC_FILE" | grep -e "alias diff=delta" > /dev/null;
|
|
||||||
then
|
|
||||||
echo "Diff is already aliased to delta. Skipping.."
|
|
||||||
else
|
|
||||||
echo "Aliasing diff to delta"
|
|
||||||
echo "alias diff=delta" >> $RC_FILE
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
# --------------------------------------------------------- #
|
|
||||||
# dust - a more visual, yet slower, du #
|
|
||||||
# --------------------------------------------------------- #
|
|
||||||
|
|
||||||
|
|
||||||
DUST_VERSION="0.5.4"
|
|
||||||
|
|
||||||
echo "Installing Dust Version ${DUST_VERSION}"
|
|
||||||
|
|
||||||
wget -q "https://github.com/bootandy/dust/releases/download/v${DUST_VERSION}/dust-v${DUST_VERSION}-x86_64-unknown-linux-musl.tar.gz"
|
|
||||||
tar -xzf "dust-v${DUST_VERSION}-x86_64-unknown-linux-musl.tar.gz"
|
|
||||||
rm "dust-v${DUST_VERSION}-x86_64-unknown-linux-musl.tar.gz"
|
|
||||||
sudo mv dust-v0.5.4-x86_64-unknown-linux-musl/dust /usr/local/bin
|
|
||||||
rm -r "dust-v${DUST_VERSION}-x86_64-unknown-linux-musl"
|
|
||||||
|
|
||||||
# --------------------------------------------------------- #
|
|
||||||
# duf - a more visual df alternative #
|
|
||||||
# --------------------------------------------------------- #
|
|
||||||
|
|
||||||
DUF_VERSION="0.6.2"
|
|
||||||
|
|
||||||
echo "Installing Duf Version ${DUF_VERSION}"
|
|
||||||
|
|
||||||
wget -q "https://github.com/muesli/duf/releases/download/v${DUF_VERSION}/duf_${DUF_VERSION}_linux_amd64.deb"
|
|
||||||
sudo dpkg -i "duf_${DUF_VERSION}_linux_amd64.deb"
|
|
||||||
rm "duf_${DUF_VERSION}_linux_amd64.deb"
|
|
||||||
|
|
||||||
# Alias df to duf
|
|
||||||
if /bin/cat "$RC_FILE" | grep -e "alias df=duf" > /dev/null;
|
|
||||||
then
|
|
||||||
echo "Df is already aliased to duf. Skipping.."
|
|
||||||
else
|
|
||||||
echo "Aliasing df to duf"
|
|
||||||
echo "alias df=duf" >> $RC_FILE
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
# --------------------------------------------------------- #
|
|
||||||
# McFly - a faster alt to ctrl+r rev search #
|
|
||||||
# --------------------------------------------------------- #
|
|
||||||
|
|
||||||
MCF_VERSION="0.5.6"
|
|
||||||
|
|
||||||
echo "Installing mcfly Version ${MCF_VERSION}"
|
|
||||||
|
|
||||||
wget -q "https://github.com/cantino/mcfly/releases/download/v${MCF_VERSION}/mcfly-v${MCF_VERSION}-x86_64-unknown-linux-gnu.tar.gz"
|
|
||||||
tar -xzf "mcfly-v${MCF_VERSION}-x86_64-unknown-linux-gnu.tar.gz"
|
|
||||||
rm "mcfly-v${MCF_VERSION}-x86_64-unknown-linux-gnu.tar.gz"
|
|
||||||
sudo mv mcfly /usr/local/bin
|
|
||||||
|
|
||||||
rm mcfly.bash mcfly.fish mcfly.zsh 2>&1 > /dev/null
|
|
||||||
|
|
||||||
if /bin/cat "$RC_FILE" | grep -i 'mcfly init' > /dev/null;
|
|
||||||
then
|
|
||||||
echo "Looks like mcfly init script is already in ${RC_FILE}!"
|
|
||||||
else
|
|
||||||
if [ "$IS_ZSH" = true ];
|
|
||||||
then
|
|
||||||
echo 'eval "$(mcfly init zsh)"' >> "$RC_FILE"
|
|
||||||
else
|
|
||||||
echo 'eval "$(mcfly init bash)"' >> "$RC_FILE"
|
|
||||||
fi
|
|
||||||
echo "Added McFly init to ${RC_FILE}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
# --------------------------------------------------------- #
|
|
||||||
# GTOP - a nicer TOP GUI, requires Node... #
|
|
||||||
# --------------------------------------------------------- #
|
|
||||||
|
|
||||||
if command -v npm &> /dev/null && ! which npm | grep /mnt/c/ &> /dev/null ;
|
|
||||||
then
|
|
||||||
echo "Installing GTOP via NPM"
|
|
||||||
npm i -g gtop
|
|
||||||
else
|
|
||||||
if command -v docker &> /dev/null ;
|
|
||||||
then
|
|
||||||
echo "Installing GTOP via Docker"
|
|
||||||
if /bin/cat "$RC_FILE" | grep -i 'alias gtop=' > /dev/null;
|
|
||||||
then
|
|
||||||
echo "Looks like gtop is already aliased!"
|
|
||||||
else
|
|
||||||
echo $'alias gtop=\'docker run --rm -it --name gtop --net=host --pid=host aksakalli/gtop\'' >> "$RC_FILE"
|
|
||||||
echo $'eval "$(alias gtop=\'docker run --rm -it --name gtop --net=host --pid=host aksakalli/gtop\')"' >> "$RC_FILE"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "Neither NPM nor Docker could not be found, skipping GTOP installation"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Done installing tools! Restarting shell"
|
|
||||||
exec "$SHELL"
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
@echo off
|
|
||||||
|
|
||||||
:loop
|
|
||||||
|
|
||||||
@echo Processing file: %1
|
|
||||||
python.exe .\main.py %1
|
|
||||||
@echo "Done!"
|
|
||||||
|
|
||||||
shift
|
|
||||||
if not "%~1"=="" goto loop
|
|
||||||
|
|
||||||
@REM pause
|
|
||||||
|
|
@ -1,187 +0,0 @@
|
||||||
"""@author Jose Stovall | github.com/oitsjustjose"""
|
|
||||||
|
|
||||||
import json
|
|
||||||
import os
|
|
||||||
import shutil
|
|
||||||
import sys
|
|
||||||
import zipfile
|
|
||||||
from pathlib import Path
|
|
||||||
from typing import List
|
|
||||||
|
|
||||||
import toml
|
|
||||||
|
|
||||||
THIS_DIR = Path(__file__).absolute().parent
|
|
||||||
CLEANUP_CONF_PATH = THIS_DIR.joinpath("..").joinpath("configuration.json").resolve()
|
|
||||||
MMC_EXPORT_CONFIG_PATH = THIS_DIR.joinpath("config.toml").resolve()
|
|
||||||
TROUBLEMAKERS_PATH = THIS_DIR.joinpath("troublemakers").resolve()
|
|
||||||
WORKING_FOLDER: Path = Path(".").resolve() # Temp, gets resolved from sys.argv in main()
|
|
||||||
|
|
||||||
# Temporary variables that aren't actually persistent really
|
|
||||||
__TMP_PACK_UNZIPPED_PATH = THIS_DIR.joinpath("activepack").resolve()
|
|
||||||
__TMP_PACK_ZIP_PATH = THIS_DIR.joinpath("activepack.zip").resolve()
|
|
||||||
__TMP_RESPACK_DIR = __TMP_PACK_UNZIPPED_PATH.joinpath("minecraft").joinpath("resourcepacks").resolve()
|
|
||||||
|
|
||||||
|
|
||||||
def print(obj):
|
|
||||||
"""override"""
|
|
||||||
# log_nm_base = sys.argv[1].split("\\")[-1]
|
|
||||||
|
|
||||||
log_nm_base = Path()
|
|
||||||
|
|
||||||
with open(f"./{log_nm_base}.log", "a+", encoding="utf-8") as log_handle:
|
|
||||||
log_handle.write(f"{str(obj)}\n")
|
|
||||||
|
|
||||||
|
|
||||||
def _clean_pack():
|
|
||||||
"""
|
|
||||||
Removes client-only configs/files
|
|
||||||
"""
|
|
||||||
with open(CLEANUP_CONF_PATH, "r", encoding="utf-8") as handle:
|
|
||||||
config = json.loads(handle.read())
|
|
||||||
|
|
||||||
for to_del in config["remove"]:
|
|
||||||
fpath = __TMP_PACK_UNZIPPED_PATH.joinpath("minecraft").joinpath(to_del)
|
|
||||||
|
|
||||||
if not fpath.exists():
|
|
||||||
continue
|
|
||||||
|
|
||||||
if fpath.is_dir():
|
|
||||||
shutil.rmtree(fpath)
|
|
||||||
print(f"Removed directory {fpath}")
|
|
||||||
continue
|
|
||||||
|
|
||||||
fpath.unlink()
|
|
||||||
print(f"Removed file {fpath}")
|
|
||||||
|
|
||||||
|
|
||||||
def _get_modpack_outnames(join: bool = False) -> List[str]:
|
|
||||||
"""
|
|
||||||
Gets the MR_{packname}.mrpack and CF_{packname}.zip names based off of the config.toml contents
|
|
||||||
Args: join (bool) [False]: Whether to join them to the current dir or not
|
|
||||||
Returns: Tuple[str, str]: The MR_ and CF_ paths (in that order)
|
|
||||||
"""
|
|
||||||
with open(MMC_EXPORT_CONFIG_PATH, "r", encoding="utf-8") as handle:
|
|
||||||
name = toml.loads(handle.read())["name"]
|
|
||||||
if join:
|
|
||||||
return [
|
|
||||||
str(THIS_DIR.joinpath(f"MR_{name}.mrpack")),
|
|
||||||
str(THIS_DIR.joinpath(f"CF_{name}.zip")),
|
|
||||||
]
|
|
||||||
return [f"MR_{name}.mrpack", f"CF_{name}.zip"]
|
|
||||||
|
|
||||||
|
|
||||||
def __cleanup() -> None:
|
|
||||||
"""Cleans up output files"""
|
|
||||||
os.unlink(MMC_EXPORT_CONFIG_PATH)
|
|
||||||
os.unlink(__TMP_PACK_ZIP_PATH)
|
|
||||||
shutil.rmtree(__TMP_PACK_UNZIPPED_PATH)
|
|
||||||
shutil.rmtree(TROUBLEMAKERS_PATH)
|
|
||||||
for file in os.listdir(THIS_DIR):
|
|
||||||
if file.startswith("CF_") or file.startswith("MR_"):
|
|
||||||
THIS_DIR.joinpath(file).unlink()
|
|
||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
|
||||||
"""
|
|
||||||
The main run function.
|
|
||||||
Args: None
|
|
||||||
Returns: None
|
|
||||||
Process Flow:
|
|
||||||
1. Move file to this dir
|
|
||||||
2. Unzip it, then:
|
|
||||||
1. Clean up the client mods
|
|
||||||
2. Grab the config.toml
|
|
||||||
3. Find any exceptive files that are going to be a PITA and remove them (a. la. Witchery in the RP's dir)
|
|
||||||
3. Re-zip
|
|
||||||
4. mmc-export
|
|
||||||
5. Move files from step 3 into output files
|
|
||||||
6. Move output folders back to originating dir
|
|
||||||
"""
|
|
||||||
if len(sys.argv) != 2:
|
|
||||||
print("Missing 2nd parameter File")
|
|
||||||
return
|
|
||||||
|
|
||||||
INPUT_FILE_PATH = Path(sys.argv[1]).resolve().parent
|
|
||||||
if not TROUBLEMAKERS_PATH.exists():
|
|
||||||
TROUBLEMAKERS_PATH.mkdir()
|
|
||||||
|
|
||||||
# STEP 1: copy the modpack locally
|
|
||||||
shutil.copy(INPUT_FILE_PATH.parent, __TMP_PACK_ZIP_PATH)
|
|
||||||
print("STEP 1: SUCCESS")
|
|
||||||
|
|
||||||
# STEP 2: unzip the pack
|
|
||||||
shutil.unpack_archive(__TMP_PACK_ZIP_PATH, __TMP_PACK_UNZIPPED_PATH, "zip")
|
|
||||||
print("STEP 2: SUCCESS")
|
|
||||||
|
|
||||||
# STEP 2.1: clean up client mods
|
|
||||||
_clean_pack()
|
|
||||||
print("STEP 2.1: SUCCESS")
|
|
||||||
|
|
||||||
# STEP 2.2: grab the config.toml file
|
|
||||||
config_toml_path = __TMP_PACK_UNZIPPED_PATH.joinpath("config.toml")
|
|
||||||
if config_toml_path.exists():
|
|
||||||
shutil.move(config_toml_path, MMC_EXPORT_CONFIG_PATH)
|
|
||||||
print("STEP 2.2: SUCCESS")
|
|
||||||
|
|
||||||
# STEP 2.3: grab PITA resourcepacks files like Witchery's 1.7.10 jar
|
|
||||||
if __TMP_RESPACK_DIR.exists() and __TMP_RESPACK_DIR.is_dir():
|
|
||||||
for respack_path in __TMP_RESPACK_DIR.iterdir():
|
|
||||||
if not respack_path.is_dir() and not respack_path.name.endswith(".zip"):
|
|
||||||
shutil.move(respack_path, TROUBLEMAKERS_PATH.joinpath(respack_path.name))
|
|
||||||
print(f"STEP 2.3: Potential Troublemaker Found & Relocated: {respack_path.name}")
|
|
||||||
else:
|
|
||||||
print("No resourcepacks dir - skipping")
|
|
||||||
|
|
||||||
# STEP 3: re-zip & cleanup
|
|
||||||
shutil.make_archive(str(__TMP_PACK_ZIP_PATH.with_suffix("")), "zip", __TMP_PACK_UNZIPPED_PATH)
|
|
||||||
shutil.rmtree(__TMP_PACK_UNZIPPED_PATH)
|
|
||||||
print("STEP 3: SUCCESS")
|
|
||||||
|
|
||||||
# ---- ANY FURTHER REFERENCES TO PACK_UNZIPPED_PATH ARE BAD!! ---- #
|
|
||||||
|
|
||||||
# STEP 4: MMC-EXPORT
|
|
||||||
print("MMC-Exporter is running, please wait")
|
|
||||||
status = os.system(
|
|
||||||
" ".join(
|
|
||||||
f"""
|
|
||||||
mmc-export.exe
|
|
||||||
-i "{__TMP_PACK_ZIP_PATH}"
|
|
||||||
-f Modrinth CurseForge
|
|
||||||
-c "{MMC_EXPORT_CONFIG_PATH}"
|
|
||||||
-o "{THIS_DIR}"
|
|
||||||
""".split()
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
if status != 0:
|
|
||||||
print("Failed to convert MMC pack to Curse and/or Modrinth. See above log.")
|
|
||||||
return
|
|
||||||
|
|
||||||
print("STEP 4: SUCCESS")
|
|
||||||
|
|
||||||
# STEP 5: Move Troublemakers back to inside each zip
|
|
||||||
output_files = _get_modpack_outnames(join=True)
|
|
||||||
for fname in output_files:
|
|
||||||
with zipfile.ZipFile(THIS_DIR.joinpath(fname), "a") as zipf:
|
|
||||||
for file in TROUBLEMAKERS_PATH.iterdir():
|
|
||||||
troublemaker_path = TROUBLEMAKERS_PATH.joinpath(file)
|
|
||||||
zipf.write(troublemaker_path, f"overrides/resourcepacks/{file}")
|
|
||||||
print("STEP 5: SUCCESS")
|
|
||||||
|
|
||||||
# STEP 6: Move finished pack files back to OG dir
|
|
||||||
output_files = _get_modpack_outnames(join=False)
|
|
||||||
for fname in output_files + ["bundled_links.md"]:
|
|
||||||
shutil.move(THIS_DIR.joinpath(fname), INPUT_FILE_PATH.parent.joinpath(fname))
|
|
||||||
|
|
||||||
print("STEP 6: SUCCESS")
|
|
||||||
|
|
||||||
__cleanup()
|
|
||||||
print("DONE")
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
try:
|
|
||||||
main()
|
|
||||||
except Exception as e:
|
|
||||||
__cleanup()
|
|
||||||
print(e)
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
*.log
|
|
||||||
activepack.zip
|
|
||||||
activepack.mrpack
|
|
||||||
|
|
@ -1,193 +0,0 @@
|
||||||
"""@author Jose Stovall | github.com/oitsjustjose"""
|
|
||||||
|
|
||||||
import json
|
|
||||||
import os
|
|
||||||
import shutil
|
|
||||||
import sys
|
|
||||||
import zipfile
|
|
||||||
from dataclasses import dataclass
|
|
||||||
from typing import List
|
|
||||||
|
|
||||||
THIS_DIR = "\\".join(os.path.realpath(__file__).split("\\")[:-1])
|
|
||||||
IS_MODRINTH = sys.argv[1].endswith(".mrpack")
|
|
||||||
|
|
||||||
CONFIG_PATH = os.path.join(THIS_DIR, "..", "configuration.json")
|
|
||||||
PACK_UNZIP_PATH = os.path.join(THIS_DIR, "activepack")
|
|
||||||
PACK_ZIP_PATH = f"{PACK_UNZIP_PATH}.{'mrpack' if IS_MODRINTH else 'zip'}"
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
|
||||||
class ModpackInfo:
|
|
||||||
name: str
|
|
||||||
version: str
|
|
||||||
|
|
||||||
|
|
||||||
def print(obj) -> None:
|
|
||||||
"""Override the initial print so it goes to a logfile instead!"""
|
|
||||||
log_nm_base = sys.argv[1].split("\\")[-1]
|
|
||||||
with open(f"./{log_nm_base}.log", "a+", encoding="utf-8") as log_handle:
|
|
||||||
log_handle.write(f"{str(obj)}\n")
|
|
||||||
|
|
||||||
|
|
||||||
def __cleanup() -> None:
|
|
||||||
"""File and dir cleanup for when the program exits"""
|
|
||||||
# remove the copied zip file
|
|
||||||
if os.path.exists(PACK_ZIP_PATH):
|
|
||||||
os.unlink(PACK_ZIP_PATH)
|
|
||||||
# remove any unzipped files
|
|
||||||
if os.path.exists(PACK_UNZIP_PATH):
|
|
||||||
shutil.rmtree(PACK_UNZIP_PATH)
|
|
||||||
|
|
||||||
|
|
||||||
def __get_pack_info() -> ModpackInfo:
|
|
||||||
"""
|
|
||||||
Gets the modpack info based on the currently unzipped pack
|
|
||||||
Returns None in the event of any failures
|
|
||||||
"""
|
|
||||||
if not os.path.exists(PACK_UNZIP_PATH):
|
|
||||||
print(
|
|
||||||
f"[__get_pack_info]: Failed to get Modpack Info: {PACK_UNZIP_PATH} does not exist!"
|
|
||||||
)
|
|
||||||
return None
|
|
||||||
|
|
||||||
manifest_path: str = None
|
|
||||||
|
|
||||||
if IS_MODRINTH:
|
|
||||||
manifest_path = os.path.join(PACK_UNZIP_PATH, "modrinth.index.json")
|
|
||||||
else:
|
|
||||||
manifest_path = os.path.join(PACK_UNZIP_PATH, "manifest.json")
|
|
||||||
|
|
||||||
if not manifest_path:
|
|
||||||
print(
|
|
||||||
"[__get_pack_info]: Failed to get Modpack Info: could not find a valid manifest path!"
|
|
||||||
)
|
|
||||||
return None
|
|
||||||
|
|
||||||
with open(manifest_path, "r") as handle:
|
|
||||||
manifest = json.loads(handle.read())
|
|
||||||
|
|
||||||
return ModpackInfo(
|
|
||||||
manifest["name"], manifest["versionId" if IS_MODRINTH else "version"]
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def __patch_neo_curse() -> None:
|
|
||||||
"""
|
|
||||||
Fixes an issue with CurseForge exports from Prism that makes them incompatible
|
|
||||||
with the CurseForge launcher because CurseForge is fucking stupid
|
|
||||||
"""
|
|
||||||
manifest_path = os.path.join(PACK_UNZIP_PATH, "manifest.json")
|
|
||||||
|
|
||||||
if not os.path.exists(manifest_path):
|
|
||||||
print(f"[__patch_neo_curse]: Failed to find manifest at {manifest_path}")
|
|
||||||
return
|
|
||||||
|
|
||||||
with open(manifest_path, "r") as handle:
|
|
||||||
manifest = json.loads(handle.read())
|
|
||||||
|
|
||||||
if "minecraft" not in manifest:
|
|
||||||
print("[__patch_neo_curse]: Missing key \{minecraft\}")
|
|
||||||
return
|
|
||||||
|
|
||||||
if "modLoaders" not in manifest["minecraft"]:
|
|
||||||
print("[__patch_neo_curse]: Missing key \{minecraft.modLoaders\}")
|
|
||||||
return
|
|
||||||
|
|
||||||
mc_version = manifest["minecraft"]["version"]
|
|
||||||
if mc_version not in ["1.20.1"]:
|
|
||||||
print(
|
|
||||||
f"[__patch_neo_curse]: Minecraft {mc_version} does not need NeoForge cleanup (or if it does, clean up this script!)"
|
|
||||||
)
|
|
||||||
return
|
|
||||||
|
|
||||||
for modloader in manifest["minecraft"]["modLoaders"]:
|
|
||||||
if "neo" not in modloader["id"]:
|
|
||||||
continue
|
|
||||||
|
|
||||||
# Other versions might not need this patch, hard to say - 1.20.1 definitely does.
|
|
||||||
if mc_version == "1.20.1":
|
|
||||||
neo_version = modloader["id"].replace("neoforge-", "")
|
|
||||||
modloader["id"] = f"neoforge-{mc_version}-{neo_version}"
|
|
||||||
|
|
||||||
with open(manifest_path, "w") as handle:
|
|
||||||
handle.write(json.dumps(manifest))
|
|
||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
|
||||||
"""
|
|
||||||
Processing flow (souper crude):
|
|
||||||
|
|
||||||
1. Load the cleanup config
|
|
||||||
2. Open the original zipped file
|
|
||||||
3. Iterate through each cleanup config entry (don't forget to path prepend "overrides/"), deleting
|
|
||||||
4. Re-zip if necessary?
|
|
||||||
5. Profit?
|
|
||||||
"""
|
|
||||||
|
|
||||||
if len(sys.argv) != 2:
|
|
||||||
print("Missing 2nd parameter File")
|
|
||||||
return
|
|
||||||
|
|
||||||
# Copy the original file to ./activepack.[mrpack|zip]
|
|
||||||
shutil.copy(sys.argv[1], PACK_ZIP_PATH)
|
|
||||||
print("Copied pack to local dir")
|
|
||||||
|
|
||||||
# Unzip the modpack -- .mrpacks are just glorified zip files too :)
|
|
||||||
shutil.unpack_archive(PACK_ZIP_PATH, PACK_UNZIP_PATH, "zip")
|
|
||||||
print("Unarchived pack successfully!")
|
|
||||||
|
|
||||||
# Read in the config if it exists - if it doesn't, early exit
|
|
||||||
if not os.path.exists(CONFIG_PATH):
|
|
||||||
print(f"Failed to find configuration at {CONFIG_PATH}")
|
|
||||||
__cleanup()
|
|
||||||
return
|
|
||||||
|
|
||||||
with open(CONFIG_PATH, "r") as handle:
|
|
||||||
config = json.loads(handle.read())["remove"]
|
|
||||||
|
|
||||||
# Prepend the "overrides/" path, remove all files necessary
|
|
||||||
for target in [f"overrides/{x}" for x in config]:
|
|
||||||
rm_path = os.path.join(PACK_UNZIP_PATH, target)
|
|
||||||
if not os.path.exists(rm_path):
|
|
||||||
continue
|
|
||||||
|
|
||||||
if os.path.isdir(rm_path):
|
|
||||||
shutil.rmtree(rm_path)
|
|
||||||
print(f"Removed dir {rm_path}")
|
|
||||||
else:
|
|
||||||
os.unlink(rm_path)
|
|
||||||
print(f"Removed file {rm_path}")
|
|
||||||
|
|
||||||
# Fix CurseForge packs being pissed about NeoForge :V
|
|
||||||
if not IS_MODRINTH:
|
|
||||||
__patch_neo_curse()
|
|
||||||
|
|
||||||
# Zip up the pack & cleanup the old working directory
|
|
||||||
info = __get_pack_info()
|
|
||||||
shutil.make_archive(
|
|
||||||
os.path.join(THIS_DIR, f"{info.name} {info.version}"), "zip", PACK_UNZIP_PATH
|
|
||||||
)
|
|
||||||
shutil.rmtree(PACK_UNZIP_PATH)
|
|
||||||
if IS_MODRINTH:
|
|
||||||
os.rename(
|
|
||||||
os.path.join(THIS_DIR, f"{info.name} {info.version}.zip"),
|
|
||||||
os.path.join(THIS_DIR, f"{info.name} {info.version}.mrpack"),
|
|
||||||
)
|
|
||||||
|
|
||||||
# Rename .zip to .mrpack if it was a modrinth pack
|
|
||||||
file_name = f"{info.name} {info.version}.{'mrpack' if IS_MODRINTH else 'zip'}"
|
|
||||||
|
|
||||||
# Move the file back to where it should've started from
|
|
||||||
og_dirname = "\\".join(sys.argv[1].split("\\")[:-1])
|
|
||||||
shutil.move(os.path.join(THIS_DIR, file_name), os.path.join(og_dirname, file_name))
|
|
||||||
print(
|
|
||||||
f"Successfully processed & moved/replaced {'Modrinth' if IS_MODRINTH else 'CurseForge'} modpack"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
try:
|
|
||||||
main()
|
|
||||||
except Exception as e:
|
|
||||||
__cleanup()
|
|
||||||
print(e)
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
@REM Sets up the Python dependency one time
|
|
||||||
pip install git+https://github.com/tanaydin/gql-query-builder.git@patch-2
|
|
||||||
pip install -U mmc-export
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
@echo Processing file: %1
|
@echo Processing file: %1
|
||||||
python.exe .\main.py %1
|
python.exe .\main.py %1
|
||||||
@echo "Done!"
|
pause
|
||||||
|
|
||||||
shift
|
shift
|
||||||
if not "%~1"=="" goto loop
|
if not "%~1"=="" goto loop
|
||||||
197
minecraft/publishing/main.py
Normal file
197
minecraft/publishing/main.py
Normal file
|
|
@ -0,0 +1,197 @@
|
||||||
|
import json
|
||||||
|
import shutil
|
||||||
|
import sys
|
||||||
|
from dataclasses import dataclass
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class ModpackInfo:
|
||||||
|
name: str
|
||||||
|
version: str
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class Paths:
|
||||||
|
is_modrinth: bool
|
||||||
|
this_dir: Path
|
||||||
|
config: Path
|
||||||
|
activepath: Path
|
||||||
|
activepath_zip: Path
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def create(file: Path):
|
||||||
|
this_dir = Path(__file__).parent.resolve()
|
||||||
|
ap = this_dir.joinpath("activepack").resolve()
|
||||||
|
|
||||||
|
return Paths(
|
||||||
|
is_modrinth=file.suffix == ".mrpack",
|
||||||
|
this_dir=this_dir,
|
||||||
|
config=this_dir.joinpath("configuration.json").resolve(),
|
||||||
|
activepath=ap,
|
||||||
|
activepath_zip=ap.with_suffix(file.suffix).resolve(),
|
||||||
|
)
|
||||||
|
|
||||||
|
def clean(self):
|
||||||
|
if self.activepath.exists():
|
||||||
|
shutil.rmtree(self.activepath)
|
||||||
|
if self.activepath_zip.exists():
|
||||||
|
self.activepath_zip.unlink()
|
||||||
|
|
||||||
|
|
||||||
|
class Processor: # TODO: we need Prism native pack support too
|
||||||
|
def __init__(self, pack_path: Path):
|
||||||
|
self.pack_path = pack_path
|
||||||
|
self.paths = Paths.create(pack_path)
|
||||||
|
self.step = "Copy Pack to Temp Dir & Unzip It"
|
||||||
|
|
||||||
|
# Read in the config
|
||||||
|
with open(self.paths.config, "r", encoding="utf-8") as fh:
|
||||||
|
self.config = json.loads(fh.read())
|
||||||
|
|
||||||
|
def override(self, path: Path) -> Path:
|
||||||
|
"""Unlinks / rmtrees a path if it exists, then returns it"""
|
||||||
|
if path.exists():
|
||||||
|
if path.is_dir():
|
||||||
|
shutil.rmtree(path)
|
||||||
|
else:
|
||||||
|
path.unlink()
|
||||||
|
return path
|
||||||
|
|
||||||
|
def run(self) -> None:
|
||||||
|
"""Common staging steps between both packs"""
|
||||||
|
# Copy the original file to ./activepack.[mrpack|zip]
|
||||||
|
shutil.copy(self.pack_path, self.paths.activepath_zip)
|
||||||
|
shutil.unpack_archive(self.paths.activepath_zip, self.paths.activepath, "zip")
|
||||||
|
print(f"✅ {self.step}")
|
||||||
|
|
||||||
|
self.step = "Clean up files we don't want to ship"
|
||||||
|
for p in [f"overrides/{x}" for x in self.config["remove"]]:
|
||||||
|
rm_path = self.paths.activepath.joinpath(p)
|
||||||
|
if not rm_path.exists():
|
||||||
|
continue
|
||||||
|
if rm_path.is_dir():
|
||||||
|
shutil.rmtree(rm_path)
|
||||||
|
print(f" 🗑️ 📁 {rm_path.name}")
|
||||||
|
else:
|
||||||
|
rm_path.unlink()
|
||||||
|
print(f" 🗑️ {rm_path.name}")
|
||||||
|
print(f"✅ {self.step}")
|
||||||
|
|
||||||
|
def post_run(self) -> None:
|
||||||
|
"""Common post-run staging steps between both types"""
|
||||||
|
info = self.get_pack_info()
|
||||||
|
|
||||||
|
# Always use .zip, shutil.make_archive has no clue what an mrpack is
|
||||||
|
self.step = "Re-archive the modified, cleaned up pack"
|
||||||
|
out_file = self.override(self.paths.this_dir.joinpath(f"{info.name} {info.version}.zip").resolve())
|
||||||
|
shutil.make_archive(out_file.with_suffix("").name, "zip", self.paths.activepath)
|
||||||
|
print(f"✅ {self.step}")
|
||||||
|
|
||||||
|
self.step = "Clean up unzipped pack and rename to mrpack if necessary"
|
||||||
|
shutil.rmtree(self.paths.activepath)
|
||||||
|
out_file = out_file.rename(self.override(out_file.with_suffix(self.pack_path.suffix)))
|
||||||
|
print(f"✅ {self.step}")
|
||||||
|
|
||||||
|
self.step = "Move re-packed modpack to the original pack's directory"
|
||||||
|
final_output = self.pack_path.parent.joinpath(out_file.name).resolve()
|
||||||
|
if final_output.exists():
|
||||||
|
final_output.unlink()
|
||||||
|
|
||||||
|
shutil.move(out_file, final_output)
|
||||||
|
self.paths.clean()
|
||||||
|
print("🎉 Done! Successfully cleaned modpack!")
|
||||||
|
|
||||||
|
def get_pack_info(self) -> ModpackInfo:
|
||||||
|
"""Common method for getting pack info in general"""
|
||||||
|
manifest_path = self.paths.activepath.joinpath("manifest.json").resolve()
|
||||||
|
with open(manifest_path, "r", encoding="utf-8") as fh:
|
||||||
|
manifest = json.loads(fh.read())
|
||||||
|
return ModpackInfo(manifest["name"], manifest["version"])
|
||||||
|
|
||||||
|
|
||||||
|
class ModrinthProcessor(Processor):
|
||||||
|
def __init__(self, pack_path: Path):
|
||||||
|
super().__init__(pack_path)
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
super().run()
|
||||||
|
self.post_run()
|
||||||
|
|
||||||
|
def get_pack_info(self) -> ModpackInfo:
|
||||||
|
"""Uses modrinth.index.json instead of manifest.json, and versionId instead of version"""
|
||||||
|
manifest_path = self.paths.activepath.joinpath("modrinth.index.json").resolve()
|
||||||
|
with open(manifest_path, "r", encoding="utf-8") as fh:
|
||||||
|
manifest = json.loads(fh.read())
|
||||||
|
return ModpackInfo(manifest["name"], manifest["versionId"])
|
||||||
|
|
||||||
|
|
||||||
|
class CurseForgeProcessor(Processor):
|
||||||
|
def __init__(self, pack_path: Path):
|
||||||
|
super().__init__(pack_path)
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
super().run()
|
||||||
|
self.__patch_neo_compat()
|
||||||
|
self.post_run()
|
||||||
|
|
||||||
|
def __patch_neo_compat(self):
|
||||||
|
"""Fixes an issue with CurseForge exports from Prism that makes them
|
||||||
|
incompatible with the CurseForge launcher because CurseForge is stupid"""
|
||||||
|
self.step = "Patch CurseForge Manifest to be compatible with NeoForge"
|
||||||
|
manifest_path = self.paths.activepath.joinpath("manifest.json").resolve()
|
||||||
|
if not manifest_path.exists():
|
||||||
|
print(f"[CurseForge+NeoForge Compat]: Failed to find a manifest at {manifest_path}")
|
||||||
|
return
|
||||||
|
|
||||||
|
with open(manifest_path, "r") as handle:
|
||||||
|
manifest = json.loads(handle.read())
|
||||||
|
|
||||||
|
if "minecraft" not in manifest:
|
||||||
|
print("[CurseForge+NeoForge Compat]: Missing key { minecraft }")
|
||||||
|
return
|
||||||
|
|
||||||
|
if "modLoaders" not in manifest["minecraft"]:
|
||||||
|
print("[CurseForge+NeoForge Compat]: Missing key { minecraft.modLoaders }")
|
||||||
|
return
|
||||||
|
|
||||||
|
mc_version = manifest["minecraft"]["version"]
|
||||||
|
if mc_version not in ["1.20.1"]:
|
||||||
|
return
|
||||||
|
|
||||||
|
for modloader in manifest["minecraft"]["modLoaders"]:
|
||||||
|
if "neo" not in modloader["id"]:
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Other versions might not need this patch, hard to say - 1.20.1 definitely does.
|
||||||
|
if mc_version == "1.20.1":
|
||||||
|
neo_version = modloader["id"].replace("neoforge-", "")
|
||||||
|
modloader["id"] = f"neoforge-{mc_version}-{neo_version}"
|
||||||
|
|
||||||
|
with open(manifest_path, "w") as handle:
|
||||||
|
handle.write(json.dumps(manifest))
|
||||||
|
|
||||||
|
|
||||||
|
def main(og_pack_path_raw: str):
|
||||||
|
og_pack_path = Path(og_pack_path_raw).resolve()
|
||||||
|
if not og_pack_path.exists():
|
||||||
|
raise Exception(f"Failed to find the Pack at {og_pack_path_raw}!")
|
||||||
|
|
||||||
|
processor = ModrinthProcessor(og_pack_path) if og_pack_path.suffix == ".mrpack" else CurseForgeProcessor(og_pack_path)
|
||||||
|
try:
|
||||||
|
processor.run()
|
||||||
|
except Exception as e:
|
||||||
|
# Clean up any paths we made but still raise our exception
|
||||||
|
processor.paths.clean()
|
||||||
|
print(f"Failure during step [{processor.step}]:")
|
||||||
|
raise e
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
if len(sys.argv) != 2:
|
||||||
|
print("Missing required parameter: <FILE> (the path to the .mrpack or .zip export)")
|
||||||
|
sys.exit(1)
|
||||||
|
try:
|
||||||
|
main(sys.argv[1])
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
Binary file not shown.
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit a11e48a1721d3b8bbb2d54376193ed6b524be115
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit a11e48a1721d3b8bbb2d54376193ed6b524be115
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
cd "TODO:\Parsec Utils\"
|
|
||||||
.\MonitorSwitcher.exe -load:.\Profiles\Desktop.xml
|
|
||||||
.\SetDpi.exe 100 1
|
|
||||||
.\SetDpi.exe 100 2
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -1 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?><displaySettings><pathInfoArray><DisplayConfigPathInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><sourceInfo><adapterId><LowPart>102332</LowPart><HighPart>0</HighPart></adapterId><id>1</id><modeInfoIdx>1</modeInfoIdx><statusFlags>InUse</statusFlags></sourceInfo><targetInfo><adapterId><LowPart>102332</LowPart><HighPart>0</HighPart></adapterId><id>49413</id><modeInfoIdx>0</modeInfoIdx><outputTechnology>DisplayportExternal</outputTechnology><rotation>Identity</rotation><scaling>Aspectratiocenteredmax</scaling><refreshRate><numerator>120</numerator><denominator>1</denominator></refreshRate><scanLineOrdering>Progressive</scanLineOrdering><targetAvailable>true</targetAvailable><statusFlags>InUse</statusFlags></targetInfo><flags>1</flags></DisplayConfigPathInfo></pathInfoArray><modeInfoArray><modeInfo><id>49413</id><LUID xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><LowPart>102332</LowPart><HighPart>0</HighPart></LUID><DisplayConfigModeInfoType>Target</DisplayConfigModeInfoType><DisplayConfigTargetMode xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><targetVideoSignalInfo><pixelRate>483400000</pixelRate><hSyncFreq><numerator>483400000</numerator><denominator>2720</denominator></hSyncFreq><vSyncFreq><numerator>120</numerator><denominator>1</denominator></vSyncFreq><activeSize><cx>2560</cx><cy>1440</cy></activeSize><totalSize><cx>2720</cx><cy>1481</cy></totalSize><videoStandard>Other</videoStandard><ScanLineOrdering>Progressive</ScanLineOrdering></targetVideoSignalInfo></DisplayConfigTargetMode></modeInfo><modeInfo><id>1</id><LUID xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><LowPart>102332</LowPart><HighPart>0</HighPart></LUID><DisplayConfigModeInfoType>Source</DisplayConfigModeInfoType><DisplayConfigSourceMode xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><width>3840</width><height>1080</height><pixelFormat>Pixelformat32Bpp</pixelFormat><position><x>0</x><y>0</y></position></DisplayConfigSourceMode></modeInfo></modeInfoArray><additionalInfo><MonitorAdditionalInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><manufactureId>26884</manufactureId><productCodeId>10220</productCodeId><valid>true</valid><monitorDevicePath>XAAAAFwAAAA/AAAAXAAAAEQAAABJAAAAUwAAAFAAAABMAAAAQQAAAFkAAAAjAAAAQQAAAEMAAABJAAAAMgAAADcAAABFAAAAQwAAACMAAAA1AAAAJgAAADEAAAA1AAAAYgAAAGUAAAAzAAAAMwAAAGYAAAAyAAAAJgAAADAAAAAmAAAAVQAAAEkAAABEAAAANAAAADkAAAA0AAAAMQAAADMAAAAjAAAAewAAAGUAAAA2AAAAZgAAADAAAAA3AAAAYgAAADUAAABmAAAALQAAAGUAAABlAAAAOQAAADcAAAAtAAAANAAAAGEAAAA5AAAAMAAAAC0AAABiAAAAMAAAADcAAAA2AAAALQAAADMAAAAzAAAAZgAAADUAAAA3AAAAYgAAAGYAAAA0AAAAZQAAAGEAAABhAAAANwAAAH0AAAA=</monitorDevicePath><monitorFriendlyDevice>UgAAAE8AAABHAAAAIAAAAFAAAABHAAAAMgAAADcAAAA5AAAAUQAAAA==</monitorFriendlyDevice></MonitorAdditionalInfo><MonitorAdditionalInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><manufactureId>0</manufactureId><productCodeId>0</productCodeId><valid>false</valid><monitorDevicePath /><monitorFriendlyDevice /></MonitorAdditionalInfo></additionalInfo></displaySettings>
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?><displaySettings><pathInfoArray><DisplayConfigPathInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><sourceInfo><adapterId><LowPart>105001</LowPart><HighPart>0</HighPart></adapterId><id>1</id><modeInfoIdx>1</modeInfoIdx><statusFlags>InUse</statusFlags></sourceInfo><targetInfo><adapterId><LowPart>105001</LowPart><HighPart>0</HighPart></adapterId><id>49413</id><modeInfoIdx>0</modeInfoIdx><outputTechnology>DisplayportExternal</outputTechnology><rotation>Identity</rotation><scaling>Identity</scaling><refreshRate><numerator>165</numerator><denominator>1</denominator></refreshRate><scanLineOrdering>Progressive</scanLineOrdering><targetAvailable>true</targetAvailable><statusFlags>InUse</statusFlags></targetInfo><flags>1</flags></DisplayConfigPathInfo></pathInfoArray><modeInfoArray><modeInfo><id>49413</id><LUID xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><LowPart>105001</LowPart><HighPart>0</HighPart></LUID><DisplayConfigModeInfoType>Target</DisplayConfigModeInfoType><DisplayConfigTargetMode xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><targetVideoSignalInfo><pixelRate>635540000</pixelRate><hSyncFreq><numerator>635540000</numerator><denominator>2640</denominator></hSyncFreq><vSyncFreq><numerator>165</numerator><denominator>1</denominator></vSyncFreq><activeSize><cx>2560</cx><cy>1440</cy></activeSize><totalSize><cx>2640</cx><cy>1459</cy></totalSize><videoStandard>Other</videoStandard><ScanLineOrdering>Progressive</ScanLineOrdering></targetVideoSignalInfo></DisplayConfigTargetMode></modeInfo><modeInfo><id>1</id><LUID xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><LowPart>105001</LowPart><HighPart>0</HighPart></LUID><DisplayConfigModeInfoType>Source</DisplayConfigModeInfoType><DisplayConfigSourceMode xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><width>1680</width><height>1050</height><pixelFormat>Pixelformat32Bpp</pixelFormat><position><x>0</x><y>0</y></position></DisplayConfigSourceMode></modeInfo></modeInfoArray><additionalInfo><MonitorAdditionalInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><manufactureId>26884</manufactureId><productCodeId>10220</productCodeId><valid>true</valid><monitorDevicePath>XAAAAFwAAAA/AAAAXAAAAEQAAABJAAAAUwAAAFAAAABMAAAAQQAAAFkAAAAjAAAAQQAAAEMAAABJAAAAMgAAADcAAABFAAAAQwAAACMAAAA1AAAAJgAAADEAAAA1AAAAYgAAAGUAAAAzAAAAMwAAAGYAAAAyAAAAJgAAADAAAAAmAAAAVQAAAEkAAABEAAAANAAAADkAAAA0AAAAMQAAADMAAAAjAAAAewAAAGUAAAA2AAAAZgAAADAAAAA3AAAAYgAAADUAAABmAAAALQAAAGUAAABlAAAAOQAAADcAAAAtAAAANAAAAGEAAAA5AAAAMAAAAC0AAABiAAAAMAAAADcAAAA2AAAALQAAADMAAAAzAAAAZgAAADUAAAA3AAAAYgAAAGYAAAA0AAAAZQAAAGEAAABhAAAANwAAAH0AAAA=</monitorDevicePath><monitorFriendlyDevice>UgAAAE8AAABHAAAAIAAAAFAAAABHAAAAMgAAADcAAAA5AAAAUQAAAA==</monitorFriendlyDevice></MonitorAdditionalInfo><MonitorAdditionalInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><manufactureId>0</manufactureId><productCodeId>0</productCodeId><valid>false</valid><monitorDevicePath /><monitorFriendlyDevice /></MonitorAdditionalInfo></additionalInfo></displaySettings>
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?><displaySettings><pathInfoArray><DisplayConfigPathInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><sourceInfo><adapterId><LowPart>98691</LowPart><HighPart>0</HighPart></adapterId><id>1</id><modeInfoIdx>1</modeInfoIdx><statusFlags>InUse</statusFlags></sourceInfo><targetInfo><adapterId><LowPart>98691</LowPart><HighPart>0</HighPart></adapterId><id>49413</id><modeInfoIdx>0</modeInfoIdx><outputTechnology>DisplayportExternal</outputTechnology><rotation>Identity</rotation><scaling>Identity</scaling><refreshRate><numerator>143998</numerator><denominator>1000</denominator></refreshRate><scanLineOrdering>Progressive</scanLineOrdering><targetAvailable>true</targetAvailable><statusFlags>InUse</statusFlags></targetInfo><flags>1</flags></DisplayConfigPathInfo></pathInfoArray><modeInfoArray><modeInfo><id>49413</id><LUID xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><LowPart>98691</LowPart><HighPart>0</HighPart></LUID><DisplayConfigModeInfoType>Target</DisplayConfigModeInfoType><DisplayConfigTargetMode xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><targetVideoSignalInfo><pixelRate>586580000</pixelRate><hSyncFreq><numerator>586580000</numerator><denominator>2640</denominator></hSyncFreq><vSyncFreq><numerator>143998</numerator><denominator>1000</denominator></vSyncFreq><activeSize><cx>2560</cx><cy>1440</cy></activeSize><totalSize><cx>2640</cx><cy>1543</cy></totalSize><videoStandard>Other</videoStandard><ScanLineOrdering>Progressive</ScanLineOrdering></targetVideoSignalInfo></DisplayConfigTargetMode></modeInfo><modeInfo><id>1</id><LUID xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><LowPart>98691</LowPart><HighPart>0</HighPart></LUID><DisplayConfigModeInfoType>Source</DisplayConfigModeInfoType><DisplayConfigSourceMode xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><width>2560</width><height>1440</height><pixelFormat>Pixelformat32Bpp</pixelFormat><position><x>0</x><y>0</y></position></DisplayConfigSourceMode></modeInfo></modeInfoArray><additionalInfo><MonitorAdditionalInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><manufactureId>26884</manufactureId><productCodeId>10220</productCodeId><valid>true</valid><monitorDevicePath>XAAAAFwAAAA/AAAAXAAAAEQAAABJAAAAUwAAAFAAAABMAAAAQQAAAFkAAAAjAAAAQQAAAEMAAABJAAAAMgAAADcAAABFAAAAQwAAACMAAAA1AAAAJgAAADEAAAA1AAAAYgAAAGUAAAAzAAAAMwAAAGYAAAAyAAAAJgAAADAAAAAmAAAAVQAAAEkAAABEAAAANAAAADkAAAA0AAAAMQAAADMAAAAjAAAAewAAAGUAAAA2AAAAZgAAADAAAAA3AAAAYgAAADUAAABmAAAALQAAAGUAAABlAAAAOQAAADcAAAAtAAAANAAAAGEAAAA5AAAAMAAAAC0AAABiAAAAMAAAADcAAAA2AAAALQAAADMAAAAzAAAAZgAAADUAAAA3AAAAYgAAAGYAAAA0AAAAZQAAAGEAAABhAAAANwAAAH0AAAA=</monitorDevicePath><monitorFriendlyDevice>UgAAAE8AAABHAAAAIAAAAFAAAABHAAAAMgAAADcAAAA5AAAAUQAAAA==</monitorFriendlyDevice></MonitorAdditionalInfo><MonitorAdditionalInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><manufactureId>0</manufactureId><productCodeId>0</productCodeId><valid>false</valid><monitorDevicePath /><monitorFriendlyDevice /></MonitorAdditionalInfo></additionalInfo></displaySettings>
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -1,21 +0,0 @@
|
||||||
from subprocess import Popen
|
|
||||||
|
|
||||||
|
|
||||||
def on_event(event):
|
|
||||||
if event == obspython.OBS_FRONTEND_EVENT_SCRIPTING_SHUTDOWN:
|
|
||||||
proc = Popen(
|
|
||||||
r".\Desktop.bat",
|
|
||||||
cwd=r"TODO:\obs\ResolutionUtils",
|
|
||||||
shell=True,
|
|
||||||
)
|
|
||||||
_ = proc.communicate()
|
|
||||||
|
|
||||||
|
|
||||||
def script_load(settings):
|
|
||||||
obspython.obs_frontend_add_event_callback(on_event)
|
|
||||||
proc = Popen(
|
|
||||||
r".\Recording.bat",
|
|
||||||
cwd=r"TODO:\obs\ResolutionUtils",
|
|
||||||
shell=True,
|
|
||||||
)
|
|
||||||
_ = proc.communicate()
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
cd "TODO:\\Parsec Utils"
|
|
||||||
.\MonitorSwitcher.exe -load:.\Profiles\Recording.xml
|
|
||||||
.\SetDpi.exe 100 2
|
|
||||||
Binary file not shown.
Loading…
Reference in a new issue