Created
September 13, 2017 06:36
-
-
Save rwenz3l/a504ac6c84b050c83c7c2321714ab90f to your computer and use it in GitHub Desktop.
A Small Script to read Library Tags and Report Quality and Stuff
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys, os, re | |
import xml.etree.ElementTree as ET | |
from mutagen.mp3 import MP3 | |
''' | |
@param Uebergeben wird: "HostName" "/path/to/movies" "path/to/txt" | |
# HostName XServe = "XServe" | |
# Input XServe = "/Volumes/AUDIO" | |
# Output XServe = "/opt/syncthing/Repository/media" | |
# Call XServe = /usr/bin/python /_scripts/movieReport.py "XServe" "/Volumes/AUDIO" "/opt/syncthing/Repository/media" | |
''' | |
allowedExtensions = [".mp3"] | |
audioList = [] | |
unknownList = [] | |
os.chdir("/Volumes/AUDIO/Library/Artists") | |
for artist in os.listdir('.'): | |
if os.path.isfile(artist): | |
print("Skip: " + artist) | |
else: | |
artistPath = os.path.abspath(artist) | |
if os.path.isdir(artistPath): | |
for album in os.listdir(artistPath): | |
albumPath = artistPath + "/" + album | |
if not album.startswith('.') and os.path.isdir(albumPath): | |
bitrates = [] | |
for track in os.listdir(albumPath): | |
trackPath = os.path.join(albumPath, track) | |
if track.startswith('.'): | |
print() | |
else: | |
file = os.path.basename(trackPath) | |
fileName, fileExtension = os.path.splitext(file) | |
if fileExtension == ".mp3": | |
audio = MP3(trackPath) | |
bitrate = audio.info.bitrate / 1000 | |
bitrates.append(bitrate) | |
albumBitrate = 0 | |
length = len(bitrates) | |
if length > 0: | |
for rate in bitrates: | |
albumBitrate = albumBitrate + rate | |
albumBitrate = albumBitrate / length | |
print(artist + " - " + album + " [" + str(albumBitrate) + "]") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment