mirror of
https://github.com/beetbox/beets.git
synced 2025-12-09 18:12:19 +01:00
Import rar archives
This commit is contained in:
parent
e3acdd0cc8
commit
68595ee09d
5 changed files with 26 additions and 0 deletions
|
|
@ -548,6 +548,10 @@ class ImportTask(object):
|
|||
|
||||
|
||||
class ArchiveImportTask(ImportTask):
|
||||
"""Additional methods for handling archives.
|
||||
|
||||
Use when `toppath` points to a `zip`, `tar`, or `rar` archive.
|
||||
"""
|
||||
|
||||
def __init__(self, toppath):
|
||||
super(ArchiveImportTask, self).__init__(toppath)
|
||||
|
|
@ -582,6 +586,13 @@ class ArchiveImportTask(ImportTask):
|
|||
cls._handlers.append((is_zipfile, ZipFile))
|
||||
from tarfile import is_tarfile, TarFile
|
||||
cls._handlers.append((is_tarfile, TarFile))
|
||||
try:
|
||||
from rarfile import is_rarfile, RarFile
|
||||
except ImportError:
|
||||
pass
|
||||
else:
|
||||
cls._handlers.append((is_rarfile, RarFile))
|
||||
|
||||
return cls._handlers
|
||||
|
||||
def cleanup(self):
|
||||
|
|
|
|||
1
setup.py
1
setup.py
|
|
@ -99,6 +99,7 @@ setup(
|
|||
'echonest_tempo': ['pyechonest'],
|
||||
'lastgenre': ['pylast'],
|
||||
'web': ['flask'],
|
||||
'import': ['rarfile'],
|
||||
},
|
||||
# Non-Python/non-PyPI plugin dependencies:
|
||||
# replaygain: mp3gain || aacgain
|
||||
|
|
|
|||
BIN
test/rsrc/archive.rar
Normal file
BIN
test/rsrc/archive.rar
Normal file
Binary file not shown.
|
|
@ -342,6 +342,19 @@ class ImportTarTest(ImportZipTest):
|
|||
return path
|
||||
|
||||
|
||||
class ImportRarTest(ImportZipTest):
|
||||
|
||||
def create_archive(self):
|
||||
return os.path.join(_common.RSRC, 'archive.rar')
|
||||
|
||||
|
||||
@unittest.skip('Implment me!')
|
||||
class ImportPasswordRarTest(ImportZipTest):
|
||||
|
||||
def create_archive(self):
|
||||
return os.path.join(_common.RSRC, 'password.rar')
|
||||
|
||||
|
||||
class ImportSingletonTest(_common.TestCase, ImportHelper):
|
||||
"""Test ``APPLY`` and ``ASIS`` choices for an import session with singletons
|
||||
config set to True.
|
||||
|
|
|
|||
1
tox.ini
1
tox.ini
|
|
@ -14,6 +14,7 @@ deps =
|
|||
flask
|
||||
responses
|
||||
pyechonest
|
||||
rarfile
|
||||
commands =
|
||||
nosetests {posargs}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue