From 4cec6b92e5cb80f239f701a017d7ec713e62326e Mon Sep 17 00:00:00 2001 From: Gabriel Corona Date: Sat, 6 Jul 2019 23:15:10 +0200 Subject: [PATCH] Fix reading directly from the disc Getting the file size with os.stat() does not work with block devices. You can now: libray -i /dev/sg0 -o test.iso --- README.md | 13 ++++++++++--- libray/core.py | 5 ++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0b9cb68..70ec3ac 100644 --- a/README.md +++ b/README.md @@ -56,10 +56,17 @@ required arguments: -i ISO, --iso ISO Path to .iso file ``` -Rip a PS3 to .ISO with an appropriate blu-ray drive: https://rpcs3.net/quickstart (see "Compatible Blu-ray disc drives section"). -Then just feed the .ISO to libray which will try to download an IRD decryption file for your iso. +You need to use an appropriate blu-ray drive: https://rpcs3.net/quickstart (see "Compatible Blu-ray disc drives section"). -Example: +On some systems (eg. Linux), you can decrypt directly from the disc. + +``` +libray -i /dev/sr0 -o ps3_game_decrypted.iso +``` + +Libray will try to download an IRD decryption file for your iso: + +Alternatively, you can first rip the disc to an ISO file and then decrypt from the ISO file: ``` libray -i ps3_game.iso -o ps3_game_decrypted.iso diff --git a/libray/core.py b/libray/core.py index 9d34a5e..703ff5f 100644 --- a/libray/core.py +++ b/libray/core.py @@ -58,7 +58,10 @@ ISO_IV = to_bytes("69474772af6fdab342743aefaa186287") def filesize(filename): """Get size of a file in bytes from os.stat""" - return os.stat(filename).st_size + try: + return open(filename, "rb").seek(0, 2) + except: + return os.stat(filename).st_size def read_seven_bit_encoded_int(fileobj, order):