Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rip out all code that uses gstreamer #130

Merged
merged 5 commits into from
Apr 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@ Whipper relies on the following packages in order to run correctly and provide a

- [cdparanoia](https://www.xiph.org/paranoia/), for the actual ripping
- [cdrdao](http://cdrdao.sourceforge.net/), for session, TOC, pre-gap, and ISRC extraction
- [GStreamer](https://gstreamer.freedesktop.org/) and its python bindings, for encoding (it's going to be removed soon™)
- `gstreamer0.10-base-plugins` (or `gstreamer0.10-plugins-base` depending on Linux distro) >= **0.10.22** for appsink
- `gstreamer0.10-good-plugins` (or `gstreamer0.10-plugins-good`) for wav encoding (it depends on the Linux distro used)
- `python-gst0.10` (GStreamer Python bindings)
- [python-musicbrainzngs](https://github.com/alastair/python-musicbrainzngs), for metadata lookup
- [python-setuptools](https://pypi.python.org/pypi/setuptools), for installation, plugins support
- [python-cddb](http://cddb-py.sourceforge.net/), for showing but not using metadata if disc not available in the MusicBrainz DB
Expand Down
28 changes: 8 additions & 20 deletions morituri/command/cd.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

from morituri.command.basecommand import BaseCommand
from morituri.common import (
accurip, common, config, drive, gstreamer, program, task
accurip, common, config, drive, program, task
)
from morituri.program import cdrdao, cdparanoia, utils
from morituri.result import result
Expand Down Expand Up @@ -317,17 +317,6 @@ def handle_arguments(self):


def doCommand(self):
# here to avoid import gst eating our options
from morituri.common import encode
profile = encode.PROFILES['flac']()
self.program.result.profileName = profile.name
self.program.result.profilePipeline = profile.pipeline
elementFactory = profile.pipeline.split(' ')[0]
self.program.result.gstreamerVersion = gstreamer.gstreamerVersion()
self.program.result.gstPythonVersion = gstreamer.gstPythonVersion()
self.program.result.encoderVersion = gstreamer.elementFactoryVersion(
elementFactory)

self.program.setWorkingDirectory(self.options.working_directory)
self.program.outdir = self.options.output_directory.decode('utf-8')
self.program.result.offset = int(self.options.offset)
Expand All @@ -339,7 +328,7 @@ def doCommand(self):
while True:
discName = self.program.getPath(self.program.outdir,
self.options.disc_template, self.mbdiscid, 0,
profile=profile, disambiguate=disambiguate)
disambiguate=disambiguate)
dirname = os.path.dirname(discName)
if os.path.exists(dirname):
sys.stdout.write("Output directory %s already exists\n" %
Expand Down Expand Up @@ -382,8 +371,8 @@ def ripIfNotRipped(number):
path = self.program.getPath(self.program.outdir,
self.options.track_template,
self.mbdiscid, number,
profile=profile, disambiguate=disambiguate) \
+ '.' + profile.extension
disambiguate=disambiguate) \
+ '.' + 'flac'
logger.debug('ripIfNotRipped: path %r' % path)
trackResult.number = number

Expand Down Expand Up @@ -429,7 +418,6 @@ def ripIfNotRipped(number):
self.program.ripTrack(self.runner, trackResult,
offset=int(self.options.offset),
device=self.device,
profile=profile,
taglist=self.program.getTagList(number),
overread=self.options.overread,
what='track %d of %d%s' % (
Expand Down Expand Up @@ -509,7 +497,7 @@ def ripIfNotRipped(number):
### write disc files
discName = self.program.getPath(self.program.outdir,
self.options.disc_template, self.mbdiscid, 0,
profile=profile, disambiguate=disambiguate)
disambiguate=disambiguate)
dirname = os.path.dirname(discName)
if not os.path.exists(dirname):
os.makedirs(dirname)
Expand All @@ -521,7 +509,8 @@ def ripIfNotRipped(number):
logger.debug('writing m3u file for %r', discName)
m3uPath = u'%s.m3u' % discName
handle = open(m3uPath, 'w')
handle.write(u'#EXTM3U\n')
u = u'#EXTM3U\n'
handle.write(u.encode('utf-8'))

def writeFile(handle, path, length):
targetPath = common.getRelativePath(path, m3uPath)
Expand All @@ -541,8 +530,7 @@ def writeFile(handle, path, length):

path = self.program.getPath(self.program.outdir,
self.options.track_template, self.mbdiscid, i + 1,
profile=profile,
disambiguate=disambiguate) + '.' + profile.extension
disambiguate=disambiguate) + '.' + 'flac'
writeFile(handle, path,
self.itable.getTrackLength(i + 1) / common.FRAMES_PER_SECOND)

Expand Down
45 changes: 8 additions & 37 deletions morituri/command/debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,22 +153,13 @@ def add_arguments(self):
# here to avoid import gst eating our options
from morituri.common import encode

default = 'flac'
# slated for deletion as flac will be the only encoder
self.parser.add_argument('--profile',
action="store",
dest="profile",
help="profile for encoding (default '%s', choices '%s')" % (
default, "', '".join(encode.ALL_PROFILES.keys())),
default=default)
self.parser.add_argument('input', action='store',
help="audio file to encode")
self.parser.add_argument('output', nargs='?', action='store',
help="output path")

def do(self):
from morituri.common import encode
profile = encode.ALL_PROFILES[self.options.profile]()

try:
fromPath = unicode(self.options.input)
Expand All @@ -180,7 +171,7 @@ def do(self):
try:
toPath = unicode(self.options.output)
except IndexError:
toPath = fromPath + '.' + profile.extension
toPath = fromPath + '.flac'

runner = task.SyncRunner()

Expand All @@ -191,33 +182,14 @@ def do(self):

runner.run(encodetask)

sys.stdout.write('Peak level: %r\n' % encodetask.peak)
sys.stdout.write('Encoded to %s\n' % toPath.encode('utf-8'))


class MaxSample(BaseCommand):
summary = "run a max sample task"
description = summary

def add_arguments(self):
self.parser.add_argument('files', nargs='+', action='store',
help="audio files to sample")

def do(self):
runner = task.SyncRunner()
# here to avoid import gst eating our options
from morituri.common import checksum

for arg in self.options.files:
fromPath = unicode(arg.decode('utf-8'))
# I think we want this to be
# fromPath, not toPath, since the sox peak task, afaik, works on wave
# files
peaktask = encode.SoxPeakTask(fromPath)
runner.run(peaktask)

checksumtask = checksum.MaxSampleTask(fromPath)

runner.run(checksumtask)

sys.stdout.write('%s\n' % arg)
sys.stdout.write('Biggest absolute sample: %04x\n' %
checksumtask.checksum)
sys.stdout.write('Peak level: %r\n' % peaktask.peak)
sys.stdout.write('Encoded to %s\n' % toPath.encode('utf-8'))


class Tag(BaseCommand):
Expand Down Expand Up @@ -325,7 +297,6 @@ class Debug(BaseCommand):
subcommands = {
'checksum': Checksum,
'encode': Encode,
'maxsample': MaxSample,
'tag': Tag,
'musicbrainzngs': MusicBrainzNGS,
'resultcache': ResultCache,
Expand Down
3 changes: 1 addition & 2 deletions morituri/command/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

from morituri.command.basecommand import BaseCommand
from morituri.common import accurip, config, program
from morituri.common import encode
from morituri.extern.task import task
from morituri.image import image
from morituri.result import result
Expand Down Expand Up @@ -59,8 +60,6 @@ def add_arguments(self):
)

def do(self):
# here to avoid import gst eating our options
from morituri.common import encode

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe also remove this empty line?

prog = program.Program(config.Config(), stdout=sys.stdout)
runner = task.SyncRunner()
Expand Down
4 changes: 1 addition & 3 deletions morituri/command/offset.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from morituri.common import accurip, common, config, drive, program
from morituri.common import task as ctask
from morituri.program import cdrdao, cdparanoia, utils
from morituri.common import checksum

from morituri.extern.task import task

Expand Down Expand Up @@ -80,7 +81,6 @@ def handle_arguments(self):
logger.debug('Trying with offsets %r', self._offsets)

def do(self):
prog = program.Program(config.Config())
runner = ctask.SyncRunner()

device = self.options.device
Expand Down Expand Up @@ -209,8 +209,6 @@ def _arcs(self, runner, table, track, offset):
track, offset)
runner.run(t)

# here to avoid import gst eating our options
from morituri.common import checksum

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe also remove this empty line?

# TODO MW: Update this to also use the v2 checksum(s)
t = checksum.FastAccurateRipChecksumTask(path, trackNumber=track,
Expand Down
Loading