Commit c48186e7 authored by Chris Lamb's avatar Chris Lamb 👀
Browse files

Add support for comparing MP3 files. (Closes: #43)

parent d6eb188d
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ Build-Depends:
 llvm <!nocheck>,
 lz4 <!nocheck> | liblz4-tool <!nocheck>,
 mono-utils <!nocheck>,
 mplayer <!nocheck>,
 ocaml-nox <!nocheck>,
 odt2txt <!nocheck>,
# oggvideotools [!s390x] <!nocheck>,
+1 −1
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@
#   $ mv debian/tests/control.tmp debian/tests/control

Tests: pytest-with-recommends
Depends: diffoscope, python3-pytest, file, linux-image-amd64 [amd64] | linux-image-generic [amd64], abootimg, acl, apktool [!ppc64el !s390x], binutils-multiarch, bzip2, caca-utils, colord, db-util, default-jdk-headless | default-jdk | java-sdk, device-tree-compiler, docx2txt, e2fsprogs, enjarify, fontforge-extras, fp-utils [!ppc64el !s390x], genisoimage, gettext, ghc, ghostscript, giflib-tools, gnumeric, gnupg, imagemagick, jsbeautifier, libarchive-tools, llvm, lz4 | liblz4-tool, mono-utils, ocaml-nox, odt2txt, openssh-client, pgpdump, poppler-utils, r-base-core, rpm2cpio, sng, sqlite3, squashfs-tools, tcpdump, unzip, xmlbeans, xxd | vim-common, xz-utils, zip, python3-argcomplete, python3-binwalk, python3-defusedxml, python3-distro, python3-guestfs, python3-jsondiff, python3-progressbar, python3-pypdf2, python3-debian, python3-pyxattr, python3-rpm, python3-tlsh
Depends: diffoscope, python3-pytest, file, linux-image-amd64 [amd64] | linux-image-generic [amd64], abootimg, acl, apktool [!ppc64el !s390x], binutils-multiarch, bzip2, caca-utils, colord, db-util, default-jdk-headless | default-jdk | java-sdk, device-tree-compiler, docx2txt, e2fsprogs, enjarify, ffmpeg, fontforge-extras, fp-utils [!ppc64el !s390x], genisoimage, gettext, ghc, ghostscript, giflib-tools, gnumeric, gnupg, imagemagick, jsbeautifier, libarchive-tools, llvm, lz4 | liblz4-tool, mono-utils, ocaml-nox, odt2txt, openssh-client, pgpdump, poppler-utils, r-base-core, rpm2cpio, sng, sqlite3, squashfs-tools, tcpdump, unzip, xmlbeans, xxd | vim-common, xz-utils, zip, python3-argcomplete, python3-binwalk, python3-defusedxml, python3-distro, python3-guestfs, python3-jsondiff, python3-progressbar, python3-pypdf2, python3-debian, python3-pyxattr, python3-rpm, python3-tlsh

Tests: pytest
Depends: diffoscope, python3-pytest, file
+1 −0
Original line number Diff line number Diff line
@@ -64,6 +64,7 @@ class ComparatorManager(object):
        ('gettext.MoFile',),
        ('ipk.IpkFile',),
        ('rust.RustObjectFile',),
        ('ffprobe.FfprobeFile',),
        ('gnumeric.GnumericFile',),
        ('gzip.GzipFile',),
        ('haskell.HiFile',),
+66 −0
Original line number Diff line number Diff line
# -*- coding: utf-8 -*-
#
# diffoscope: in-depth comparison of files, archives, and directories
#
# Copyright © 2019 Chris Lamb <lamby@debian.org>
#
# diffoscope is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# diffoscope is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with diffoscope.  If not, see <https://www.gnu.org/licenses/>.

import re

from diffoscope.tools import tool_required
from diffoscope.difference import Difference

from .utils.file import File
from .utils.command import Command


class Ffprobe(Command):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.flag = False

    def start(self):
        super().start()

        self.stderr = ''

    @property
    def stdout(self):
        return self._process.stderr.splitlines(True)

    @tool_required('ffprobe')
    def cmdline(self):
        return ('ffprobe', self.path)

    def filter(self, line):
        if self.flag:
            return line
        elif line == b'  Metadata:\n':
            self.flag = True
        return b''


class FfprobeFile(File):
    DESCRIPTION = "Multimedia metadata"
    FILE_TYPE_RE = re.compile(r'^Audio file')

    def compare_details(self, other, source=None):
        return [Difference.from_command(
            Ffprobe,
            self.path,
            other.path,
            source='ffprobe',
        )]
+3 −0
Original line number Diff line number Diff line
@@ -72,6 +72,9 @@ EXTERNAL_TOOLS = {
        'debian': 'device-tree-compiler',
        'arch': 'dtc',
    },
    'ffprobe': {
        'debian': 'ffmpeg',
    },
    'file': {
        'debian': 'file',
        'arch': 'file',
Loading