libray.py 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #!/usr/bin/env python3
  2. # -*- coding: utf8 -*-
  3. # libray - Libre Blu-Ray PS3 ISO Tool
  4. # Copyright © 2018 - 2024 Nichlas Severinsen
  5. #
  6. # This file is part of libray.
  7. #
  8. # libray is free software: you can redistribute it and/or modify
  9. # it under the terms of the GNU General Public License as published by
  10. # the Free Software Foundation, either version 3 of the License, or
  11. # (at your option) any later version.
  12. #
  13. # libray is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU General Public License
  19. # along with libray. If not, see <https://www.gnu.org/licenses/>.
  20. import argparse
  21. try:
  22. from libray import core
  23. except ImportError:
  24. import core
  25. if __name__ == '__main__':
  26. parser = argparse.ArgumentParser(
  27. description='A Libre (FLOSS) Python application for unencrypting, extracting, repackaging, and encrypting PS3 ISOs')
  28. required = parser.add_mutually_exclusive_group(required=True)
  29. required.add_argument('-i', '--iso', dest='iso', type=str, help='Path to .iso file or stream')
  30. required.add_argument('-k', '--ird', dest='ird', type=str, help='Path to .ird file', default='')
  31. optional = parser.add_argument_group('optional arguments')
  32. optional.add_argument('-o', '--output', dest='output', type=str, help='Output filename', default='')
  33. optional.add_argument('-d', '--decryption-key', dest='decryption_key', type=str, help='Manually specify key', default='')
  34. optional.add_argument('-v', '--verbose', dest='verbose', help='Increase verbosity', action='count')
  35. optional.add_argument('-q', '--quiet', dest='quiet', help='Quiet mode, only prints on error', action='store_true')
  36. # -e is reserved for "extract" so re-encrypt is "-r"
  37. optional.add_argument('-r', '--re-encrypt', dest='reencrypt', help='Re-encrypt .iso', action='store_true')
  38. optional.add_argument('-c', '--checksum', dest='checksum', help='Allow fallback to CRC32 checksum (disabled by default)', action='store_true')
  39. optional.add_argument('-t', '--checksum-timeout', dest='checksum_timeout', type=int, help='How many seconds to wait for CRC32 checksum (default 15)', default=15)
  40. optional.add_argument('--info', dest='info', action='store_true', help='Print info about .iso or .ird, then quit.')
  41. args = parser.parse_args()
  42. if args.info:
  43. core.info(args)
  44. if not args.iso:
  45. core.error('No .iso file given. Use -i/--iso path/to/file.iso')
  46. if args.reencrypt:
  47. core.encrypt(args)
  48. else:
  49. core.decrypt(args)