Beispiel #1
0
 def test_support_types(self):
     path = '/some/path/image.jpeg'
     image = LocalFileCoverArtImage(path)
     self.assertFalse(image.support_types)
     self.assertFalse(image.support_multi_types)
     image = LocalFileCoverArtImage(path, support_types=True)
     self.assertTrue(image.support_types)
     self.assertFalse(image.support_multi_types)
     image = LocalFileCoverArtImage(path, support_multi_types=True)
     self.assertFalse(image.support_types)
     self.assertTrue(image.support_multi_types)
Beispiel #2
0
    def queue_images(self):
        config = get_config()
        _match_re = re.compile(config.setting['local_cover_regex'],
                               re.IGNORECASE)
        dirs_done = set()

        for file in self.album.iterfiles():
            current_dir = os.path.dirname(file.filename)
            if current_dir in dirs_done:
                continue
            dirs_done.add(current_dir)
            for root, dirs, files in os.walk(current_dir):
                for filename in files:
                    m = _match_re.search(filename)
                    if not m:
                        continue
                    filepath = os.path.join(current_dir, root, filename)
                    if os.path.exists(filepath):
                        types = self.get_types(m.group(1)) or ['front']
                        self.queue_put(
                            LocalFileCoverArtImage(filepath,
                                                   types=types,
                                                   support_types=True,
                                                   support_multi_types=True))
        return CoverArtProvider.FINISHED
Beispiel #3
0
 def find_local_images(self, current_dir, match_re):
     for root, dirs, files in os.walk(current_dir):
         for filename in files:
             m = match_re.search(filename)
             if not m:
                 continue
             filepath = os.path.join(current_dir, root, filename)
             if not os.path.exists(filepath):
                 continue
             try:
                 type_from_filename = self.get_types(m.group(1))
             except IndexError:
                 type_from_filename = []
             yield LocalFileCoverArtImage(filepath,
                                          types=type_from_filename
                                          or self._default_types,
                                          support_types=True,
                                          support_multi_types=True)
Beispiel #4
0
 def test_windows_path(self):
     path = 'C:\\Music\\somefile.mp3'
     image = LocalFileCoverArtImage(path)
     self.assertEqual(image.url.toLocalFile(), 'C:/Music/somefile.mp3')
Beispiel #5
0
 def test_set_file_url(self):
     path = '/some/path/image.jpeg'
     image = LocalFileCoverArtImage(path)
     self.assertEqual(image.url.toString(), 'file://' + path)