def test_simple_script(self):
     metadata = Metadata()
     metadata['artist'] = 'AC/DC'
     metadata['album'] = 'The Album'
     filename = script_to_filename('%album%', metadata)
     self.assertEqual('The Album', filename)
     filename = script_to_filename('%artist%/%album%', metadata)
     self.assertEqual('AC_DC/The Album', filename)
 def test_simple_script(self):
     metadata = Metadata()
     metadata['artist'] = 'AC/DC'
     metadata['album'] = 'The Album'
     filename = script_to_filename('%album%', metadata)
     self.assertEqual('The Album', filename)
     filename = script_to_filename('%artist%/%album%', metadata)
     self.assertEqual('AC_DC/The Album', filename)
 def test_ascii_filenames(self):
     metadata = Metadata()
     metadata['artist'] = 'Die Ärzte'
     settings = config.setting.copy()
     settings['ascii_filenames'] = False
     filename = script_to_filename('%artist% éöü', metadata, settings=settings)
     self.assertEqual('Die Ärzte éöü', filename)
     settings['ascii_filenames'] = True
     filename = script_to_filename('%artist% éöü', metadata, settings=settings)
     self.assertEqual('Die Arzte eou', filename)
 def test_windows_compatibility(self):
     metadata = Metadata()
     metadata['artist'] = '*:'
     settings = config.setting.copy()
     settings['windows_compatibility'] = False
     expect_orig = '*:?'
     expect_compat = '___'
     filename = script_to_filename('%artist%?', metadata, settings=settings)
     self.assertEqual(expect_compat if IS_WIN else expect_orig, filename)
     settings['windows_compatibility'] = True
     filename = script_to_filename('%artist%?', metadata, settings=settings)
     self.assertEqual(expect_compat, filename)
 def test_windows_compatibility(self):
     metadata = Metadata()
     metadata['artist'] = '\\*:'
     settings = config.setting.copy()
     settings['windows_compatibility'] = False
     expect_orig = '\\*:?'
     expect_compat = '____'
     filename = script_to_filename('%artist%?', metadata, settings=settings)
     self.assertEqual(expect_compat if IS_WIN else expect_orig, filename)
     settings['windows_compatibility'] = True
     filename = script_to_filename('%artist%?', metadata, settings=settings)
     self.assertEqual(expect_compat, filename)
 def test_ascii_filenames(self):
     metadata = Metadata()
     metadata['artist'] = 'Die Ärzte'
     settings = config.setting.copy()
     settings['ascii_filenames'] = False
     filename = script_to_filename('%artist% éöü½',
                                   metadata,
                                   settings=settings)
     self.assertEqual('Die Ärzte éöü½', filename)
     settings['ascii_filenames'] = True
     filename = script_to_filename('%artist% éöü½',
                                   metadata,
                                   settings=settings)
     self.assertEqual('Die Arzte eou 1_2', filename)
Exemple #7
0
 def _script_to_filename(self, naming_format, file_metadata, settings=None):
     metadata = Metadata()
     if config.setting["clear_existing_tags"]:
         metadata.copy(file_metadata)
     else:
         metadata.copy(self.orig_metadata)
         metadata.update(file_metadata)
     return script_to_filename(naming_format, metadata, file=self, settings=settings)
Exemple #8
0
 def _script_to_filename(self, naming_format, file_metadata, settings=None):
     metadata = Metadata()
     if config.setting["clear_existing_tags"]:
         metadata.copy(file_metadata)
     else:
         metadata.copy(self.orig_metadata)
         metadata.update(file_metadata)
     return script_to_filename(naming_format, metadata, file=self, settings=settings)
 def _test_ascii_windows_compatibility(self):
     metadata = Metadata()
     metadata['artist'] = '\u2216/\\\u2215'
     settings = config.setting.copy()
     settings['ascii_filenames'] = True
     filename = script_to_filename('%artist%/\u2216\\\\\u2215',
                                   metadata,
                                   settings=settings)
     self.assertEqual('____/_\\_', filename)
Exemple #10
0
 def _make_image_filename(self, filename, dirname, _metadata):
     metadata = Metadata()
     metadata.copy(_metadata)
     metadata["coverart_maintype"] = self.maintype
     metadata["coverart_comment"] = self.comment
     if self.is_front:
         metadata.add_unique("coverart_types", "front")
     for cover_type in self.types:
         metadata.add_unique("coverart_types", cover_type)
     filename = script_to_filename(filename, metadata)
     if not filename:
         filename = DEFAULT_COVER_IMAGE_FILENAME
     if not is_absolute_path(filename):
         filename = os.path.join(dirname, filename)
     return encode_filename(filename)
Exemple #11
0
 def _make_image_filename(self, filename, dirname, _metadata):
     metadata = Metadata()
     metadata.copy(_metadata)
     metadata["coverart_maintype"] = self.maintype
     metadata["coverart_comment"] = self.comment
     if self.is_front:
         metadata.add_unique("coverart_types", "front")
     for cover_type in self.types:
         metadata.add_unique("coverart_types", cover_type)
     filename = script_to_filename(filename, metadata)
     if not filename:
         filename = "cover"
     if not os.path.isabs(filename):
         filename = os.path.join(dirname, filename)
     return encode_filename(filename)
Exemple #12
0
 def _make_image_filename(self, filename, dirname, _metadata):
     metadata = Metadata()
     metadata.copy(_metadata)
     metadata["coverart_maintype"] = self.maintype
     metadata["coverart_comment"] = self.comment
     if self.is_front:
         metadata.add_unique("coverart_types", "front")
     for cover_type in self.types:
         metadata.add_unique("coverart_types", cover_type)
     filename = script_to_filename(filename, metadata)
     if not filename:
         filename = "cover"
     if not os.path.isabs(filename):
         filename = os.path.join(dirname, filename)
     return encode_filename(filename)
 def test_remove_tabs_and_linebreaks_chars(self):
     metadata = Metadata()
     filename = script_to_filename('a\tb\nc', metadata)
     self.assertEqual('abc', filename)
 def test_file_metadata(self):
     metadata = Metadata()
     file = File('somepath/somefile.mp3')
     self.assertEqual('', script_to_filename('$has_file()', metadata))
     self.assertEqual(
         '1', script_to_filename('$has_file()', metadata, file=file))
 def test_preserve_backslash(self):
     metadata = Metadata()
     metadata['artist'] = 'AC\\/DC'
     filename = script_to_filename('%artist%', metadata)
     self.assertEqual('AC__DC' if IS_WIN else 'AC\\_DC', filename)
 def test_plain_filename(self):
     metadata = Metadata()
     filename = script_to_filename('AlbumArt', metadata)
     self.assertEqual('AlbumArt', filename)
 def test_preserve_leading_and_trailing_whitespace(self):
     metadata = Metadata()
     metadata['artist'] = 'The Artist'
     filename = script_to_filename(' %artist% ', metadata)
     self.assertEqual(' The Artist ', filename)
 def test_remove_tabs_and_linebreaks_chars(self):
     metadata = Metadata()
     filename = script_to_filename('a\tb\nc', metadata)
     self.assertEqual('abc', filename)
 def test_remove_null_chars(self):
     metadata = Metadata()
     filename = script_to_filename('a\x00b\x00', metadata)
     self.assertEqual('ab', filename)
 def test_preserve_leading_and_trailing_whitespace(self):
     metadata = Metadata()
     metadata['artist'] = 'The Artist'
     filename = script_to_filename(' %artist% ', metadata)
     self.assertEqual(' The Artist ', filename)
 def test_remove_null_chars(self):
     metadata = Metadata()
     filename = script_to_filename('a\x00b\x00', metadata)
     self.assertEqual('ab', filename)
 def test_plain_filename(self):
     metadata = Metadata()
     filename = script_to_filename('AlbumArt', metadata)
     self.assertEqual('AlbumArt', filename)
 def test_file_metadata(self):
     metadata = Metadata()
     file = File('somepath/somefile.mp3')
     self.assertEqual('', script_to_filename('$has_file()', metadata))
     self.assertEqual('1', script_to_filename('$has_file()', metadata, file=file))