Last active
July 6, 2020 17:21
-
-
Save mariomadproductions/6f77d33876c2f0884be67e74c34b7e70 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
#Decode Nintendo GameCube/Wii/Wii U disc mastering codes | |
#To use interactive mode, pass '-i' as the argument instead of a mastering code. | |
from sys import argv | |
import string | |
from datetime import datetime | |
def print_decoded_mstr(input_var): | |
input_striped = input_var.strip() | |
if len(input_striped) != 8: | |
raise ValueError('Mastering code is the wrong length.') | |
factory = input_striped[0] | |
year = int('20' + input_striped[1:3]) | |
if not input_striped[3].isupper(): | |
raise ValueError('Month code is not uppercase.') | |
month = int(string.ascii_uppercase.index(input_striped[3]) + 1) | |
day = int(input_striped[4:6]) | |
date = datetime(year, month, day) | |
prodrun = input_striped[6:8].lstrip('0') | |
print('Factory: {}\nProduction Date: {}\nProduction Run: {}\n'\ | |
.format(factory,date.strftime('%d %B, %Y').lstrip('0'),prodrun)) | |
def interactive_mode(): | |
while True: | |
print_decoded_mstr(raw_input('Input: ')) | |
arg = argv[1] | |
try: | |
if arg == '-i': | |
interactive_mode() | |
else: | |
print_decoded_mstr(arg) | |
except IndexError: | |
print('No valid argument entered.') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment