eyed3 developer on retainer: eyed3.load() returns None for unrecognized file types; AudioFile.tag returns None for untagged MP3s; AttributeError masked by catch-all exception handler; 7 600 podcast episodes per month fail metadata write silently — initTag() fix — 3 weeks — eyeD3 developer on monthly retainer
eyeD3 0.9.7 • Python 3.9; eyed3.load(path); AudioFile.tag; audio_file.initTag() • Northfield Eyed3 Ltd. (podcast metadata normalization service; 60,000 MP3 episodes/month from 1,200 independent podcasters; eyed3.load(path) returns None for 400 non-MP3 files/month mislabeled .mp3; AudioFile.tag returns None for 7,200 valid MP3s/month with no existing ID3 header (Zoom H6 exports, Audacity exports without tags); AttributeError: 'NoneType' object has no attribute 'tag' and 'title'; catch-all AttributeError handler logs “tag read failed” and continues; 7,600 episodes/month fail metadata write silently for 3 weeks; fix: if audio_file is None: continue; if audio_file.tag is None: audio_file.initTag(version=eyed3.id3.ID3_V2_4); 2.0h retainer engagement)
Northfield Eyed3 Ltd. built a podcast metadata normalization service for a podcast aggregator platform that accepted MP3 episode uploads from 1,200 independent podcasters. Each submitted episode was processed by a normalization pipeline that read existing ID3 tags using eyeD3, applied canonical formatting rules (standardizing title capitalization, filling missing artist from channel metadata, normalizing genre to one of 15 approved genre strings, embedding a 300×300 cover art image), and wrote the corrected tags back to the file on disk before the episode was indexed by the aggregator’s search engine. The pipeline called eyed3.load(path) for each uploaded file, accessed audio_file.tag.title, audio_file.tag.artist, audio_file.tag.album, and audio_file.tag.genre, applied the normalization rules, wrote back via audio_file.tag.save(). The exception handling wrapped each episode in a try/except block that caught AttributeError and logged “tag read failed: {path}” before continuing to the next file — a reasonable handler for tag fields that might not exist on certain ID3 versions, but dangerously broad for a pipeline where two distinct None-return failure modes produced the same exception class.
Two distinct failure modes were silently consuming episodes. The first: 400 of the 60,000 monthly uploads were not MP3 files at all — they were WAV, FLAC, or OGG audio files submitted with a .mp3 extension by podcasters who renamed files without re-encoding. eyed3.load() reads the file’s magic bytes and structure to identify the format; for non-MP3 files, it returns None instead of raising an exception. The pipeline accessed audio_file.tag on this None return without checking, raising AttributeError: 'NoneType' object has no attribute 'tag'. The second: 7,200 of the monthly uploads were valid MP3 files recorded by hardware devices — Zoom H5 and H6 field recorders, some older Audacity exports, and MP3 files processed by a batch converter tool that stripped ID3 headers as a side effect. MP3 audio does not require ID3 tags; the MPEG audio stream is valid without any ID3 structure. For these files, eyed3.load() correctly returned an AudioFile instance, but AudioFile.tag returned None because there was no ID3 header to parse. The pipeline then executed audio_file.tag.title = normalized_title, raising AttributeError: 'NoneType' object has no attribute 'title'. Both AttributeError instances — from the first and second failure modes — were indistinguishable by the catch-all handler, which logged “tag read failed: {path}” and moved on. 7,600 episodes per month accumulated with no metadata. The aggregator’s search index showed these episodes with blank titles and no author attribution. Podcasters began opening support tickets in week 2 (“my episodes aren’t showing up in search”, “the aggregator isn’t showing my podcast name”); the support team classified them as “user error — submit correctly tagged MP3” for one additional week before an engineer reproduced the issue with a Zoom H6 export and confirmed audio_file.tag was None for a valid, ffprobe-verified MP3 file.
The annotated buggy and fixed eyeD3 metadata normalization pipeline, with both None-check patterns:
# Northfield Eyed3 Ltd. — eyeD3 0.9.7 None-return handling
# eyeD3 0.9.7; Python 3.9; podcast metadata normalization pipeline
# 60,000 MP3 episodes/month; 1,200 independent podcasters
# Two distinct None-return failure modes:
# (1) eyed3.load(path) returns None for non-MP3 files mislabeled .mp3
# → AttributeError: 'NoneType' has no attribute 'tag'
# (2) audio_file.tag returns None for valid MP3 with no ID3 header
# → AttributeError: 'NoneType' has no attribute 'title'
# Both masked by catch-all AttributeError handler; 7,600 episodes/month fail silently
import eyed3
import eyed3.id3
APPROVED_GENRES = {
'arts', 'business', 'comedy', 'education', 'fiction',
'health', 'history', 'music', 'news', 'religion',
'science', 'society', 'sports', 'technology', 'true-crime',
}
# ── BUGGY normalization pipeline ─────────────────────────────────────────────
def normalize_episode_buggy(path: str, channel_name: str,
cover_art_bytes: bytes | None = None) -> bool:
"""
BUG (1): eyed3.load() returns None for non-MP3 files.
Accessing audio_file.tag on None raises AttributeError immediately.
BUG (2): AudioFile.tag returns None for MP3s with no ID3 header.
Accessing audio_file.tag.title raises AttributeError on tag write.
Both AttributeErrors caught by generic handler; logged as 'tag read failed'.
7,600 episodes/month fail silently: tags never written, search index empty.
"""
try:
audio_file = eyed3.load(path)
# BUG: no None check — raises AttributeError if eyed3.load() returned None
normalized_title = audio_file.tag.title.strip().title() if audio_file.tag.title else channel_name
normalized_artist = audio_file.tag.artist or channel_name
raw_genre = (audio_file.tag.genre.name if audio_file.tag.genre else None) or ''
normalized_genre = raw_genre.lower() if raw_genre.lower() in APPROVED_GENRES else 'technology'
audio_file.tag.title = normalized_title
# BUG: if audio_file.tag is None, this raises AttributeError
audio_file.tag.artist = normalized_artist
audio_file.tag.album = channel_name
audio_file.tag.genre = normalized_genre
if cover_art_bytes:
audio_file.tag.images.set(
type_=eyed3.id3.frames.ImageFrame.FRONT_COVER,
img_data=cover_art_bytes,
mime_type='image/jpeg'
)
audio_file.tag.save()
return True
except AttributeError:
# Catches BOTH NoneType.tag and NoneType.title without distinction.
# Swallows both failure modes into a single log line.
import logging
logging.warning(f"tag read failed: {path}")
return False
# ── FIXED normalization pipeline ─────────────────────────────────────────────
def normalize_episode_fixed(path: str, channel_name: str,
cover_art_bytes: bytes | None = None) -> bool:
"""
FIX: check for None at both stages explicitly.
Stage 1: eyed3.load(path) → None means unrecognized file format.
Skip the file and log the specific failure cause.
Do NOT attempt tag access on None.
Stage 2: audio_file.tag → None means valid MP3 with no ID3 header.
Call audio_file.initTag(version=eyed3.id3.ID3_V2_4) to create
a new empty ID3v2.4 tag before writing any tag fields.
Do NOT skip; these files should receive new tags.
"""
import logging
# Stage 1: check that eyed3 recognized the file as an MP3.
audio_file = eyed3.load(path)
if audio_file is None:
logging.error(
f"eyed3: file not recognized as MP3 — skipping: {path}. "
f"Check actual format with: file '{path}' or ffprobe '{path}'. "
f"Non-MP3 audio (WAV, FLAC, OGG) with .mp3 extension causes this."
)
return False
# Stage 2: check that the MP3 has an ID3 tag (may be absent even for valid MP3).
if audio_file.tag is None:
# MP3 is valid but has no ID3 header.
# Create a new empty ID3v2.4 tag before writing.
# Common causes: Zoom H5/H6 field recorder exports, Audacity exports
# without 'Write ID3v2.3 tags' checked, batch converters that strip tags.
audio_file.initTag(version=eyed3.id3.ID3_V2_4)
logging.info(f"eyed3: no existing ID3 tag — initialized new ID3v2.4 tag: {path}")
# Now audio_file.tag is guaranteed non-None. Write normalized fields.
try:
existing_title = audio_file.tag.title
normalized_title = existing_title.strip().title() if existing_title else channel_name
existing_artist = audio_file.tag.artist
normalized_artist = existing_artist or channel_name
existing_genre = audio_file.tag.genre
raw_genre = existing_genre.name.lower() if existing_genre else ''
normalized_genre = raw_genre if raw_genre in APPROVED_GENRES else 'technology'
audio_file.tag.title = normalized_title
audio_file.tag.artist = normalized_artist
audio_file.tag.album = channel_name
audio_file.tag.genre = normalized_genre
if cover_art_bytes:
audio_file.tag.images.set(
type_=eyed3.id3.frames.ImageFrame.FRONT_COVER,
img_data=cover_art_bytes,
mime_type='image/jpeg'
)
audio_file.tag.save()
return True
except Exception as exc:
# Remaining exceptions (IOError on read-only mount, etc.) are logged
# with the specific exception type — not a generic AttributeError catch.
logging.error(f"eyed3: tag write failed for {path}: {type(exc).__name__}: {exc}")
return False
# ── Corpus audit helper ───────────────────────────────────────────────────────
def audit_corpus(paths: list[str]) -> dict:
"""
Classify all files in a corpus by their eyed3 load/tag status.
Run this before deploying a normalization pipeline to understand
the distribution of file types in the target collection.
Returns counts: recognized_tagged, recognized_untagged, unrecognized.
"""
results = {'recognized_tagged': 0, 'recognized_untagged': 0, 'unrecognized': 0}
for path in paths:
audio_file = eyed3.load(path)
if audio_file is None:
results['unrecognized'] += 1
elif audio_file.tag is None:
results['recognized_untagged'] += 1
else:
results['recognized_tagged'] += 1
return results
How eyeD3’s two distinct None-return paths, the MP3 format’s optional ID3 header architecture, and catch-all AttributeError handlers interact — and the correct pattern for production-grade ID3 tag pipelines
eyeD3’s design reflects the underlying MP3 format architecture: the MPEG audio bitstream and the ID3 metadata container are independent structures. An MP3 file can be a valid, fully playable audio file with absolutely no ID3 header. eyeD3 models this by returning a valid AudioFile from eyed3.load() while letting AudioFile.tag be None when no ID3 structure is present. The eyed3.load() function additionally returns None (not an exception) when the file is not recognized as any supported format — this is the design choice that creates the two-stage None pattern. Any pipeline that writes ID3 tags must handle both stages: check that eyed3.load() did not return None before accessing any AudioFile attribute, then check that audio_file.tag is not None before accessing any tag field. The initTag(version=eyed3.id3.ID3_V2_4) method creates a new empty ID3 tag in memory, allowing subsequent field writes. The version argument controls the ID3 version written to disk: eyed3.id3.ID3_V2_4 for the current standard (supported by all modern players), eyed3.id3.ID3_V2_3 for maximum legacy compatibility (Windows Media Player 11 and earlier, some car stereo systems require v2.3). The root failure in the Northfield Eyed3 Ltd. pipeline was treating AttributeError as a homogeneous exception class when it actually encoded three distinct failure modes: None.tag from an unrecognized file, None.title from an untagged MP3, and legitimate AttributeError from accessing fields that don’t exist in certain ID3 versions. The fix required disaggregating the exception handling: check for None explicitly at the two stages where eyeD3 design can produce it, and narrow the remaining except clause to cover only the residual I/O and format errors that cannot be pre-checked. The corpus audit helper — audit_corpus() — is the most practical way to characterize a new file collection before deploying a normalization pipeline: knowing the distribution of recognized-tagged, recognized-untagged, and unrecognized files in advance lets the engineer write the right exception handling for the actual distribution rather than the idealized “all files are properly tagged MP3s” assumption. The retainer engagement was 2.0h: 0.5h triage (7,600 episodes with blank search metadata; support tickets from week 2; AttributeError patterns identified in production logs as two distinct forms: “NoneType has no attribute tag” vs “NoneType has no attribute title”); 0.5h root cause (Zoom H6 export confirmed as audio_file.tag is None for valid MP3; WAV-as-MP3 test confirmed eyed3.load() returns None for non-MP3 magic bytes; eyeD3 initTag API confirmed); 0.5h fix (None check on eyed3.load() return; None check on audio_file.tag with initTag() call; exception handler disaggregated); 0.5h validation (60,000-file corpus processed; 400 non-MP3 files skipped with dedicated log entries; 7,200 untagged MP3 files correctly received new ID3v2.4 tags; zero AttributeError in 48-hour production validation; 2.0h total). Hours logged to HourTab with per-session breakdown.
Related retainer posts
- mutagen developer on retainer — mutagen 1.47.0; Python 3.9; music metadata normalization service 50,000 MP3 tracks/month;
EasyID3.save()writes ID3v2.4 (mutagen default); OEM car stereo SDK requires ID3v2.3; 12,000 devices show Unknown Artist; fix:audio.save(v2_version=3)— 3 weeks - tinytag developer on retainer — tinytag 1.10.1; Python 3.9; music catalog API 100,000-track library;
tag.trackreturns raw'3/12'TRCK string;int(tag.track)raises ValueError; 22,000 tracks crash job; 1,800 albums broken; fix:int(tag.track.split('/')[0]) if tag.track else None— 3 weeks - acoustid developer on retainer — pyacoustid 1.3.0; Python 3.9; music fingerprinting service 100,000 tracks/month;
fingerprint_file()callsfpcalcsubprocess;python:3.9-slimDocker base:fpcalcabsent;NoBackendErrormisread as network error; retry runs 3× per track; 0% success for 3 weeks; fix:RUN apt-get install -y libchromaprint-tools— 1.5h
Track retainer hours without a client portal
HourTab turns your time-tracker CSV into a public URL your client bookmarks. No login. No portal. CSV in, URL out.
See pricing →