Skip to content

o-daneel/Lunii.QT

Repository files navigation

πŸ‡«πŸ‡· README en franΓ§ais πŸ‡«πŸ‡·

Lunii.QT

A Python QT app to manage Lunii and Flam Storytellers, including reorder / import / export / hide / firmware download
for Windows / Linux / macOS
(compatible with STUdio archive, with transcoding)

Hardware supported:

  • v1, v2 (full Support)
  • v3 (export requires device key file)
  • Flam (partial support, only reorder and firmware backup)

Limitations

  • Application no longer allows Official stories to be exported
  • Audio transcoding requires FFMPEG v6 to be present (more details)

Table of contents

User Interface

.

Description

  1. The menu bar. It will notify you when an update is available
    (just get it with Menu About/Update to v2.X.X)

  2. The location of your Lunii/Flam when it's connected.
    The button on the left updates automatic detection.

  3. Official DB refresh : Updates the list of stories and related information from the official Lunii Store. Use it when some official are not recognized.

  4. The list of your stories with UUID and Database (DB) origin.
    The UUID: This unique identifier allows you to associate stories with their folder on the Lunii, thanks to the last eight characters that make up the name of the folder associated with that story.

    • DB stands for Database. This application supports two different databases
      • O - Lunii Official Database
        (all metadata are fed from Lunii servers)
      • T - Thirdparty Database, also known as Unofficial or Custom Stories
        (Those metadata can't be fetched. They are completed upon story import)
  5. The status bar, you'll find

    • your SNU (serial number)
    • the firmware version of your Lunii/Flam
    • the available space
    • the number of stories it contains
  6. Hidden stories (greyed items in the list) are still stored on the device, but won't be visible by Luniistore app. That will avoid getting third party stories to be removed during synchronization. Just remember to hide them before hitting sync button !

Shortcuts

Keys Actions
Ctrl+Up Move the selected item(s) Top
Alt+Up Move the selected item(s) Up
Alt+Down Move the selected item(s) Down
Ctrl+Down Move the selected item(s) Bottom
Ctrl+I Import new story
Ctrl+S Export the selection
Ctrl+Shift+S Export all the stories
Ctrl+H Hide/Show selected stories
Delete Remove the selected item(s)
Ctrl+O Open a Lunii/Flam device
Ctrl+L Open debug log window
Ctrl+Q Exit the application
F1 About the app
F5 Refresh devices

Features

  • Automatic Update detection
  • Import / Export / Remove stories
  • Support STUdio archive formats, and import STUdio database
  • Reorganize the stories in the order you want
  • Hide stories
    In order to avoid stories to get removed by Luniistore PC Synchronization, you can temporary hide them (all files ares kept on device), sync, and revert hide.
  • Lost Stories
    Three tools are offered to manage "crashed" stories on your device.
    You can :
    • List them
      (app will try to fix broken stories, in particular auth files on v1/v2)
    • Recover them (if they are complete)
    • Remove them (be careful, files will be deleted)
  • Get Firmware for your device (refer this section)

Audio Transcoding

Some third-party stories are using non MP3 files. Thus they can't be installed as it is on Lunii. It requires a transcoding step. This extra process is done using FFMPEG tool ( https://ffmpeg.org/download.html )

WARNING : transcoding is very long, you should be patient. That's why you should prefer the .plain.pk format that use compatible audio.

Installation

Windows

NOTE : By default, from now on, the Windows portable and MSI will embed FFMPEG 6.1.1

Procedure:

  1. grab your ffmpeg release from here
  2. rename it to ffmpeg.exe
  3. copy beside lunii-qt.exe
    - 
     |- lunii-qt.exe
     |- ffmpeg.exe
    
  4. restart luni-qt

Alternate method (I prefer):

  1. open powershell terminal
  2. run the following commands to install Scoop Package manager
    Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
    Invoke-RestMethod -Uri https://get.scoop.sh | Invoke-Expression
  3. install ffmpeg with
    scoop install ffmpeg
  4. restart luni-qt

Linux

  1. open a terminal
  2. run following command :
    sudo apt-get install ffmpeg
  3. restart luni-qt

macOS

To ease ffmpeg tool installation, it is recommended to use Brew from https://brew.sh/

  1. open a terminal
  2. copy and paste the following link
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  3. At the end of the installation, type into the terminal:
    brew install ffmpeg
  4. restart luni-qt

Checking

Within the application, the Tools menu will display the status of detection.

Not found

Not available

Found

Available

Firmware upgrade

Lunii.QT offers you the possibility to backup and upgrade your Firmware without connecting to LuniiStore (you won't lost your non official loaded stories). This procedure is experimental but so far no one faced issues.

NOTE 1: Remember to keep a backup of your firmware for Lunii v3 and FLAMs, in cas of a release that would break to third party stories trick. You will be able to downgrade.
NOTE 2: You cannot choose the firmware version. You'll only get the latest available from Lunii servers.

HowTo - Lunii

  1. Select a Lunii/Flam device
  2. Menu Tools/Get FW Update
  3. You'll be prompted for login entry

  1. Enter your Luniistore credentials (they are not saved for security purpose).
    You can verify this point here

    Lunii.QT/pkg/main_window.py

    Lines 468 to 475 in a8bd30e

    login_dialog = LoginDialog()
    if login_dialog.exec_() != QDialog.Accepted:
    return
    login, password = login_dialog.get_login_password()
    try:
    # getting auth token
    auth_token = lunii_get_authtoken(login, password)
  2. Pick a location where to save your firmware(s) (there are two for Lunii v1)
  3. Copy it to the root dir of your device
  4. Rename it to fa.bin (and optionnally fu.bin for Lunii v1)
- 
 |- .contents
 |- .md
 |- .pi
 |- fa.bin
 |- ... (other files)
  1. Power OFF, Power ON, Wait : TADA
    (if you reconnect your lunii on your pc, the fa.bin should have been removed)

HowTo - Flam

  1. Select a Flam device
  2. Menu Tools/Get FW Update
  3. You'll be prompted for login entry

  1. Enter your Luniistore credentials (they are not saved for security purpose).
    You can verify this point here

    Lunii.QT/pkg/main_window.py

    Lines 468 to 475 in a8bd30e

    login_dialog = LoginDialog()
    if login_dialog.exec_() != QDialog.Accepted:
    return
    login, password = login_dialog.get_login_password()
    try:
    # getting auth token
    auth_token = lunii_get_authtoken(login, password)
  2. Pick a location where to save your firmwares (update-main.enc and update-comm.enc)
  3. Copy them to the root dir of your device
- 
 |- etc/
 |- str/
 |- .mdf
 |- update-main.enc
 |- update-comm.enc
 |- ... (other files)
  1. Create an empty file cable_update_complete in /tmp
- 
 |- etc/
 |- str/
 |- .mdf
 |- update-main.enc
 |- update-comm.enc
 |- tmp/
   |- cable_update_complete
 |- ... (other files)
  1. Eject USB from Flam device (USB cable must be kept connected) and update process will start : TADA
    (if you reconnect your flam on your pc, the *.enc should have been removed)

Supported archive formats (Lunii)

NOTE : Flam stories are not yet supported

.plain.pk

Filename : story_name.8B_UUID.plain.pk
Ciphering : None / Plain
Structure :

  uuid.bin
  ni
  li.plain
  ri.plain
  si.plain
  rf/000/XXYYXXYY.bmp
  sf/000/XXYYXXYY.mp3

.v1.pk / .v2.pk

Filename :

  • LONG_UUID.v2.pk
  • LONG_UUID.v2.pk
  • LONG_UUID.pk

Ciphering : Generic Key
Structure :

  00000000000000000000000000000000/ni
  00000000000000000000000000000000/li
  00000000000000000000000000000000/ri
  00000000000000000000000000000000/si
  00000000000000000000000000000000/rf/000/XXYYXXYY
  00000000000000000000000000000000/sf/000/XXYYXXYY

ZIP (old Lunii.QT)

Filename : 8B_UUID - story_name.zip
Ciphering : Generic Key
Structure :

  uuid.bin
  ni
  li
  ri
  si
  rf/000/XXYYXXYY
  sf/000/XXYYXXYY

ZIP (alternate)

Filename : AGE+] story_title DASHED_UUID.zip
Ciphering : Generic Key
Structure : (same as .v1.pk / .v2.pk)

  00000000-0000-0000-0000-000000000000/ni
  00000000-0000-0000-0000-000000000000/li
  00000000-0000-0000-0000-000000000000/ri
  00000000-0000-0000-0000-000000000000/si
  00000000-0000-0000-0000-000000000000/rf/000/XXYYXXYY
  00000000-0000-0000-0000-000000000000/sf/000/XXYYXXYY

7z

Filename : AGE+] story_title DASHED_UUID.7z
Ciphering : Generic Key
Structure :

  00000000-0000-0000-0000-000000000000/ni
  00000000-0000-0000-0000-000000000000/li
  00000000-0000-0000-0000-000000000000/ri
  00000000-0000-0000-0000-000000000000/si
  00000000-0000-0000-0000-000000000000/rf/000/XXYYXXYY
  00000000-0000-0000-0000-000000000000/sf/000/XXYYXXYY

STUdio (ZIP / 7z)

Filename : AGE+] story_title DASHED_UUID.zip .7z
Ciphering : None

Structure :

    assets/
    stroy.json
    thumbnail.png

Python ? HowTo

Prepare env

First, clone the git repo
Prepare a Virtual environment for your project and install requirements

$ python3 -m venv venv

Switch to your venv

  • on Linux
    source venv/bin/activate
  • on Windows
    .\venv\Scripts\activate.bat

Install dependencies ****``` $ pip install -r requirements.txt


**Linux** has one more extra dependency to be installed  

```bash
$ apt install libxcb-cursor0

Build UI files

$ pyside6-uic pkg/ui/main.ui -o pkg/ui/main_ui.py
$ pyside6-rcc resources.qrc -o resources_rc.py

Run

$ python lunii-qt.py

Build GUI executable

NOTE : PyInstaller by its design generates executables that are flagged by AntiViruses. Those are false positives. cx_Freeze is an alternative that allows to avoid such false positives.

PyInstaller πŸ‘Ž

$ pip install pyinstaller
$ pyinstaller lunii-qt.spec
...
$ dist\lunii-qt

cx_Freeze πŸ‘

$ pip install cx_Freeze
$ python setup.py build_exe
...
$ build/exe.win-amd64/lunii-qt

Tricks

macOS - Application Authorization

  1. Double-click the file called lunii-qt.
  2. You should see an error message "lunii-qt can’t be opened because it is from an unidentified developer".

    Click "OK"
  3. Go to System Preferences > Security and Privacy and click on the General tab.
  4. At the bottom of the window you will see a message saying that lunii-qt was blocked. Click "Open Anyway".
    If you do not see this message in the General tab, double-click lunii-qt again.
    NOTE : You may have to click the "unlock" button and enter your password to be able to click "Open Anyway".
  5. If you see another popup that says β€œlunii-qt is from an unidentified developer. Are you sure you want to open it?”, click "Open". If you don’t get this popup, just go to the same file and double-click it again.
  6. Finally, you'll be informed that lunii-qt was downloaded from internet

    Click "Open", and you'll never get these messages in the future.

Third Party story metadata

You might have already loaded non-official stories to your device thanks to another app. When opening Lunii.QT, this story will appear as Unknown story (maybe a User created story)....
You can easily fix that by :

  1. Importing STUdio DB with menu File/Import STUdio DB
  2. Dropping the corresponding archive as you'll do for loading.
    Lunii.QT will only read the metadata and add them locally, skipping the rest of the archive.

Cache management

This application will download once for all the official story database and any request pictures to the application dedicated folder

  • $HOME/.lunii-qt/official.db
  • $HOME/.lunii-qt/cache/*

In case of any trouble, just remove this file and directory to force refresh

v3 export

In order to suport story export from Lunii v3 hardware, you must place your device keys in here :

%HOME%\.lunii-qt\v3.keys
$HOME/.lunii-qt/v3.keys

It is a binary file with 0x10 bytes for Key and 0x10 bytes for IV

ICO creation

magick convert logo.png -define icon:auto-resize="256,128,96,64,48,32,16"  logo.ico

Credits

Thanks to :

  • olup for STUdio archive format
  • sniperflo for v1 support, MacOs support & debug
  • McFlyPartages for Linux debug and other contributions

Links / Similar repos