Example #1
0
 def _guess_tracknumber_and_title(self, metadata):
     if 'tracknumber' not in metadata or 'title' not in metadata:
         tracknumber, title = tracknum_and_title_from_filename(
             self.base_filename)
         if 'tracknumber' not in metadata:
             metadata['tracknumber'] = tracknumber
         if 'title' not in metadata:
             metadata['title'] = title
Example #2
0
 def test_returns_expected_tracknumber(self):
     tests = (
         ((None, 'Foo'), 'Foo.mp3'),
         (('1', 'Track 0001'), 'Track 0001.mp3'),
         (('99', 'Foo'), '99 Foo.mp3'),
         (('42', 'Foo'), '0000042 Foo.mp3'),
         (('2', 'Foo'), '0000002 Foo.mp3'),
         ((None, '20000 Feet'), '20000 Feet.mp3'),
         ((None, '20,000 Feet'), '20,000 Feet.mp3'),
     )
     for expected, filename in tests:
         result = tracknum_and_title_from_filename(filename)
         self.assertEqual(expected, result)
Example #3
0
 def test_namedtuple(self):
     result = tracknum_and_title_from_filename('0000002 Foo.mp3')
     self.assertEqual(result.tracknumber, '2')
     self.assertEqual(result.title, 'Foo')
Example #4
0
 def _guess_tracknumber_and_title(self, metadata):
     missing = {'tracknumber', 'title'} - set(metadata)
     if missing:
         guessed = tracknum_and_title_from_filename(self.base_filename)
         for m in missing:
             metadata[m] = getattr(guessed, m)