Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python3
- """
- Script to extract all audio from downloaded content of Star Craft II
- This module is needed:
- https://github.com/eagleflo/mpyq
- """
- from pathlib import Path
- from zlib import error as zlib_error
- from mpyq import MPQArchive
- FILE_TYPES = ('.mp3', '.ogg')
- def get_sound(path):
- path = Path(path)
- for file in path.rglob('*.s2m?'):
- try:
- mpq = MPQArchive(file)
- # print(f'Processing {file.name}')
- except ValueError:
- continue
- for content in map(bytes.decode, mpq.files):
- if any(content.endswith(ext) for ext in FILE_TYPES):
- try:
- mpq.extract_files(content)
- except (RuntimeError, zlib_error):
- # print(f'Error with decompression: {file.name}')
- pass
- my_path = "Games/starcraft-ii/drive_c/ProgramData/Blizzard Entertainment/Battle.net/Cache"
- get_sound(my_path)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement