-
Notifications
You must be signed in to change notification settings - Fork 1
/
STYLEfetch.py
31 lines (27 loc) · 1.04 KB
/
STYLEfetch.py
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
import os, operator
def getListOfFiles(dirName):
listOfFile = os.listdir(dirName)
allFiles = list()
for entry in listOfFile:
fullPath = os.path.join(dirName, entry)
if os.path.isdir(fullPath):
allFiles = allFiles + getListOfFiles(fullPath)
else:
allFiles.append(fullPath)
return allFiles
array_style_list = {}
dirName = '/home/theo546/Musique'
listOfFiles = getListOfFiles(dirName)
for file in listOfFiles:
filename, file_extension = os.path.splitext(file)
if file_extension == ".mp3" or file_extension == ".flac":
result = os.popen('ffprobe "' + file + '" 2>&1 | grep "GENRE" | sed "s/ //g"').read()
if result != '':
result = result.split(':')
result = result[1].strip('\n')
if result not in array_style_list:
array_style_list[result] = 0
array_style_list[result] = array_style_list[result] + 1
sorted_array = sorted(array_style_list.items(), key=operator.itemgetter(1))
sorted_array.reverse()
print(sorted_array)