Skip to content

Instantly share code, notes, and snippets.

@rwenz3l
Created September 13, 2017 06:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rwenz3l/a504ac6c84b050c83c7c2321714ab90f to your computer and use it in GitHub Desktop.
Save rwenz3l/a504ac6c84b050c83c7c2321714ab90f to your computer and use it in GitHub Desktop.
A Small Script to read Library Tags and Report Quality and Stuff
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