-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
53 lines (35 loc) · 1.5 KB
/
main.py
File metadata and controls
53 lines (35 loc) · 1.5 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from os import *
from functions import *
from config import *
import re
import sys
# number of songs to move to quantum folder, if it is empty
QUANTUM_SIZE = 100
# application initialization
# print style().h1() + ' === Otaguj si svoji hudbu === ' + style().normal()
# make sure all necessary directories exists
ensure_dirs = [MUSIC_OUTBOX_DIR, MUSIC_QUANTUM_DIR]
for single_dir in ensure_dirs:
if not os.path.exists(single_dir):
ensure_dir(single_dir)
print style().info() + 'folder ' + single_dir + ' does not exists, creating' + style().normal()
# check whether any files are in quantum dir
if not os.listdir(MUSIC_QUANTUM_DIR):
print
print style().h2() + 'QUANTUM is empty, filling it with files' + style().normal()
# list all files in inbox
quantum_files = []
for root, dirs, files in os.walk(MUSIC_INBOX_DIR):
for file in files:
if re.search(".mp3|.wma", file):
quantum_files.append(root + "\\" + file)
# take quantum from inbox
quantum_files = quantum_files[:QUANTUM_SIZE]
print 'Taking ' + str(len(quantum_files)) + ' files from inbox'
for quantum_file in quantum_files:
os.rename(quantum_file, MUSIC_QUANTUM_DIR + "\\" + os.path.basename(quantum_file))
sys.stdout.write('.')
print style().normal()
print style().normal() + 'Files moved from inbox to quantum'
else:
print style().normal() + 'There are files on quantum (' + str(len(os.listdir(MUSIC_QUANTUM_DIR))) + '), thus doing nothing'