Giter Club home page Giter Club logo

rpatool's Introduction

rpatool

This is a simple tool allowing you to create, modify and extract Ren'Py Archive (.rpa/.rpi) files. Currently, only writing to RPAv2/RPAv3 archives is supported.

Usage

rpatool [-l|-x|-c|-d|-a] [-o OUTFILE] [-2] [-3] [-k KEY]
        [-p COUNT] [-h] [-v] [-V]
        ARCHIVE [FILE [FILE ...]]


positional arguments:
  ARCHIVE               The Ren'py archive file to operate on
  FILE                  Zero or more files to operate on

actions:
  -l, --list            List files in archive ARCHIVE
  -x, --extract         Extract FILEs from ARCHIVE
  -c, --create          Creative ARCHIVE from FILEs
  -d, --delete          Delete FILEs from ARCHIVE
  -a, --append          Append FILEs to ARCHIVE

optional arguments:
  -o OUTFILE, --outfile OUTFILE
                        An alternative output archive file when appending to or
                        deleting from archives, or output directory when extracting.
  -2, --two             Use the RPAv2 format for creating/appending to
                        archives
  -3, --three           Use the RPAv3 format for creating/appending to
                        archives (default)
  -k KEY, --key KEY     The obfuscation key used for creating RPAv3 archives 
                        (default: 0xDEADBEEF)
  -p COUNT, --padding COUNT
                        The maximum number of bytes of padding to add between
                        files (default: 0)
  -h, --help            Print this help and exit
  -v, --verbose         Be a bit more verbose while performing operations
  -V, --version         Show version information

The FILE argument can optionally be in ARCHIVE=REAL format, mapping a file in
the archive file system to a file on your real file system. An example of
this is: rpatool -x test.rpa script.rpyc=/home/foo/test.rpyc

Examples

rpatool -x foo.rpa

Will extract every file from foo.rpainto the current directory, making subdirectories when necessary.

rpatool -o output -x foo.rpa script.rpyc ui.png

Will extract the files script.rpyc and ui.png from foo.rpa into the directory output.

rpatool -c bar.rpa test.jpg script.rpy sprites

Will create the archive bar.rpa, containing the files test.jpg, script.rpy and the directory sprites.

rpatool -p 25 -k 12345 -c bar.rpa movies=C:\projects\vn\movies

Will create the archive bar.rpa with the obfuscation key 0x12345 and maximum padding of 25, taking files from C:\projects\vn\movies and placing them in the archive folder movies.

rpatool -l baz.rpa

Will list all files in the archive baz.rpa.

rpatool -v -a foo.rpa sprites=sprites_new

Will add all files from the directory sprites_new to the directory sprites in the archive, giving more information about what it's doing.

rpatool -o bar_new.rpa -d bar.rpa foo.jpg

Will remove the file foo.jpg from the archive bar.rpa, storing the result archive in bar_new.rpa.

API

rpatool can also be included in any other project (following the license conditions, of course) to provide the RenPyArchive class. A small overview:

RenPyArchive([file = None], [version = 3], [padlength = 0], [key = 0xDEADBEEF], [verbose = False])

The constructor, which will optionally load an archive file.

file: the archive file to open. If None, no archive will be attempted to open.

version: the archive format version used to save the archive when RenPyArchive.save([file]) is called. Default: 3

padlength: the maximum number of bytes of padding to put between files when saving. Default: 0

key: the obfuscation key used when saving RPAv3 archives. Default: 0xDEADBEEF

verbose: print info on what we are doing to the command line. Default: False

RenPyArchive.load(filename)

Loads an archive file from filename. Will raise an IOError if the file can't be accessed, or a ValueError if the file is not detected as a Ren'Py archive.

RenPyArchive.save([filename])

Save the archive to filename. Will raise ValueError if the filename isn't given with filename, nor previously defined, or an IOError if it couldn't save the file.

RenPyArchive.list()

Give a list of all filenames currently in the archive.

RenPyArchive.has_file(filename)

Returns True if filename is found in the archive, False otherwhise.

RenPyArchive.add(filename, content)

Add a file to the archive with file filename and contents content. Will raise a ValueError if the filename already exists in the archive.

RenPyArchive.change(filename, content)

Change the contents of a current file in the archive. Will raise an IOError if the file isn't known in the archive.

RenPyArchive.remove(filename)

Remove filename from the archive. Will raise an IOError if the filename isn't known in the archive.

RenPyArchive.read(filename)

Read and return the content of file filename in the archive. Will raise an IOError if the filename isn't known in the archive.

License

rpatool is licensed under the WTFPL. See the LICENSE file for more details.

Disclaimer

This tool is intended for use with files on which the authors allowed modification of and/or extraction from ONLY and the unpermitted use on files where such consent was not given is highly discouraged, and most likely a license violation as well. Support requests for help with dealing with such files will not be answered.

Credits

Credits for the creation of the Ren'Py archive format and the reference code in Ren'Py go to renpytom.

rpatool's People

Contributors

schwert avatar sebastic avatar shizmob avatar universedevel avatar vasyapro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rpatool's Issues

Extract error

Tried to extact a rpa file but got the error 'bytes' object has no attribute 'encode'

Fixed it by changing _unmangle to this:
return data.encode('latin1') if hasattr(data,"encode") else data

zlib.error: Error -3 while decompressing data: incorrect header check?

Not sure what to ask here, but this is the error I get.

Traceback (most recent call last):
File "rpatool.py", line 307, in
File "rpatool.py", line 30, in init
File "rpatool.py", line 176, in load
File "rpatool.py", line 66, in extract_indexes
File "encodings\zlib_codec.pyc", line 43, in zlib_decode
zlib.error: Error -3 while decompressing data: incorrect header check

Thanks

Can't remove directories from archives

The -d argument lets you delete files, but not whole directories. As a result, if I have to remove a folder from an archive, I have to extract it -> remove the folder -> create an archive again.
It would be nice to be able to delete directories just by typing a "\" after its name.

Problem with Kyrillic

#File "rpatool.py", line 385, in
UnicodeEncodeError: 'ascii' codec can't encode character u'\u0441' in position 38: ordinal not in range(128)

Does not work with Ren'py 6.99.12.4

On the latest version of Ren'py (6.99.12.4), the tool can extract data, but when it archives the data, the new .rpa file is not recognized/does not work :<.

How do I use this tool?

Ive tried using it though command prompt and through python, but niether have worked. Am i missing something?

I cannot extract the .extra content of a game in Ren'Py

I'm trying to extract some images from the game to translate into my language, but it gives error.

-desktop:~/Jogos/ExtraLife-0.5.9-pc/game$ python3 rpatool.py -x data.extra Traceback (most recent call last): File "rpatool.py", line 383, in <module> archive = RenPyArchive(archive, padlength=padding, key=key, version=version, verbose=arguments.verbose) File "rpatool.py", line 85, in __init__ self.load(file) File "rpatool.py", line 249, in load self.version = self.get_version() File "rpatool.py", line 96, in get_version magic = self.handle.readline().decode('utf-8') UnicodeDecodeError: 'utf-8' codec can't decode byte 0xcc in position 3: invalid continuation byte

Can you tell me if there is any solution for this?

permission error

Could not save archive file: [Errno 13] Permission denied: u'gui'

pickle5 problem?

I'm trying to unpack a Ren'Py 8.0.0 archive with the latest version. I get the following error:

Traceback (most recent call last): File "./rpatool", line 363, in <module> archive = RenPyArchive(archive, padlength=padding, key=key, version=version, verbose=arguments.verbose) File "./rpatool", line 65, in __init__ self.load(file) File "./rpatool", line 230, in load self.indexes = self.extract_indexes() File "./rpatool", line 111, in extract_indexes indexes = _unpickle(contents) File "./rpatool", line 24, in _unpickle return pickle.loads(data, encoding='latin1')

System is Debian Buster. I tried to force python3 and installing pickle5 through pip, but that gives the same error. May be I'm doing something wrong? Older archives works flawlessly.

Archives with index obfuscation won't extract correctly

I found an archive which rpatool was unable to extract correctly. All the files were listed and created but they all had a size of zero.

The first linein the file looked like this:

RPA-3.0 00000000030b3ce8 24242424 0b4dc0de

and after changing the following two lines of code:

            (offset, length) = self.indexes[filename][0]
            prefix = ''
        offset ^= 0xB4DC0DE
        length ^= 0xB4DC0DE

        self.verbose_print('Reading file {0} from data file {1}... (offset = {2}, length = {3} bytes)'.format(filename.encode('utf-8'), self.file, offset, length))

... to the read() method around line 136 the files did extract correctly. It should be easy to decode the actual value from the header.

Windows 7 64-bit, Python 2.7.

How to use this?

Hey im really sorry but im like completly new to everything and even though ive tried to read and figure out by myself what to do to not bother people i still cant get it right :(. Like I said I know nothing about this other than someone recommended me to use this to pack a rpa file. I have python installed and i put the rpatool file in the directory i wanted, i opened a command tab on the directory but when i put this command "rpatool -c archive.rpa archive" I get the error "'rpatool' is not recognized as an internal or external command,
operable program or batch file", I would really appreciate the help and sorry if this is a dumb question!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.