1
0
Fork 0

Add: py script to get stats of music files

This commit is contained in:
Aroy-Art 2024-09-21 23:07:42 +02:00
parent 0b832a3364
commit e150e47b91
Signed by: Aroy
GPG key ID: DB9689E9391DD156

View file

@ -0,0 +1,43 @@
import os
import sys
import mutagen
if len(sys.argv) != 2:
print("Usage: python3 MusicLibVisualizing/main.py <path_to_your_music_library>")
sys.exit(1)
music_library = sys.argv[1]
music_data = []
from tqdm import tqdm
for root, dirs, files in tqdm(list(os.walk(music_library)), desc="Walking folders", unit="folders"):
for file in tqdm(files, desc=f"Processing folder {root}", unit="files"):
if file.endswith(('.mp3', '.flac', '.opus')):
try:
audio = mutagen.File(os.path.join(root, file))
#print(f"Processing {file}")
#print(audio.info)
music_data.append({
"title": audio.get('title', ['Unknown'])[0],
"artist": audio.get('artist', ['Unknown'])[0],
"album": audio.get('album', ['Unknown'])[0],
"genre": audio.get('genre', ['Unknown'])[0],
"length": audio.info.length,
#"bitrate": audio.info.bitrate
})
except Exception as e:
print(f"Error processing {file}: {e}")
print(f"Found a total of {len(music_data)} files.")
import pandas as pd
df = pd.DataFrame(music_data)
import seaborn as sns
import matplotlib.pyplot as plt