Merge pull request #3929 from arogl/7z_support

Add 7z file support #3906
This commit is contained in:
Adrian Sampson 2021-05-10 08:53:35 -07:00 committed by GitHub
commit 747486432f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 21 additions and 2 deletions

View file

@ -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

View file

@ -216,6 +216,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://pypi.org/project/py7zr/
Fixes:

View file

@ -67,7 +67,7 @@ albums (the latter case is true of typical Artist/Album organizations
and many people's "downloads" folders). The path can also be a single
song or an archive. Beets supports `zip` and `tar` archives out of the
box. To extract `rar` files, install the `rarfile`_ package and the
`unrar` command.
`unrar` command. To extract `7z` files, install the `py7zr`_ package.
Optional command flags:
@ -152,6 +152,7 @@ Optional command flags:
beet import --set genre="Alternative Rock" --set mood="emotional"
.. _rarfile: https://pypi.python.org/pypi/rarfile/
.. _py7zr: https://pypi.org/project/py7zr/
.. only:: html

View file

@ -130,7 +130,9 @@ setup(
] + [
'discogs-client' if (sys.version_info < (3, 0, 0))
else 'python3-discogs-client'
],
] + (
['py7zr'] if (sys.version_info > (3, 5, 0)) else []
),
'lint': [
'flake8',
'flake8-coding',

BIN
test/rsrc/archive.7z Normal file

Binary file not shown.

View file

@ -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):