Skip to content

Random Access RAR: parse and extract RAR archives efficiently without complete access to the file

License

Notifications You must be signed in to change notification settings

eliasbenb/RARAR.py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RARAR.py

RARAR is a Python package that enables random access to RAR archives, allowing you to list and extract files without downloading the entire archive.

While the main use case for RARAR is to access RAR archives stored over HTTP, it can also be used to access any file-like object that supports seeking and reading. This includes local files, in-memory files, and other file-like objects.

Installation

pip install git+https://github.com/eliasbenb/RARAR.py.git

Features

  • Remote RAR Access: Read RAR archives directly from URLs without downloading the entire file
  • Random Access: Extract specific files from an archive efficiently
  • Support for Multiple Sources: Works with local file paths, file-like objects, and HTTP URLs

TODO

Important

Unfortunately, due to limitations in the RAR format, RARAR cannot currently access RAR archives that are either:

  • Compressed with any compression method other than Store
  • Encrypted
  • Multi-part

Additionally, if using an HTTP URL, the server must support Range requests to allow for partial downloads.

  • Look into support compression methods other than Store
  • TUI for the CLI
  • Support for directory downloads
  • Create file tree UI for CLI's list output

Python Usage

Listing Contents of a RAR Archive

from rarar import RarReader

source = "https://example.com/archive.rar"  # URL, file, or file-like object
reader = RarReader(source) 
for file in reader:
    print(f"{file.name} - {file.size} bytes")

Extracting a File from a RAR Archive

from rarar import RarReader

source = "./archives/archive.rar"  # URL, file, or file-like object
reader = RarReader("https://example.com/archive.rar")
file = next(reader) # Get the first file in the archive
reader.extract(file, output_path="/path/to/save/file.dat")

CLI Usage

You can also use the RARAR package via the command-line interface to list and extract files from a RAR archive.

usage: rarar [-h] [--debug] {list,extract} ...

Random Access RAR Reader - Access RAR archives without loading the entire file into memory

positional arguments:
  {list,extract}  Command to execute
    list          List contents of a RAR archive
    extract       Extract files from a RAR archive

options:
  -h, --help      show this help message and exit
  --debug         Enable debug logging

Listing Contents of a RAR Archive

rarar list [--json] source

Extracting a File from a RAR Archive

rarar extract [-o OUTPUT] source [file_indices ...]

About

Random Access RAR: parse and extract RAR archives efficiently without complete access to the file

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published