Add gstreamer-less flac encoder and tagging (#121)

* Add encoding using Xiph.org 'flac' program.

This adds a FlacEncodeTask that encodes wave files to flac files.
This commit also replaces morituri's EncodeTask with FlacEncodeTask, however, in
morituri, EncodeTask also does the tagging.

FlacEncodeTask will not perform the tagging.
So we will need an extra task for the tagging - this will be added soon.

Meanwhile, do not merge this commit to master yet.

* Add tagging using mutagen.

Replace the gstreamer tagging code with mutagen tagging code.
getTagList is rewritten to return a dictionary of tags, which are then simply
passed to mutagen.

The way it is set up right now is not the best - I don't think it makes sense
for tagging to take place in program/cdparanoia.py ; but this is how the current
code did it.

I suggest that, when we rip out all the gstreamer code, we also move the tagging
to a more sensible place; and then also make the tagging not be an actual
'task.Task'.

* Add gstreamer-less CRC32 version

Only works on wave files at this point. Should not be a problem, I think.

* Use proper musicbrainz tags and ALBUM tag.

* Add mutagen to .travis.yml
This commit is contained in:
Merlijn Wajer
2017-02-02 21:50:47 +01:00
committed by JoeLametta
parent 4dc7a3cf77
commit 6ddb5d0114
8 changed files with 112 additions and 53 deletions

View File

@@ -450,58 +450,29 @@ class Program:
# htoa defaults to disc's artist
title = 'Hidden Track One Audio'
# here to avoid import gst eating our options
import gst
tags = {}
ret = gst.TagList()
# gst-python 0.10.15.1 does not handle unicode -> utf8 string
# conversion
# see http://bugzilla.gnome.org/show_bug.cgi?id=584445
if self.metadata and not self.metadata.various:
ret["album-artist"] = albumArtist.encode('utf-8')
ret[gst.TAG_ARTIST] = trackArtist.encode('utf-8')
ret[gst.TAG_TITLE] = title.encode('utf-8')
ret[gst.TAG_ALBUM] = disc.encode('utf-8')
tags['ALBUMARTIST'] = albumArtist
tags['ARTIST'] = trackArtist
tags['TITLE'] = title
tags['ALBUM'] = disc
tags['TRACKNUMBER'] = u'%s' % number
# gst-python 0.10.15.1 does not handle tags that are UINT
# see gst-python commit 26fa6dd184a8d6d103eaddf5f12bd7e5144413fb
# FIXME: no way to compare against 'master' version after 0.10.15
if gst.pygst_version >= (0, 10, 15):
ret[gst.TAG_TRACK_NUMBER] = number
if self.metadata:
# works, but not sure we want this
# if gst.pygst_version >= (0, 10, 15):
# ret[gst.TAG_TRACK_COUNT] = len(self.metadata.tracks)
# hack to get a GstDate which we cannot instantiate directly in
# 0.10.15.1
# FIXME: The dates are strings and must have the format 'YYYY',
# 'YYYY-MM' or 'YYYY-MM-DD'.
# GstDate expects a full date, so default to
# Jan and 1st if MM and DD are missing
date = self.metadata.release
if date:
logger.debug('Converting release date %r to structure', date)
if len(date) == 4:
date += '-01'
if len(date) == 7:
date += '-01'
tags['DATE'] = self.metadata.release
s = gst.structure_from_string('hi,date=(GstDate)%s' %
str(date))
ret[gst.TAG_DATE] = s['date']
# no musicbrainz info for htoa tracks
if number > 0:
ret["musicbrainz-trackid"] = mbidTrack
ret["musicbrainz-artistid"] = mbidTrackArtist
ret["musicbrainz-albumid"] = mbidAlbum
ret["musicbrainz-albumartistid"] = mbidTrackAlbum
ret["musicbrainz-discid"] = mbDiscId
tags['MUSICBRAINZ_TRACKID'] = mbidTrack
tags['MUSICBRAINZ_ARTISTID'] = mbidTrackArtist
tags['MUSICBRAINZ_ALBUMID'] = mbidAlbum
tags['MUSICBRAINZ_ALBUMARTISTID'] = mbidTrackAlbum
tags['MUSICBRAINZ_DISCID'] = mbDiscId
# FIXME: gst.TAG_ISRC
# TODO/FIXME: ISRC tag
return ret
return tags
def getHTOA(self):
"""