Merge branch 'fatg3erman-fix/1212-mpd-stream-name-title-reversed' into develop

This commit is contained in:
Thomas Adamcik 2015-07-20 19:30:28 +02:00
commit 8e8577f707
2 changed files with 22 additions and 3 deletions

View File

@ -38,12 +38,15 @@ def track_to_mpd_format(track, position=None, stream_title=None):
# https://github.com/mopidy/mopidy/issues/923#issuecomment-79584110
('Time', track.length and (track.length // 1000) or 0),
('Artist', concat_multi_values(track.artists, 'name')),
('Title', track.name or ''),
('Album', track.album and track.album.name or ''),
]
if stream_title:
result.append(('Name', stream_title))
if stream_title is not None:
result.append(('Title', stream_title))
if track.name:
result.append(('Name', track.name))
else:
result.append(('Title', track.name or ''))
if track.date:
result.append(('Date', track.date))

View File

@ -118,6 +118,22 @@ class TrackMpdFormatTest(unittest.TestCase):
translated = translator.concat_multi_values(artists, 'musicbrainz_id')
self.assertEqual(translated, '')
def test_track_to_mpd_format_with_stream_title(self):
result = translator.track_to_mpd_format(self.track, stream_title='foo')
self.assertIn(('Name', 'a name'), result)
self.assertIn(('Title', 'foo'), result)
def test_track_to_mpd_format_with_empty_stream_title(self):
result = translator.track_to_mpd_format(self.track, stream_title='')
self.assertIn(('Name', 'a name'), result)
self.assertIn(('Title', ''), result)
def test_track_to_mpd_format_with_stream_and_no_track_name(self):
track = self.track.replace(name=None)
result = translator.track_to_mpd_format(track, stream_title='foo')
self.assertNotIn(('Name', ''), result)
self.assertIn(('Title', 'foo'), result)
class PlaylistMpdFormatTest(unittest.TestCase):