Skip to content

Commit

Permalink
v1.0
Browse files Browse the repository at this point in the history
Finished up the scripts so far
  • Loading branch information
MightyZanark committed Jul 14, 2022
1 parent f1f3187 commit e6f4f7f
Show file tree
Hide file tree
Showing 14 changed files with 213 additions and 153 deletions.
8 changes: 6 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ __pycache__/
database/
movie/
sound/
Test.py
dist/
build/
*.spec

Test.py
*.spec
Run.exe
PriconneUtils.exe
*.ico
31 changes: 21 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,51 @@
# Priconne Utils

Scripts written in Python to get the master.db, BGM files, L2D, UB Cutin, etc. from the game Princess Connect! Re: Dive JP Server. Made in Windows 10, so it might not work as intended on other OSs.
Scripts written in Python to get the master database, BGM files, L2D, UB Cutin, etc. from the game Princess Connect! Re: Dive JP Server. Made in Windows 10, so it might not work as intended on other OSs.


## Requirements

- Internet Connection (obviously)
- [Python 3.x](https://www.python.org/downloads/)
- Requests library for Python `pip install requests`
- [acb2wavs (for audio files)](https://github.com/hozuki/libcgss)
- [UsmToolkit (for video files)](https://github.com/MightyZanark/UsmToolkit)
- [FFmpeg (for audio files and UsmToolkit)](https://ffmpeg.org/download.html)
- [.NET 3.1 Core Runtime (for UsmToolkit)](https://dotnet.microsoft.com/en-us/download/dotnet/3.1/runtime)

Note: If you don't already have FFmpeg installed, then you can just do it from UsmToolkit. UsmToolkit have a command to download FFmpeg.


## How to Use

1. Well first of all, install all the requirements, won't work without it.
2. If you haven't already, add Python, UsmToolkit, and FFmpeg to PATH in System Variables. If you don't know how to do that then check out the later section. Additionally, if you got FFmpeg from UsmToolkit, then as long as UsmToolkit is in PATH, you are good to go.
3. If you got everything set up already, then you can double click on `Run.py` to run the script. After running, a window will pop up and there are instructions there as well.
4.
2. If you haven't already, add acb2wavs, UsmToolkit, and FFmpeg to PATH in System Variables. If you don't know how to do that then check out the later section. Additionally, if you got FFmpeg from UsmToolkit, then as long as UsmToolkit is in PATH, you are good to go.
3. Don't forget to download the executable from [latest](https://github.com/MightyZanark/PriconneUtils/releases/latest).
4. If you got everything set up already, then you can double click on `PriconneUtils.exe` to run the program. After running, a window will pop up and there are instructions there as well.
5. Type the option that you would like to do, upper/lowercases doesn't matter.
6. After the program runs the option you selected, it will ask you if you want to continue on to another option or to stop. Just write a simple `y` (yes) or `n` (no) as indicated.
7. And that is it. The L2D, cutin, etc will be saved in a folder created right where the `PriconneUtils.exe` file is, so if you don't want to bother moving the output files elsewhere later, make sure to place the executable where you want it.


## How to Add to PATH (Windows 10)

1. Open up the search bar and search for `system variables`, `Edit the system environment variables` should appear so click on it.
2. A window called `System Properties` should open and you should be in the `Advanced` tab.
3. At the very bottom, there should be a button called `Environment Variables...`, click that.
4. Another window called `Environment Variables` should open up. There are 2 section in it, the upper part is the variables for the **CURRENT USER**, while the bottom part is for the **WHOLE SYSTEM** (or ALL USER). You can choose whether you like Python, UsmToolkit, and FFmpeg to be available to only the **CURRENT USER** or to **ALL USER**.
4. Another window called `Environment Variables` should open up. There are 2 section in it, the upper part is the variables for the **CURRENT USER**, while the bottom part is for the **WHOLE SYSTEM** (or ALL USER). You can choose whether you like acb2wavs, UsmToolkit, and FFmpeg to be available to only the **CURRENT USER** or to **ALL USER**.
5. After you decided which one you want to edit, find the variable called `Path` (not `PATHEXT`), select it, and press `Edit` or double click it. That should open up yet another window.
6. In that window, there should be all kinds of options like `New`, `Edit`, `Browse`, `Delete`, etc. To add Python and UsmToolkit to it, press `New`.
7. Copy and paste the full path of Python and UsmToolkit, and by full path I meant something like this `C:\Users\user\AppData\Local\Programs\Python\Python39\`. At the end of it, you should have something along this line
6. In that window, there should be all kinds of options like `New`, `Edit`, `Browse`, `Delete`, etc. To add acb2wavs and UsmToolkit to it, press `New`.
7. Copy and paste the full path of acb2wavs and UsmToolkit, and by full path I meant something like this `D:\libcgss-win-x86-vc14.2-0.3.7.89\bin\x86\Release` (acb2wavs). At the end of it, you should have something along this line

![Image of completed path](./path.png)

I have FFmpeg as a separate line because I already have FFmpeg installed way before I have UsmToolkit, but if you don't have both and you downloaded FFmpeg from UsmToolkit command, then you just need to have UsmToolkit in `Path` and it will work just fine.

If this still wasn't clear, you can contact me through Discord from [Priconne Unofficial Server](https://discord.gg/priconne), if you're not from the server, chances are I will just ignore your DM/friend req. My tag is **MightyZanark#0138**.


## Building

If you want to modify and build the program yourself, you will need:
- [Python 3.9.6](https://www.python.org/downloads/)
- Requests `pip install requests`
- Pyinstaller `pip install pyinstaller`

After installing those, you can just run the `build.bat` file under the scripts folder.
27 changes: 0 additions & 27 deletions Run.py

This file was deleted.

1 change: 0 additions & 1 deletion build.bat

This file was deleted.

4 changes: 2 additions & 2 deletions config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"TruthVersion": 10039500,
"hash": "6570a400cacce97dc5db5bb4a9dafe0b",
"TruthVersion": 10039800,
"hash": "5b6d3e1264489008ce6044d4a69d106a",
"assetmanifest": "http://prd-priconne-redive.akamaized.net/dl/Resources/version/Jpn/AssetBundles/Windows/manifest/manifest_assetmanifest",
"masterdata": "http://prd-priconne-redive.akamaized.net/dl/Resources/version/Jpn/AssetBundles/Windows/manifest/masterdata_assetmanifest",
"movie": "http://prd-priconne-redive.akamaized.net/dl/Resources/version/Jpn/Movie/PC/High/manifest/moviemanifest",
Expand Down
Binary file modified path.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
60 changes: 60 additions & 0 deletions scripts/Constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import os, re

CUR_DIR = os.getcwd()

# DBCheck constants
CONFIG_FILE = os.path.join(CUR_DIR, 'config.json')
DB_DIR = os.path.join(CUR_DIR, 'database')
MAX_TEST = 20
TEST_MULTIPLIER = 10


# Movie constants
MOVIE_URL = 'http://prd-priconne-redive.akamaized.net/dl/pool/Movie'
MOVIE_DIR = os.path.join(CUR_DIR, 'movie')
MOVIEMANIFEST = os.path.join(DB_DIR, 'moviemanifest')

L2D_DIR = os.path.join(MOVIE_DIR, 'l2d')
L2D_NAME = re.compile('character_\d+_000002\.usm')

CUTIN_DIR = os.path.join(MOVIE_DIR, 'cutin')
CUTIN_NAME = re.compile('cutin_\d+\.usm')

SUMMON_DIR = os.path.join(MOVIE_DIR, 'summon')
SUMMON_NAME = re.compile('character_\d+_000001\.usm')

EVENT_DIR = os.path.join(MOVIE_DIR, 'event')
EVENT_NAME = re.compile('story_5\d{5}[7-9]0[1-2]\.usm')

MOVIE_TYPES = {
'dir': {
'cutin': CUTIN_DIR,
'l2d': L2D_DIR,
'summon': SUMMON_DIR,
'event': EVENT_DIR
},
'name': {
'cutin': CUTIN_NAME,
'l2d': L2D_NAME,
'summon': SUMMON_NAME,
'event': EVENT_NAME
}
}


# Sound constants
SOUND_URL = 'http://prd-priconne-redive.akamaized.net/dl/pool/Sound'
SOUND_DIR = os.path.join(CUR_DIR, 'sound')
SOUNDMANIFEST = os.path.join(DB_DIR, 'sound2manifest')

BGM_DIR = os.path.join(SOUND_DIR, 'bgm')
BGM_NAME = re.compile('bgm_.+\.(acb||awb)')

SOUND_TYPES = {
'dir': {
'bgm': BGM_DIR
},
'name': {
'bgm': BGM_NAME
}
}
40 changes: 18 additions & 22 deletions DBCheck.py → scripts/DBCheck.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
import os, requests, json, asyncio
import os, requests, json
import Constants

cur_dir = os.getcwd()
max_test = 20
test_multi = 10
conf = r'.\config.json'
db_dir = r'.\database'

async def update_db():
# Function to update the db if there is one
def update_db():
# Checks if database folder exist, if it doesn't then create one
if not os.path.isdir(db_dir):
os.mkdir(db_dir)
if not os.path.isdir(Constants.DB_DIR):
os.mkdir(Constants.DB_DIR)

print('Checking for database updates...')
await check_update()
check_update()

# Downloads the new database alongside manifests
# print('Downloading database and manifests...')
Expand All @@ -23,7 +19,7 @@ async def update_db():

# Downloads .db and sound/movie manifest to use for L2D, BGM extraction, etc.
def download_manifest(type):
with open(conf, 'r') as f:
with open(Constants.CONFIG_FILE, 'r') as f:
data = json.load(f)
t = str(data[type])
hash = data["hash"]
Expand All @@ -35,27 +31,28 @@ def download_manifest(type):
database = requests.get(f'{t}/{hash[:2]}/{hash}').content
with open('master.cdb', 'wb') as cdb:
cdb.write(database)
os.system(f'Coneshell_call.exe -cdb master.cdb "{db_dir}\\master.db"')
os.system(f'Coneshell_call.exe -cdb master.cdb "{Constants.DB_DIR}\\master.db"')
os.remove('master.cdb')
print("> Finished downloading database!\n")

else:
print(f'Downloading {manifest_name}...')
manifest = requests.get(t.replace('version', ver)).content
with open(f'{db_dir}\\{manifest_name}', 'wb') as m:
with open(os.path.join(Constants.DB_DIR, manifest_name), 'wb') as m:
m.write(manifest)
print("> Download completed!\n")

async def check_update():
with open(conf, 'r+') as j:
# Function to check for DB updates and to update config.json if there is an update
def check_update():
with open(Constants.CONFIG_FILE, 'r+') as j:
c = json.load(j)
version = int(c["TruthVersion"])
assetmanifest = str(c["assetmanifest"])
i = 1

# While loop to check for new versions
while i <= max_test:
guess = version + (i * test_multi)
while i <= Constants.MAX_TEST:
guess = version + (i * Constants.TEST_MULTIPLIER)
r = requests.get(assetmanifest.replace('version', str(guess)))
if r.status_code == 200:
print(f'[{guess}] is a valid new version. Checking for more...')
Expand All @@ -79,9 +76,8 @@ async def check_update():
j.seek(0)
json.dump(c, j, indent=1)

print('>> Update check completed!\n')
return
# print('>> Update check completed!\n')


if __name__ == '__main__':
asyncio.run(update_db())
# if __name__ == '__main__':
# update_db()
Loading

0 comments on commit e6f4f7f

Please sign in to comment.