forked from manuelsc/rdr2-photomode-extractor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rdr2_photomode.py
40 lines (34 loc) · 1.17 KB
/
rdr2_photomode.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import os
import errno
if os.path.isfile('./rdr2dir.txt'):
f = open("rdr2dir.txt", "r")
rdr_dir = f.readlines()[0]
if len(rdr_dir.strip()) == 0:
rdr_dir = os.path.expanduser('~') + "\Documents\Rockstar Games\Red Dead Redemption 2\Profiles"
else:
rdr_dir = os.path.expanduser('~') + "\Documents\Rockstar Games\Red Dead Redemption 2\Profiles"
if os.path.isfile('./photodir.txt'):
f = open("photodir.txt", "r")
photo_dir = f.readlines()[0]
if len(photo_dir.strip()) == 0:
photo_dir = "Images\\"
else:
photo_dir = "Images\\"
def mkdir_p(path):
try:
os.makedirs(path)
except OSError as exc:
if exc.errno == errno.EEXIST and os.path.isdir(path):
pass
else:
raise
def convert(name, path):
with open(path + "/" + name, 'rb') as in_file:
with open(photo_dir +name + '.jpg', 'wb') as out_file:
out_file.write(in_file.read()[300:])
mkdir_p(photo_dir)
for folderName in os.listdir(rdr_dir):
folder = rdr_dir + "\\" + folderName
for filename in os.listdir(folder):
if(filename.startswith( 'PRDR' )):
convert(filename, folder)