User:Molldust/Scripts/MoveVO

Pyhton script for moving VO files

entry = ["‎batrider", "bat", "Batrider", True]
 * 1) HeroName, SetSpecifier, CategoryName, IsMainVoice
 * 1) entry = ["antimage", "anti", "Anti-Mage", True],
 * 2) entry = ["invoker", "kidvo", "Acolyte of the Lost Arts", False],

if (True): print("Gathering target pages") os.system("/opt/PyWikiBot/pwb.py listpages -cat:'{} audio responses‎' -ns:6 -format:3 > move_target.txt".format(entry[2]))
 * 1) Set to False if some files have the mp3 extension bug and remove the lines from move_todo.txt manually

print("Gathering move pairs pages") move_target = open('move_target.txt', 'r') move_todo = open('move_todo.txt', 'w') for line in move_target: line = re.sub(r"({})(.*?)\.mp3\s*".format(entry[1].capitalize), u"File:\\1\\2.mp3\nFile:vo {} {}\\2.mp3\n".format(entry[0],entry[1]), line) move_todo.write(line)

move_target.close move_todo.close

print("Move pages") os.system("/opt/PyWikiBot/pwb.py movepages -pairsfile:move_todo.txt -noredirect")

catregex = r"'.+{}[\s\_]audio[\s\_]responses.+'".format(entry[2]) catregex = re.sub(r"\s", u"[\s\_]", catregex) catregex = re.sub(r"\-", u"\-", catregex) catregex = re.sub(r"\'", u"\'", catregex)

catreplacement = u"''".format(entry[0] if entry[3] else (entry[0]+' '+entry[1]))

print("Adapt audio page contents") os.system("/opt/PyWikiBot/pwb.py replace -always -regex -dotall -cat:'{} audio responses' {} {} -summary:'Bot: Changing vo audio categories'".format( entry[2], catregex, catreplacement ))