diff --git a/beets/importer.py b/beets/importer.py index b7bfdb156..38d2a4e62 100644 --- a/beets/importer.py +++ b/beets/importer.py @@ -1054,6 +1054,12 @@ class ArchiveImportTask(SentinelImportTask): pass else: cls._handlers.append((is_rarfile, RarFile)) + try: + from py7zr import is_7zfile, SevenZipFile + except ImportError: + pass + else: + cls._handlers.append((is_7zfile, SevenZipFile)) return cls._handlers diff --git a/docs/changelog.rst b/docs/changelog.rst index 6caed75c6..b215ae7b2 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -214,6 +214,10 @@ Other new things: ``check_on_import`` config option. * :doc:`/plugins/export`: big speedups when `--include-keys` option is used Thanks to :user:`ssssam`. +* Added 7z support via the `py7zr`_ library + Thanks to :user:`arogl`. :bug:`3906` + + .. _py7zr: https://github.com/miurahr/py7zr Fixes: diff --git a/setup.py b/setup.py index 8191d3888..84b391a78 100755 --- a/setup.py +++ b/setup.py @@ -122,6 +122,7 @@ setup( 'responses>=0.3.0', 'requests_oauthlib', 'reflink', + 'py7zr', ] + ( # Tests for the thumbnails plugin need pathlib on Python 2 too. ['pathlib'] if (sys.version_info < (3, 4, 0)) else [] diff --git a/test/rsrc/archive.7z b/test/rsrc/archive.7z new file mode 100644 index 000000000..6a09fdf4b Binary files /dev/null and b/test/rsrc/archive.7z differ diff --git a/test/test_importer.py b/test/test_importer.py index 3418d4628..48cb23378 100644 --- a/test/test_importer.py +++ b/test/test_importer.py @@ -450,6 +450,12 @@ class ImportRarTest(ImportZipTest): return os.path.join(_common.RSRC, b'archive.rar') +class Import7zTest(ImportZipTest): + + def create_archive(self): + return os.path.join(_common.RSRC, b'archive.7z') + + @unittest.skip('Implement me!') class ImportPasswordRarTest(ImportZipTest):