Enviar arquivos para "/"
This commit is contained in:
parent
e360589a0f
commit
fed7ad551f
|
@ -0,0 +1,88 @@
|
|||
import xml.etree.ElementTree as ET
|
||||
|
||||
def parse_mmp_file(file_path):
|
||||
try:
|
||||
tree = ET.parse(file_path)
|
||||
root = tree.getroot()
|
||||
bpm = root.find('./head').attrib.get('bpm', 'N/A')
|
||||
tracks = root.findall('./song/trackcontainer/track')
|
||||
track_info = []
|
||||
|
||||
for track in tracks:
|
||||
track_name = track.attrib.get('name', 'N/A')
|
||||
track_type = track.attrib.get('type')
|
||||
instruments = []
|
||||
|
||||
# Para cada faixa, processar seus instrumenttracks
|
||||
for instrumenttrack in track.findall('./instrumenttrack'):
|
||||
instrument_info = {}
|
||||
|
||||
# Extraindo os atributos do <instrumenttrack>
|
||||
instrument_info['instrumenttrack'] = {
|
||||
'pitch': instrumenttrack.attrib.get('pitch', 'N/A'),
|
||||
'pan': instrumenttrack.attrib.get('pan', 'N/A'),
|
||||
'pitchrange': instrumenttrack.attrib.get('pitchrange', 'N/A'),
|
||||
'basenote': instrumenttrack.attrib.get('basenote', 'N/A'),
|
||||
'vol': instrumenttrack.attrib.get('vol', 'N/A'),
|
||||
'fxch': instrumenttrack.attrib.get('fxch', 'N/A'),
|
||||
'usemasterpitch': instrumenttrack.attrib.get('usemasterpitch', 'N/A')
|
||||
}
|
||||
|
||||
# Adicionando suporte para o plugin "malletsstk"
|
||||
instrument = instrumenttrack.find('.//instrument')
|
||||
if instrument is not None:
|
||||
instrument_name = instrument.attrib.get('name', 'N/A')
|
||||
instrument_info['instrument_name'] = instrument_name
|
||||
|
||||
# Verificar se é o "malletsstk" e extrair os atributos
|
||||
if instrument_name.lower() == "malletsstk":
|
||||
malletsstk = instrument.find('.//malletsstk') # Buscando pelo plugin "malletsstk"
|
||||
if malletsstk is not None:
|
||||
instrument_info['malletsstk'] = {}
|
||||
for key, value in malletsstk.attrib.items():
|
||||
instrument_info['malletsstk'][key] = value
|
||||
|
||||
# Extraindo os dados do <eldata>
|
||||
eldata = instrumenttrack.find('.//eldata')
|
||||
if eldata is not None:
|
||||
instrument_info['eldata'] = {
|
||||
'fwet': eldata.attrib.get('fwet', 'N/A'),
|
||||
'ftype': eldata.attrib.get('ftype', 'N/A'),
|
||||
'fcut': eldata.attrib.get('fcut', 'N/A'),
|
||||
'fres': eldata.attrib.get('fres', 'N/A')
|
||||
}
|
||||
|
||||
# Extraindo os elementos <elvol>, <elcut>, <elres>
|
||||
for el in ['elvol', 'elcut', 'elres']:
|
||||
el_element = eldata.find('.//' + el)
|
||||
if el_element is not None:
|
||||
instrument_info[el] = {}
|
||||
for key, value in el_element.attrib.items():
|
||||
instrument_info[el][key] = value
|
||||
|
||||
# Extraindo dados do <chordcreator>, <arpeggiator>, <midiport>, <fxchain>
|
||||
for tag_name in ['chordcreator', 'arpeggiator', 'midiport', 'fxchain']:
|
||||
tag_element = instrumenttrack.find('.//' + tag_name)
|
||||
if tag_element is not None:
|
||||
instrument_info[tag_name] = {}
|
||||
for key, value in tag_element.attrib.items():
|
||||
instrument_info[tag_name][key] = value
|
||||
|
||||
instruments.append(instrument_info)
|
||||
|
||||
# Adiciona a faixa com os instrumentos
|
||||
track_info.append({
|
||||
'track_name': track_name,
|
||||
'type': track_type,
|
||||
'instruments': instruments,
|
||||
})
|
||||
|
||||
return {
|
||||
'file': file_path,
|
||||
'bpm': bpm,
|
||||
'tracks': track_info
|
||||
}
|
||||
|
||||
except ET.ParseError as e:
|
||||
print(f'Erro ao analisar o arquivo XML {file_path}: {e}')
|
||||
return None
|
|
@ -0,0 +1,88 @@
|
|||
import xml.etree.ElementTree as ET
|
||||
|
||||
def parse_mmp_file(file_path):
|
||||
try:
|
||||
tree = ET.parse(file_path)
|
||||
root = tree.getroot()
|
||||
bpm = root.find('./head').attrib.get('bpm', 'N/A')
|
||||
tracks = root.findall('./song/trackcontainer/track')
|
||||
track_info = []
|
||||
|
||||
for track in tracks:
|
||||
track_name = track.attrib.get('name', 'N/A')
|
||||
track_type = track.attrib.get('type')
|
||||
instruments = []
|
||||
|
||||
# Para cada faixa, processar seus instrumenttracks
|
||||
for instrumenttrack in track.findall('./instrumenttrack'):
|
||||
instrument_info = {}
|
||||
|
||||
# Extraindo os atributos do <instrumenttrack>
|
||||
instrument_info['instrumenttrack'] = {
|
||||
'pitch': instrumenttrack.attrib.get('pitch', 'N/A'),
|
||||
'pan': instrumenttrack.attrib.get('pan', 'N/A'),
|
||||
'pitchrange': instrumenttrack.attrib.get('pitchrange', 'N/A'),
|
||||
'basenote': instrumenttrack.attrib.get('basenote', 'N/A'),
|
||||
'vol': instrumenttrack.attrib.get('vol', 'N/A'),
|
||||
'fxch': instrumenttrack.attrib.get('fxch', 'N/A'),
|
||||
'usemasterpitch': instrumenttrack.attrib.get('usemasterpitch', 'N/A')
|
||||
}
|
||||
|
||||
# Adicionando suporte para o plugin "monstro"
|
||||
instrument = instrumenttrack.find('.//instrument')
|
||||
if instrument is not None:
|
||||
instrument_name = instrument.attrib.get('name', 'N/A')
|
||||
instrument_info['instrument_name'] = instrument_name
|
||||
|
||||
# Verificar se é o "monstro" e extrair os atributos
|
||||
if instrument_name.lower() == "monstro":
|
||||
monstro = instrument.find('.//monstro') # Buscando pelo plugin "monstro"
|
||||
if monstro is not None:
|
||||
instrument_info['monstro'] = {}
|
||||
for key, value in monstro.attrib.items():
|
||||
instrument_info['monstro'][key] = value
|
||||
|
||||
# Extraindo os dados do <eldata>
|
||||
eldata = instrumenttrack.find('.//eldata')
|
||||
if eldata is not None:
|
||||
instrument_info['eldata'] = {
|
||||
'fwet': eldata.attrib.get('fwet', 'N/A'),
|
||||
'ftype': eldata.attrib.get('ftype', 'N/A'),
|
||||
'fcut': eldata.attrib.get('fcut', 'N/A'),
|
||||
'fres': eldata.attrib.get('fres', 'N/A')
|
||||
}
|
||||
|
||||
# Extraindo os elementos <elvol>, <elcut>, <elres>
|
||||
for el in ['elvol', 'elcut', 'elres']:
|
||||
el_element = eldata.find('.//' + el)
|
||||
if el_element is not None:
|
||||
instrument_info[el] = {}
|
||||
for key, value in el_element.attrib.items():
|
||||
instrument_info[el][key] = value
|
||||
|
||||
# Extraindo dados do <chordcreator>, <arpeggiator>, <midiport>, <fxchain>
|
||||
for tag_name in ['chordcreator', 'arpeggiator', 'midiport', 'fxchain']:
|
||||
tag_element = instrumenttrack.find('.//' + tag_name)
|
||||
if tag_element is not None:
|
||||
instrument_info[tag_name] = {}
|
||||
for key, value in tag_element.attrib.items():
|
||||
instrument_info[tag_name][key] = value
|
||||
|
||||
instruments.append(instrument_info)
|
||||
|
||||
# Adiciona a faixa com os instrumentos
|
||||
track_info.append({
|
||||
'track_name': track_name,
|
||||
'type': track_type,
|
||||
'instruments': instruments,
|
||||
})
|
||||
|
||||
return {
|
||||
'file': file_path,
|
||||
'bpm': bpm,
|
||||
'tracks': track_info
|
||||
}
|
||||
|
||||
except ET.ParseError as e:
|
||||
print(f'Erro ao analisar o arquivo XML {file_path}: {e}')
|
||||
return None
|
|
@ -0,0 +1,88 @@
|
|||
import xml.etree.ElementTree as ET
|
||||
|
||||
def parse_mmp_file(file_path):
|
||||
try:
|
||||
tree = ET.parse(file_path)
|
||||
root = tree.getroot()
|
||||
bpm = root.find('./head').attrib.get('bpm', 'N/A')
|
||||
tracks = root.findall('./song/trackcontainer/track')
|
||||
track_info = []
|
||||
|
||||
for track in tracks:
|
||||
track_name = track.attrib.get('name', 'N/A')
|
||||
track_type = track.attrib.get('type')
|
||||
instruments = []
|
||||
|
||||
# Para cada faixa, processar seus instrumenttracks
|
||||
for instrumenttrack in track.findall('./instrumenttrack'):
|
||||
instrument_info = {}
|
||||
|
||||
# Extraindo os atributos do <instrumenttrack>
|
||||
instrument_info['instrumenttrack'] = {
|
||||
'pitch': instrumenttrack.attrib.get('pitch', 'N/A'),
|
||||
'pan': instrumenttrack.attrib.get('pan', 'N/A'),
|
||||
'pitchrange': instrumenttrack.attrib.get('pitchrange', 'N/A'),
|
||||
'basenote': instrumenttrack.attrib.get('basenote', 'N/A'),
|
||||
'vol': instrumenttrack.attrib.get('vol', 'N/A'),
|
||||
'fxch': instrumenttrack.attrib.get('fxch', 'N/A'),
|
||||
'usemasterpitch': instrumenttrack.attrib.get('usemasterpitch', 'N/A')
|
||||
}
|
||||
|
||||
# Adicionando suporte para o plugin "nes"
|
||||
instrument = instrumenttrack.find('.//instrument')
|
||||
if instrument is not None:
|
||||
instrument_name = instrument.attrib.get('name', 'N/A')
|
||||
instrument_info['instrument_name'] = instrument_name
|
||||
|
||||
# Verificar se é o "nes" e extrair os atributos
|
||||
if instrument_name.lower() == "nes":
|
||||
nescaline = instrument.find('.//nes') # Buscando pelo plugin "nes"
|
||||
if nescaline is not None:
|
||||
instrument_info['nescaline'] = {}
|
||||
for key, value in nescaline.attrib.items():
|
||||
instrument_info['nescaline'][key] = value
|
||||
|
||||
# Extraindo os dados do <eldata>
|
||||
eldata = instrumenttrack.find('.//eldata')
|
||||
if eldata is not None:
|
||||
instrument_info['eldata'] = {
|
||||
'fwet': eldata.attrib.get('fwet', 'N/A'),
|
||||
'ftype': eldata.attrib.get('ftype', 'N/A'),
|
||||
'fcut': eldata.attrib.get('fcut', 'N/A'),
|
||||
'fres': eldata.attrib.get('fres', 'N/A')
|
||||
}
|
||||
|
||||
# Extraindo os elementos <elvol>, <elcut>, <elres>
|
||||
for el in ['elvol', 'elcut', 'elres']:
|
||||
el_element = eldata.find('.//' + el)
|
||||
if el_element is not None:
|
||||
instrument_info[el] = {}
|
||||
for key, value in el_element.attrib.items():
|
||||
instrument_info[el][key] = value
|
||||
|
||||
# Extraindo dados do <chordcreator>, <arpeggiator>, <midiport>, <fxchain>
|
||||
for tag_name in ['chordcreator', 'arpeggiator', 'midiport', 'fxchain']:
|
||||
tag_element = instrumenttrack.find('.//' + tag_name)
|
||||
if tag_element is not None:
|
||||
instrument_info[tag_name] = {}
|
||||
for key, value in tag_element.attrib.items():
|
||||
instrument_info[tag_name][key] = value
|
||||
|
||||
instruments.append(instrument_info)
|
||||
|
||||
# Adiciona a faixa com os instrumentos
|
||||
track_info.append({
|
||||
'track_name': track_name,
|
||||
'type': track_type,
|
||||
'instruments': instruments,
|
||||
})
|
||||
|
||||
return {
|
||||
'file': file_path,
|
||||
'bpm': bpm,
|
||||
'tracks': track_info
|
||||
}
|
||||
|
||||
except ET.ParseError as e:
|
||||
print(f'Erro ao analisar o arquivo XML {file_path}: {e}')
|
||||
return None
|
|
@ -0,0 +1,88 @@
|
|||
import xml.etree.ElementTree as ET
|
||||
|
||||
def parse_mmp_file(file_path):
|
||||
try:
|
||||
tree = ET.parse(file_path)
|
||||
root = tree.getroot()
|
||||
bpm = root.find('./head').attrib.get('bpm', 'N/A')
|
||||
tracks = root.findall('./song/trackcontainer/track')
|
||||
track_info = []
|
||||
|
||||
for track in tracks:
|
||||
track_name = track.attrib.get('name', 'N/A')
|
||||
track_type = track.attrib.get('type')
|
||||
instruments = []
|
||||
|
||||
# Para cada faixa, processar seus instrumenttracks
|
||||
for instrumenttrack in track.findall('./instrumenttrack'):
|
||||
instrument_info = {}
|
||||
|
||||
# Extraindo os atributos do <instrumenttrack>
|
||||
instrument_info['instrumenttrack'] = {
|
||||
'pitch': instrumenttrack.attrib.get('pitch', 'N/A'),
|
||||
'pan': instrumenttrack.attrib.get('pan', 'N/A'),
|
||||
'pitchrange': instrumenttrack.attrib.get('pitchrange', 'N/A'),
|
||||
'basenote': instrumenttrack.attrib.get('basenote', 'N/A'),
|
||||
'vol': instrumenttrack.attrib.get('vol', 'N/A'),
|
||||
'fxch': instrumenttrack.attrib.get('fxch', 'N/A'),
|
||||
'usemasterpitch': instrumenttrack.attrib.get('usemasterpitch', 'N/A')
|
||||
}
|
||||
|
||||
# Adicionando suporte para o plugin "OPL2" (OpulenZ)
|
||||
instrument = instrumenttrack.find('.//instrument')
|
||||
if instrument is not None:
|
||||
instrument_name = instrument.attrib.get('name', 'N/A')
|
||||
instrument_info['instrument_name'] = instrument_name
|
||||
|
||||
# Verificar se é o "OPL2" (OpulenZ) e extrair os atributos
|
||||
if instrument_name.lower() == "opl2":
|
||||
opl2 = instrument.find('.//OPL2') # Buscando pelo plugin "OPL2"
|
||||
if opl2 is not None:
|
||||
instrument_info['opl2'] = {}
|
||||
for key, value in opl2.attrib.items():
|
||||
instrument_info['opl2'][key] = value
|
||||
|
||||
# Extraindo os dados do <eldata>
|
||||
eldata = instrumenttrack.find('.//eldata')
|
||||
if eldata is not None:
|
||||
instrument_info['eldata'] = {
|
||||
'fwet': eldata.attrib.get('fwet', 'N/A'),
|
||||
'ftype': eldata.attrib.get('ftype', 'N/A'),
|
||||
'fcut': eldata.attrib.get('fcut', 'N/A'),
|
||||
'fres': eldata.attrib.get('fres', 'N/A')
|
||||
}
|
||||
|
||||
# Extraindo os elementos <elvol>, <elcut>, <elres>
|
||||
for el in ['elvol', 'elcut', 'elres']:
|
||||
el_element = eldata.find('.//' + el)
|
||||
if el_element is not None:
|
||||
instrument_info[el] = {}
|
||||
for key, value in el_element.attrib.items():
|
||||
instrument_info[el][key] = value
|
||||
|
||||
# Extraindo dados do <chordcreator>, <arpeggiator>, <midiport>, <fxchain>
|
||||
for tag_name in ['chordcreator', 'arpeggiator', 'midiport', 'fxchain']:
|
||||
tag_element = instrumenttrack.find('.//' + tag_name)
|
||||
if tag_element is not None:
|
||||
instrument_info[tag_name] = {}
|
||||
for key, value in tag_element.attrib.items():
|
||||
instrument_info[tag_name][key] = value
|
||||
|
||||
instruments.append(instrument_info)
|
||||
|
||||
# Adiciona a faixa com os instrumentos
|
||||
track_info.append({
|
||||
'track_name': track_name,
|
||||
'type': track_type,
|
||||
'instruments': instruments,
|
||||
})
|
||||
|
||||
return {
|
||||
'file': file_path,
|
||||
'bpm': bpm,
|
||||
'tracks': track_info
|
||||
}
|
||||
|
||||
except ET.ParseError as e:
|
||||
print(f'Erro ao analisar o arquivo XML {file_path}: {e}')
|
||||
return None
|
|
@ -0,0 +1,88 @@
|
|||
import xml.etree.ElementTree as ET
|
||||
|
||||
def parse_mmp_file(file_path):
|
||||
try:
|
||||
tree = ET.parse(file_path)
|
||||
root = tree.getroot()
|
||||
bpm = root.find('./head').attrib.get('bpm', 'N/A')
|
||||
tracks = root.findall('./song/trackcontainer/track')
|
||||
track_info = []
|
||||
|
||||
for track in tracks:
|
||||
track_name = track.attrib.get('name', 'N/A')
|
||||
track_type = track.attrib.get('type')
|
||||
instruments = []
|
||||
|
||||
# Para cada faixa, processar seus instrumenttracks
|
||||
for instrumenttrack in track.findall('./instrumenttrack'):
|
||||
instrument_info = {}
|
||||
|
||||
# Extraindo os atributos do <instrumenttrack>
|
||||
instrument_info['instrumenttrack'] = {
|
||||
'pitch': instrumenttrack.attrib.get('pitch', 'N/A'),
|
||||
'pan': instrumenttrack.attrib.get('pan', 'N/A'),
|
||||
'pitchrange': instrumenttrack.attrib.get('pitchrange', 'N/A'),
|
||||
'basenote': instrumenttrack.attrib.get('basenote', 'N/A'),
|
||||
'vol': instrumenttrack.attrib.get('vol', 'N/A'),
|
||||
'fxch': instrumenttrack.attrib.get('fxch', 'N/A'),
|
||||
'usemasterpitch': instrumenttrack.attrib.get('usemasterpitch', 'N/A')
|
||||
}
|
||||
|
||||
# Adicionando suporte para o plugin "organic"
|
||||
instrument = instrumenttrack.find('.//instrument')
|
||||
if instrument is not None:
|
||||
instrument_name = instrument.attrib.get('name', 'N/A')
|
||||
instrument_info['instrument_name'] = instrument_name
|
||||
|
||||
# Verificar se é o "organic" e extrair os atributos
|
||||
if instrument_name.lower() == "organic":
|
||||
organic = instrument.find('.//organic') # Buscando pelo plugin "organic"
|
||||
if organic is not None:
|
||||
instrument_info['organic'] = {}
|
||||
for key, value in organic.attrib.items():
|
||||
instrument_info['organic'][key] = value
|
||||
|
||||
# Extraindo os dados do <eldata>
|
||||
eldata = instrumenttrack.find('.//eldata')
|
||||
if eldata is not None:
|
||||
instrument_info['eldata'] = {
|
||||
'fwet': eldata.attrib.get('fwet', 'N/A'),
|
||||
'ftype': eldata.attrib.get('ftype', 'N/A'),
|
||||
'fcut': eldata.attrib.get('fcut', 'N/A'),
|
||||
'fres': eldata.attrib.get('fres', 'N/A')
|
||||
}
|
||||
|
||||
# Extraindo os elementos <elvol>, <elcut>, <elres>
|
||||
for el in ['elvol', 'elcut', 'elres']:
|
||||
el_element = eldata.find('.//' + el)
|
||||
if el_element is not None:
|
||||
instrument_info[el] = {}
|
||||
for key, value in el_element.attrib.items():
|
||||
instrument_info[el][key] = value
|
||||
|
||||
# Extraindo dados do <chordcreator>, <arpeggiator>, <midiport>, <fxchain>
|
||||
for tag_name in ['chordcreator', 'arpeggiator', 'midiport', 'fxchain']:
|
||||
tag_element = instrumenttrack.find('.//' + tag_name)
|
||||
if tag_element is not None:
|
||||
instrument_info[tag_name] = {}
|
||||
for key, value in tag_element.attrib.items():
|
||||
instrument_info[tag_name][key] = value
|
||||
|
||||
instruments.append(instrument_info)
|
||||
|
||||
# Adiciona a faixa com os instrumentos
|
||||
track_info.append({
|
||||
'track_name': track_name,
|
||||
'type': track_type,
|
||||
'instruments': instruments,
|
||||
})
|
||||
|
||||
return {
|
||||
'file': file_path,
|
||||
'bpm': bpm,
|
||||
'tracks': track_info
|
||||
}
|
||||
|
||||
except ET.ParseError as e:
|
||||
print(f'Erro ao analisar o arquivo XML {file_path}: {e}')
|
||||
return None
|
Loading…
Reference in New Issue