/usr/lib/python2.7/dist-packages/mutagen/_tools/moggsplit.py is in python-mutagen 1.36-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | # -*- coding: utf-8 -*-
# Split a multiplex/chained Ogg file into its component parts.
# Copyright 2006 Joe Wreschnig
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of version 2 of the GNU General Public License as
# published by the Free Software Foundation.
import os
import mutagen.ogg
from mutagen._senf import argv
from ._util import SignalHandler, OptionParser
_sig = SignalHandler()
def main(argv):
from mutagen.ogg import OggPage
parser = OptionParser(
usage="%prog [options] filename.ogg ...",
description="Split Ogg logical streams using Mutagen.",
version="Mutagen %s" % ".".join(map(str, mutagen.version))
)
parser.add_option(
"--extension", dest="extension", default="ogg", metavar='ext',
help="use this extension (default 'ogg')")
parser.add_option(
"--pattern", dest="pattern", default="%(base)s-%(stream)d.%(ext)s",
metavar='pattern', help="name files using this pattern")
parser.add_option(
"--m3u", dest="m3u", action="store_true", default=False,
help="generate an m3u (playlist) file")
(options, args) = parser.parse_args(argv[1:])
if not args:
raise SystemExit(parser.print_help() or 1)
format = {'ext': options.extension}
for filename in args:
with _sig.block():
fileobjs = {}
format["base"] = os.path.splitext(os.path.basename(filename))[0]
fileobj = open(filename, "rb")
if options.m3u:
m3u = open(format["base"] + ".m3u", "w")
fileobjs["m3u"] = m3u
else:
m3u = None
while True:
try:
page = OggPage(fileobj)
except EOFError:
break
else:
format["stream"] = page.serial
if page.serial not in fileobjs:
new_filename = options.pattern % format
new_fileobj = open(new_filename, "wb")
fileobjs[page.serial] = new_fileobj
if m3u:
m3u.write(new_filename + "\r\n")
fileobjs[page.serial].write(page.write())
for f in fileobjs.values():
f.close()
def entry_point():
_sig.init()
return main(argv)
|