annotate msvpvf.py @ 12:59501244594c

Happy new year!
author Paper <37962225+mrpapersonic@users.noreply.github.com>
date Fri, 04 Feb 2022 23:11:17 -0500
parents 2ec81711f0c7
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
1 import sys, argparse, os
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
2
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
3 def prog_type(byte):
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
4 if byte == 0xF6:
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
5 return "Movie Studio"
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
6 elif byte == 0xEF:
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
7 return "VEGAS Pro"
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
8 else:
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
9 return "Unknown"
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
10
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
11 def type_hex(type):
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
12 if type == "vf" or type == 1:
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
13 return "MS", [0xF6, 0x1B, 0x3C, 0x53, 0x35, 0xD6, 0xF3, 0x43, 0x8A, 0x90, 0x64, 0xB8, 0x87, 0x23, 0x1F, 0x7F]
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
14 elif type == "veg" or type == 0:
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
15 return "PRO", [0xEF, 0x29, 0xC4, 0x46, 0x4A, 0x90, 0xD2, 0x11, 0x87, 0x22, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A]
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
16 else:
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
17 return
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
18
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
19 def main(args):
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
20 if args.input:
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
21 inputfile = args.input
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
22 if os.path.exists(inputfile):
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
23 with open(inputfile, "rb") as fp:
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
24 test = bytearray(fp.read())
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
25 else:
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
26 print("Input file doesn't exist!")
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
27 exit()
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
28 project = prog_type(test[0x18])
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
29 print("Project file version: " + project + " " + str(test[0x46]) + ".0")
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
30 if not args.version:
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
31 answer = ""
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
32 else:
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
33 answer = args.version
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
34 while answer not in ["8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18"]:
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
35 answer = str(input("Which version of VEGAS would you like it to be spoofed to? [8-18]: "))
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
36 if not args.type:
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
37 answer2 = ""
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
38 while answer2 not in ["veg", "vf"]:
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
39 answer2 = input("Would you like it to be VEGAS Pro or Movie Studio? [veg,vf]: ").lower()
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
40 else:
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
41 answer2 = args.type
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
42 filename_prefix, typehex = type_hex(answer2)
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
43 test[0x18:0x27] = typehex
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
44 test[0x46] = int(answer)
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
45 filename_wo_ext = os.path.basename(os.path.splitext(inputfile)[0])
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
46 if args.output:
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
47 outputfile = args.output
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
48 else:
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
49 outputfile = os.path.abspath(os.path.dirname(inputfile)) + "/" + filename_prefix + "_V" + answer + "_" + str(filename_wo_ext) + "." + answer2
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
50 with open(outputfile, 'wb') as target:
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
51 target.write(test)
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
52 if __name__ == "__main__":
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
53 parser = argparse.ArgumentParser()
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
54 parser.add_argument('-i', '--input', help="input file", metavar='<input>', required=True)
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
55 parser.add_argument('-o', '--output', help="output file, defaults to '(MS,VEG)_(version)_(original name).(vf,veg)'", metavar='<output>')
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
56 parser.add_argument('-v', '--version', help="output file version", metavar='<version>')
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
57 parser.add_argument('-t', '--type', help="output file type, vf/veg", metavar='<type>')
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
58 args = parser.parse_args()
2ec81711f0c7 Move python files to this repo
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
59 main(args)