values audio generator

 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
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
import sys
import xml.dom.minidom
from xml.dom.minidom import Node
from xml.dom.minidom import Document
files = os.listdir(".")
mp3s = filter(lambda x: x.endswith('.mp3'), files)
mp3s.sort()
doc = Document()
root = doc.createElement('resources')
doc.appendChild(root)
string_array = doc.createElement('string-array')
string_array.setAttribute('name', 'audio-book')
root.appendChild(string_array)
for i in mp3s:
filename = i.split('.')[0]
print(filename)
item = doc.createElement('item')
string_array.appendChild(item)
item_source = doc.createTextNode("@raw/" + filename)
item.appendChild(item_source)
doc.writexml(open('audio.xml', 'w'), encoding= 'utf-8', newl='\n')
#doc.writexml(open('chapter_' + file_count + xml_ext, 'w'), indent=" ", addindent=" ", newl='\n')
doc.unlink()