Skip to content

Commit

Permalink
v1.1 update
Browse files Browse the repository at this point in the history
  • Loading branch information
seregonwar authored Sep 29, 2024
1 parent 6d46ac6 commit 5ff2c7f
Show file tree
Hide file tree
Showing 55 changed files with 4,308 additions and 0 deletions.
3 changes: 3 additions & 0 deletions PkgToolBox/FodyWeavers.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<Costura />
</Weavers>
9 changes: 9 additions & 0 deletions PkgToolBox/IllegalNameCheck.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import re

class IllegalNameCheck:
@staticmethod
def is_valid_file_name(expression, platform_independent):
s_pattern = r"^(?!^(PRN|AUX|CLOCK\$|NUL|CON|COM\d|LPT\d|\..*)(\..+)?$)[^\x00-\x1f\\?*:\";|/]+$"
if platform_independent:
s_pattern = r"^(([a-zA-Z]:|\\)\\)?(((\.)|(\.\.)|([^\\/:\*\?\"<>\. ](([^\\/:\*\?\"<>\. ])|([^\\/:\*\?\"<>]*[^\\/:\*\?\"<>\. ]))?))\\)*[^\\/:\*\?\"<>\. ](([^\\/:\*\?\"<>\. ])|([^\\/:\*\?\"<>]*[^\\/:\*\?\"<>\. ]))?$"
return re.match(s_pattern, expression) is not None
Binary file added PkgToolBox/OrbisLibrary/orbis-pub-cmd.exe
Binary file not shown.
34 changes: 34 additions & 0 deletions PkgToolBox/PS4PKGToolTemp/Settings.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"pkg_directories": [],
"scan_recursive": false,
"play_bgm": false,
"show_directory_settings_at_startup": true,
"auto_sort_row": false,
"local_server_ip": "",
"ps4_ip": "",
"nodejs_installed": false,
"http_server_installed": false,
"official_update_download_directory": "",
"pkg_color_label": false,
"game_pkg_forecolor": -2302756,
"patch_pkg_forecolor": -2302756,
"addon_pkg_forecolor": -2302756,
"app_pkg_forecolor": -2302756,
"game_pkg_backcolor": -12828863,
"patch_pkg_backcolor": -12828863,
"addon_pkg_backcolor": -12828863,
"app_pkg_backcolor": -12828863,
"rename_custom_format": "",
"ps5bc_json_download_date": "",
"psvr_neo_ps5bc_check": false,
"pkg_titleId_column": true,
"pkg_contentId_column": true,
"pkg_region_column": true,
"pkg_minimum_firmware_column": true,
"pkg_version_column": true,
"pkg_type_column": true,
"pkg_category_column": true,
"pkg_size_column": true,
"pkg_location_column": true,
"pkg_backport_column": true
}
80 changes: 80 additions & 0 deletions PkgToolBox/PkgToolBox.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# -*- mode: python ; coding: utf-8 -*-


import os
import sys
from PyInstaller.utils.hooks import collect_all

block_cipher = None

# Ottieni il percorso della directory corrente
current_dir = os.path.dirname(os.path.abspath('__main__'))

# Funzione per verificare l'esistenza di un file o una directory
def resource_path(relative_path):
path = os.path.join(current_dir, relative_path)
if not os.path.exists(path):
print(f"Warning: {path} not found")
return path

# Raccogli tutti i dati necessari per Crypto
crypto_datas, crypto_binaries, crypto_hiddenimports = collect_all('Crypto')

a = Analysis(
['main.py'],
pathex=[current_dir],
binaries=crypto_binaries,
datas=crypto_datas,
hiddenimports=[
'PyQt5',
'PIL',
'kiwisolver',
'concurrent.futures',
'Utilities',
'Utilities.Trophy',
'repack',
] + crypto_hiddenimports,
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False,
)

pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)

exe = EXE(
pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name='PkgToolBox',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=False,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)

# Crea una cartella per i file temporanei
temp_folder = 'PS4PKGToolTemp'
if not os.path.exists(temp_folder):
os.makedirs(temp_folder)

# Copia la cartella PS4PKGToolTemp nell'eseguibile
import shutil
shutil.copytree(temp_folder, os.path.join(DISTPATH, temp_folder), dirs_exist_ok=True)

print(f"Build completed. Executable should be in {DISTPATH}")
4 changes: 4 additions & 0 deletions PkgToolBox/Utilities/Constants/ImageIconExtractionType.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class ImageIconExtractionType:
ALL = "ALL"
IMAGE = "IMAGE"
ICON = "ICON"
10 changes: 10 additions & 0 deletions PkgToolBox/Utilities/Constants/NamingFormat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class NamingFormat:
TITLE = "{TITLE}"
TITLE_ID = "{TITLE_ID}"
APP_VERSION = "{APP_VERSION}"
VERSION = "{VERSION}"
CATEGORY = "{CATEGORY}"
CONTENT_ID = "{CONTENT_ID}"
CONTENT_ID2 = "{CONTENT_ID2}"
REGION = "{REGION}"
SYSTEM_VERSION = "{SYSTEM_VERSION}"
6 changes: 6 additions & 0 deletions PkgToolBox/Utilities/Constants/PKGCategory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class PKGCategory:
GAME = "Game"
PATCH = "Patch"
ADDON = "Addon"
APP = "App"
UNKNOWN = "Unknown"
8 changes: 8 additions & 0 deletions PkgToolBox/Utilities/Constants/PKGRegion.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class PKGRegion:
UK = "UK"
EU = "EU"
US = "US"
JAPAN = "JAPAN"
HONG_KONG = "HONG KONG"
ASIA = "ASIA"
KOREA = "KOREA"
3 changes: 3 additions & 0 deletions PkgToolBox/Utilities/Constants/PKGSelectionType.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class PKGSelectionType:
ALL = "ALL"
SELECTED = "SELECTED"
4 changes: 4 additions & 0 deletions PkgToolBox/Utilities/Constants/PKGState.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class PKGState:
FAKE = "Fake"
OFFICIAL = "Official"
ADDON_UNLOCKER = "Addon_Unlocker"
6 changes: 6 additions & 0 deletions PkgToolBox/Utilities/Constants/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from .ImageIconExtractionType import ImageIconExtractionType
from .NamingFormat import NamingFormat
from .PKGCategory import PKGCategory
from .PKGRegion import PKGRegion
from .PKGSelectionType import PKGSelectionType
from .PKGState import PKGState
8 changes: 8 additions & 0 deletions PkgToolBox/Utilities/Extension/Extension.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class Extension:
@staticmethod
def get_until_or_empty(text, stop_at="-"):
if text:
char_location = text.find(stop_at)
if char_location > 0:
return text[:char_location]
return ""
9 changes: 9 additions & 0 deletions PkgToolBox/Utilities/Extension/TreeView.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from PyQt5.QtWidgets import QTreeWidgetItem

class TreeView:
@staticmethod
def get_all_nodes(node):
list_nodes = [node]
for i in range(node.childCount()):
list_nodes.extend(TreeView.get_all_nodes(node.child(i)))
return list_nodes
2 changes: 2 additions & 0 deletions PkgToolBox/Utilities/Extension/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from .Extension import Extension
from .TreeView import TreeView
19 changes: 19 additions & 0 deletions PkgToolBox/Utilities/GlobalUsing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# This file is not necessary in Python as imports are handled differently.
# However, we can use it to define some common global imports.

from PyQt5.QtWidgets import QMessageBox
from PyQt5.QtGui import QColor
import os
import json
import struct
import io
import zipfile
from typing import List, Optional

# Imports from custom utilities
from Utilities.PS4PKGToolHelper.Helper import Helper
from Utilities.PS4PKGToolHelper.MessageBoxHelper import MessageBoxHelper
from Utilities.Settings.AppSettings import AppSettings
from Utilities.Settings.SettingsManager import SettingsManager

# Other common imports can be added here
9 changes: 9 additions & 0 deletions PkgToolBox/Utilities/ListViewDraw.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from PyQt5.QtWidgets import QTreeWidget, QTreeWidgetItem
from PyQt5.QtGui import QColor, QBrush

class ListViewDraw:
@staticmethod
def color_list_view_header(tree_widget, back_color, fore_color):
for i in range(tree_widget.columnCount()):
tree_widget.headerItem().setBackground(i, QBrush(back_color))
tree_widget.headerItem().setForeground(i, QBrush(fore_color))
35 changes: 35 additions & 0 deletions PkgToolBox/Utilities/Logger.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import logging
import sys

class Logger:
@staticmethod
def setup_logger():
logging.basicConfig(filename='PS4PKGToolLog.txt', level=logging.DEBUG,
format='%(asctime)s - %(levelname)s: %(message)s',
datefmt='%Y-%m-%d %H:%M:%S')
console = logging.StreamHandler(sys.stdout)
console.setLevel(logging.INFO)
formatter = logging.Formatter('%(levelname)s: %(message)s')
console.setFormatter(formatter)
logging.getLogger('').addHandler(console)

@staticmethod
def log_information(message):
try:
logging.info(message)
except Exception as e:
logging.error(f"Errore nel logging: {str(e)}")

@staticmethod
def log_error(message):
try:
logging.error(message)
except Exception as e:
logging.error(f"Errore nel logging: {str(e)}")

@staticmethod
def log_warning(message):
try:
logging.warning(message)
except Exception as e:
logging.error(f"Errore nel logging: {str(e)}")
20 changes: 20 additions & 0 deletions PkgToolBox/Utilities/PS4PKGToolHelper/DialogHelper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from PyQt5.QtWidgets import QFileDialog

class DialogHelper:
@staticmethod
def show_folder_browser_dialog():
dialog = QFileDialog()
dialog.setFileMode(QFileDialog.Directory)
if dialog.exec_():
return dialog.selectedFiles()[0]
return None

@staticmethod
def show_save_file_dialog(title, filter):
dialog = QFileDialog()
dialog.setAcceptMode(QFileDialog.AcceptSave)
dialog.setNameFilter(filter)
dialog.setWindowTitle(title)
if dialog.exec_():
return dialog.selectedFiles()[0]
return None
86 changes: 86 additions & 0 deletions PkgToolBox/Utilities/PS4PKGToolHelper/Helper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import os
import json
from datetime import datetime
from PyQt5.QtWidgets import QMessageBox
from PyQt5.QtGui import QPixmap
from PyQt5.QtCore import QByteArray, Qt

class Helper:
first_launch = True
finalize_pkg_process = True
ps4pkg_tool_temp_directory = "path/to/temp/directory"
orbis_pub_cmd = os.path.join(ps4pkg_tool_temp_directory, "orbis-pub-cmd.exe")
ps5_bc_json_file = os.path.join(ps4pkg_tool_temp_directory, "ps5bc.json")
ps4pkg_tool_log_file = os.path.join(ps4pkg_tool_temp_directory, "PS4PKGToolLog.txt")

@staticmethod
def round_bytes(num):
if num < 1024:
return f"{num} bytes"
elif num < 1048576:
return f"{round(num / 1024, 2)} KB"
elif num < 1073741824:
return f"{round(num / 1048576, 2)} MB"
elif num < 1099511627776:
return f"{round(num / 1073741824, 2)} GB"
else:
return f"{round(num / 1099511627776, 2)} TB"

@staticmethod
def extract_resources():
pass

@classmethod
def get_backport_info_file(cls):
return os.path.join(cls.ps4pkg_tool_temp_directory, "backport.json")

class Backport:
backport_info_file = None
pkg_file_list = []

@staticmethod
def check_pkg_backported(pkg_file):
if Backport.backport_info_file is None:
Backport.backport_info_file = Helper.get_backport_info_file()
with open(Backport.backport_info_file, 'r') as f:
Backport.pkg_file_list = json.load(f)
matching_file = next((file for file in Backport.pkg_file_list if file["FilePath"].lower() == pkg_file.lower()), None)
return matching_file["Backported"] if matching_file else None

@staticmethod
def save_data(data_grid_view):
updated_pkg_file_list = []
for row in data_grid_view:
file_path = os.path.join(row[12], row[0])
backported = "No" if row[13] == "No" else row[13]
updated_pkg_file_list.append({"FilePath": file_path, "Backported": backported})
with open(Backport.backport_info_file, 'w') as f:
json.dump(updated_pkg_file_list, f, indent=4)

class Bitmap:
pic0 = None
pic1 = None
fail_extract_image_list = ""

@staticmethod
def bytes_to_bitmap(img_bytes):
pixmap = QPixmap()
pixmap.loadFromData(QByteArray(img_bytes))
return pixmap

@staticmethod
def resize_image(image, width, height):
return image.scaled(width, height, aspectRatioMode=Qt.KeepAspectRatio, transformMode=Qt.SmoothTransformation)

class Trophy:
trophy = None
id_entry_list = []
name_entry_list = []
image_to_extract_list = []
trophy_filename_to_extract_list = []
trophy_temp_folder = os.path.join(Helper.ps4pkg_tool_temp_directory, "TrophyFile")
out_path = ""

@staticmethod
def resize_image(image, width, height):
return image.scaled(width, height, aspectRatioMode=Qt.KeepAspectRatio, transformMode=Qt.SmoothTransformation)
Loading

0 comments on commit 5ff2c7f

Please sign in to comment.