-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfind.flac.files.py
60 lines (53 loc) · 1.97 KB
/
find.flac.files.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import os
import logging
import sys
from mutagen.flac import FLAC
from flacfile import FLACFile
from lib import get_path_from_config
def main():
# set up for logging
LEVELS = {'debug': logging.DEBUG,
'info': logging.INFO,
'warning': logging.WARNING,
'error': logging.ERROR,
'critical': logging.CRITICAL,
}
if len(sys.argv) > 1:
level_name = sys.argv[1]
level = LEVELS.get(level_name, logging.NOTSET)
logging.basicConfig(
format='%(asctime)s - %(levelname)-8s - %(message)s\n',
level=level,
datefmt='%Y-%m-%d %H:%M:%S'
)
logger = logging.getLogger(__name__)
logger.debug('Entering main')
oversized_covers = 0
# pic_not_found = True
for root, dirs, files in os.walk('/home/robertm'):
# print(f'root: {root}')
for file in files:
if file.lower().endswith('.flac'):
f = os.path.join(root, file)
p = FLAC(f)
pics = p.pictures
if not pics:
print(f'no pic found: {f}')
# print(f'type(pics) == {type(pics)}')
# print(f'{pics}')
for i in pics:
size = sys.getsizeof(i.data)
if size > 150000:
print(f'{size:10,} --> {f}')
oversized_covers += 1
# if i.type == 3: # front cover
# print(f'found front cover - {i.desc}')
# print(f'sizeof data == {sys.getsizeof(i.data)}')
# with open("cover.jpg", "wb") as f:
# f.write(i.data)
flac = FLACFile(f)
print(f'ttl files processed: {FLACFile.ttl_files_processed}')
print(f'ttl file size: {FLACFile.ttl_file_size:,}')
print(f'ttl over sized covers: {oversized_covers}')
if __name__ == '__main__':
main()