Пример #1
0
 def _copy_loaded_metadata(self, metadata):
     filename, _ = os.path.splitext(self.base_filename)
     metadata['~length'] = format_time(metadata.length)
     if 'title' not in metadata:
         metadata['title'] = filename
     if 'tracknumber' not in metadata:
         tracknumber = tracknum_from_filename(self.base_filename)
         if tracknumber != -1:
             metadata['tracknumber'] = str(tracknumber)
     self.orig_metadata = metadata
     self.metadata.copy(metadata)
Пример #2
0
 def _copy_loaded_metadata(self, metadata):
     filename, _ = os.path.splitext(self.base_filename)
     metadata['~length'] = format_time(metadata.length)
     if 'title' not in metadata:
         metadata['title'] = filename
     if 'tracknumber' not in metadata:
         tracknumber = tracknum_from_filename(self.base_filename)
         if tracknumber != -1:
             metadata['tracknumber'] = str(tracknumber)
     self.orig_metadata = metadata
     self.metadata.copy(metadata)
Пример #3
0
 def test_unmatched_tracknum(self):
     self.assertEqual(tracknum_from_filename('0.mp3'), None)
     self.assertEqual(tracknum_from_filename('track00.mp3'), None)
     self.assertEqual(tracknum_from_filename('song.mp3'), None)
     self.assertEqual(tracknum_from_filename('song [2004] [1000].mp3'),
                      None)
     self.assertEqual(tracknum_from_filename('song 2015.mp3'), None)
     self.assertEqual(tracknum_from_filename('2015 song.mp3'), None)
Пример #4
0
 def _copy_loaded_metadata(self, metadata):
     filename, _ = os.path.splitext(self.base_filename)
     metadata['~length'] = format_time(metadata.length)
     if 'title' not in metadata:
         metadata['title'] = filename
     if 'tracknumber' not in metadata:
         tracknumber = tracknum_from_filename(self.base_filename)
         if tracknumber != -1:
             tracknumber = str(tracknumber)
             metadata['tracknumber'] = tracknumber
             if metadata['title'] == filename:
                 stripped_filename = filename.lstrip('0')
                 tnlen = len(tracknumber)
                 if stripped_filename[:tnlen] == tracknumber:
                     metadata['title'] = stripped_filename[tnlen:].lstrip()
     self.orig_metadata = metadata
     self.metadata.copy(metadata)
Пример #5
0
 def _copy_loaded_metadata(self, metadata):
     filename, _ = os.path.splitext(self.base_filename)
     metadata['~length'] = format_time(metadata.length)
     if 'title' not in metadata:
         metadata['title'] = filename
     if 'tracknumber' not in metadata:
         tracknumber = tracknum_from_filename(self.base_filename)
         if tracknumber != -1:
             tracknumber = str(tracknumber)
             metadata['tracknumber'] = tracknumber
             if metadata['title'] == filename:
                 stripped_filename = filename.lstrip('0')
                 tnlen = len(tracknumber)
                 if stripped_filename[:tnlen] == tracknumber:
                     metadata['title'] = stripped_filename[tnlen:].lstrip()
     self.orig_metadata = metadata
     self.metadata.copy(metadata)
Пример #6
0
 def test_matched_tracknum_21(self):
     self.assertEqual(tracknum_from_filename('01abc.mp3'), 1)
Пример #7
0
 def test_matched_tracknum_19(self):
     self.assertEqual(tracknum_from_filename('01_foo.mp3'), 1)
Пример #8
0
 def test_matched_tracknum_18(self):
     self.assertEqual(tracknum_from_filename('song-70s 69 comment.mp3'), 69)
Пример #9
0
 def test_matched_tracknum_14(self):
     self.assertEqual(
         tracknum_from_filename('01 artist song [2004] (02).mp3'), 1)
Пример #10
0
 def test_matched_tracknum_12(self):
     self.assertEqual(tracknum_from_filename('artist song [2004] [01].mp3'),
                      1)
Пример #11
0
 def test_matched_tracknum_11(self):
     self.assertEqual(
         tracknum_from_filename('artist song-(666) (01) xxx.ogg'), 1)
Пример #12
0
 def test_matched_tracknum_10(self):
     self.assertEqual(
         tracknum_from_filename('artist song 2004 track-no_01 xxxx.ogg'), 1)
Пример #13
0
 def test_matched_tracknum_07(self):
     self.assertEqual(tracknum_from_filename('artist - s 02 ong (01).mp3'),
                      1)
Пример #14
0
 def test_matched_tracknum_05(self):
     self.assertEqual(tracknum_from_filename('song 01.mp3'), 1)
Пример #15
0
 def test_matched_tracknum_04(self):
     self.assertEqual(tracknum_from_filename('01 song.mp3'), 1)
     self.assertEqual(tracknum_from_filename('1 song.mp3'), 1)
Пример #16
0
def parse(filename):
    return tracknum_from_filename(filename)
Пример #17
0
 def test_returns_expected_tracknumber(self):
     tests = (
         (2, '2.mp3'),
         (2, '02.mp3'),
         (2, '002.mp3'),
         (None, 'Foo.mp3'),
         (1, 'Foo 0001.mp3'),
         (1, '1 song.mp3'),
         (99, '99 Foo.mp3'),
         (42, '42. Foo.mp3'),
         (None, '20000 Feet.mp3'),
         (242, 'track no 242.mp3'),
         (77, 'Track no. 77 .mp3'),
         (242, 'track-242.mp3'),
         (242, 'track nr 242.mp3'),
         (242, 'track_242.mp3'),
         (1, 'artist song 2004 track01 xxxx.ogg'),
         (1, 'artist song 2004 track-no-01 xxxx.ogg'),
         (1, 'artist song 2004 track-no_01 xxxx.ogg'),
         (1, '01_foo.mp3'),
         (1, '01ābc.mp3'),
         (1, '01abc.mp3'),
         (11, "11 Linda Jones - Things I've Been Through 08.flac"),
         (1, "01 artist song [2004] (02).mp3"),
         (1, "01 artist song [04].mp3"),
         (7, "artist song [2004] [7].mp3"),
         # (7, "artist song [2004] (7).mp3"),
         (7, 'artist song [2004] [07].mp3'),
         (7, 'artist song [2004] (07).mp3'),
         (4, 'xx 01 artist song [04].mp3'),
         (None, 'artist song-(666) (01) xxx.ogg'),
         (None, 'song-70s 69 comment.mp3'),
         (13, "2_13 foo.mp3"),
         (13, "02-13 foo.mp3"),
         (None, '1971.mp3'),
         (42, '1971 Track 42.mp3'),
         (None, "artist song [2004].mp3"),
         (None, '0.mp3'),
         (None, 'track00.mp3'),
         (None, 'song [2004] [1000].mp3'),
         (None, 'song 2015.mp3'),
         (None, '2015 song.mp3'),
         (None, '30,000 Pounds of Bananas.mp3'),
         (None, 'Dalas 1 PM.mp3'),
         (None, "Don't Stop the 80's.mp3"),
         (None, 'Symphony no. 5 in D minor.mp3'),
         (None, 'Song 2.mp3'),
         (None, '80s best of.mp3'),
         (None, 'best of 80s.mp3'),
         # (None, '99 Luftballons.mp3'),
         (7, '99 Luftballons Track 7.mp3'),
         (None, 'Margin 0.001.mp3'),
         (None, 'All the Small Things - blink‐182.mp3'),
         (None, '99.99 Foo.mp3'),
         (5, '٠٥ فاصله میان دو پرده.mp3'),
         (23, '23 foo.mp3'),
         (None, '²³ foo.mp3'),
     )
     for expected, filename in tests:
         tracknumber = tracknum_from_filename(filename)
         self.assertEqual(expected, tracknumber, filename)
Пример #18
0
 def test_matched_tracknum_16(self):
     self.assertEqual(tracknum_from_filename('xx 01 artist song [04].mp3'),
                      1)
Пример #19
0
 def test_matched_tracknum_17(self):
     self.assertEqual(tracknum_from_filename('song [2004] [1].mp3'), 1)
Пример #20
0
 def test_matched_tracknum_22(self):
     t = u"11 Linda Jones - Things I've Been Through 08.flac"
     self.assertEqual(tracknum_from_filename(t), 11)