From 4bbd847a6a508b5bba7668e3847f2e3c721401c5 Mon Sep 17 00:00:00 2001 From: Thomas Adamcik Date: Sat, 26 Mar 2016 21:27:03 +0100 Subject: [PATCH 01/49] audio: Always install audio element --- mopidy/audio/actor.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/mopidy/audio/actor.py b/mopidy/audio/actor.py index 267b228d..1fb4fec6 100644 --- a/mopidy/audio/actor.py +++ b/mopidy/audio/actor.py @@ -22,7 +22,6 @@ logger = logging.getLogger(__name__) gst_logger = logging.getLogger('mopidy.audio.gst') _GST_PLAY_FLAGS_AUDIO = 0x02 -_GST_PLAY_FLAGS_SOFT_VOLUME = 0x10 _GST_STATE_MAPPING = { Gst.State.PLAYING: PlaybackState.PLAYING, @@ -451,8 +450,7 @@ class Audio(pykka.ThreadingActor): def _setup_playbin(self): playbin = Gst.ElementFactory.make('playbin') - playbin.set_property( - 'flags', _GST_PLAY_FLAGS_AUDIO | _GST_PLAY_FLAGS_SOFT_VOLUME) + playbin.set_property('flags', _GST_PLAY_FLAGS_AUDIO) # TODO: turn into config values... playbin.set_property('buffer-size', 5 << 20) # 5MB @@ -489,15 +487,16 @@ class Audio(pykka.ThreadingActor): def _setup_audio_sink(self): audio_sink = Gst.ElementFactory.make('bin', 'audio-sink') + queue = Gst.ElementFactory.make('queue') + volume = Gst.ElementFactory.make('volume') # Queue element to buy us time between the about-to-finish event and # the actual switch, i.e. about to switch can block for longer thanks # to this queue. + # TODO: See if settings should be set to minimize latency. Previous # setting breaks appsrc, and settings before that broke on a few # systems. So leave the default to play it safe. - queue = Gst.ElementFactory.make('queue') - if self._config['audio']['buffer_time'] > 0: queue.set_property( 'max-size-time', @@ -505,15 +504,13 @@ class Audio(pykka.ThreadingActor): audio_sink.add(queue) audio_sink.add(self._outputs) + audio_sink.add(volume) + + queue.link(volume) + volume.link(self._outputs) if self.mixer: - volume = Gst.ElementFactory.make('volume') - audio_sink.add(volume) - queue.link(volume) - volume.link(self._outputs) self.mixer.setup(volume, self.actor_ref.proxy().mixer) - else: - queue.link(self._outputs) ghost_pad = Gst.GhostPad.new('sink', queue.get_static_pad('sink')) audio_sink.add_pad(ghost_pad) From df0d534a56fd10682816b87f8f3145ee4c7162ac Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Fri, 1 Apr 2016 08:12:29 +0200 Subject: [PATCH 02/49] docs: Depend on sphinx_rtd_theme As of Sphinx 1.4, it is no longer a transitive dependency, so we need to depend on it explicitly. --- docs/requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/requirements.txt b/docs/requirements.txt index c75793d9..62c7e3e5 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,2 +1,3 @@ Sphinx >= 1.0 +sphinx_rtd_theme pygraphviz From c2c64620b14aa0360f49212c51820289af6c7503 Mon Sep 17 00:00:00 2001 From: Jens Luetjen Date: Mon, 4 Apr 2016 20:40:56 +0200 Subject: [PATCH 03/49] Ignore position of _on_position_changed callback --- mopidy/core/playback.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mopidy/core/playback.py b/mopidy/core/playback.py index ab96171e..96c11b2e 100644 --- a/mopidy/core/playback.py +++ b/mopidy/core/playback.py @@ -230,8 +230,8 @@ class PlaybackController(object): self._seek(self._pending_position) def _on_position_changed(self, position): - if self._pending_position == position: - self._trigger_seeked(position) + if self._pending_position: + self._trigger_seeked(self._pending_position) self._pending_position = None def _on_about_to_finish_callback(self): From 7757d306eaed772ba65e382841602f2777e736b6 Mon Sep 17 00:00:00 2001 From: Jens Luetjen Date: Mon, 4 Apr 2016 21:45:02 +0200 Subject: [PATCH 04/49] Include _pending_position 0 (zero) as valid target --- mopidy/core/playback.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mopidy/core/playback.py b/mopidy/core/playback.py index 96c11b2e..da505b22 100644 --- a/mopidy/core/playback.py +++ b/mopidy/core/playback.py @@ -230,7 +230,7 @@ class PlaybackController(object): self._seek(self._pending_position) def _on_position_changed(self, position): - if self._pending_position: + if self._pending_position is not None: self._trigger_seeked(self._pending_position) self._pending_position = None From c24380679f2cde841048ad349391cdf5241fe82e Mon Sep 17 00:00:00 2001 From: Jens Luetjen Date: Sat, 9 Apr 2016 11:10:21 +0200 Subject: [PATCH 05/49] Test only events triggered after seek --- tests/core/test_playback.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/core/test_playback.py b/tests/core/test_playback.py index 3572800c..34c9d367 100644 --- a/tests/core/test_playback.py +++ b/tests/core/test_playback.py @@ -734,6 +734,7 @@ class EventEmissionTest(BaseTest): self.core.playback.play(tl_tracks[0]) self.trigger_about_to_finish(replay_until='stream_changed') + self.replay_events() listener_mock.reset_mock() self.core.playback.seek(1000) From d87de65f9a27425b24165a31a8653bc93b94ca33 Mon Sep 17 00:00:00 2001 From: Lars Kruse Date: Sat, 28 May 2016 04:57:32 +0200 Subject: [PATCH 06/49] model documentation: update 'composers' and 'performers' type --- mopidy/models/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mopidy/models/__init__.py b/mopidy/models/__init__.py index f477a323..368739e0 100644 --- a/mopidy/models/__init__.py +++ b/mopidy/models/__init__.py @@ -192,9 +192,9 @@ class Track(ValidatedImmutableObject): :param album: track album :type album: :class:`Album` :param composers: track composers - :type composers: string + :type composers: list of :class:`Artist` :param performers: track performers - :type performers: string + :type performers: list of :class:`Artist` :param genre: track genre :type genre: string :param track_no: track number in album From 37cd2965521586403b42f25c6643f6111711dbad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Chr=C3=A9tien?= Date: Tue, 31 May 2016 15:13:55 +0200 Subject: [PATCH 07/49] mpd: fix protocol for replay_gain_status --- docs/changelog.rst | 3 +++ mopidy/mpd/protocol/playback.py | 2 +- tests/mpd/protocol/test_playback.py | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 18eaea9f..e47ba9af 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -38,6 +38,9 @@ Bug fix release. where a :confval:`file/media_dirs` path contained non-ASCII characters. (Fixes: :issue:`1345`, PR: :issue:`1493`) +- MPD: Fix MPD protocol for ``replay_gain_status`` command. The actual command + remains unimplemented. (PR: :issue:`1520`) + v2.0.0 (2016-02-15) =================== diff --git a/mopidy/mpd/protocol/playback.py b/mopidy/mpd/protocol/playback.py index 7b943930..08e7cded 100644 --- a/mopidy/mpd/protocol/playback.py +++ b/mopidy/mpd/protocol/playback.py @@ -325,7 +325,7 @@ def replay_gain_status(context): Prints replay gain options. Currently, only the variable ``replay_gain_mode`` is returned. """ - return 'off' # TODO + return 'replay_gain_mode: off' # TODO @protocol.commands.add('seek', songpos=protocol.UINT, seconds=protocol.UINT) diff --git a/tests/mpd/protocol/test_playback.py b/tests/mpd/protocol/test_playback.py index 9f13fc22..07ece3b0 100644 --- a/tests/mpd/protocol/test_playback.py +++ b/tests/mpd/protocol/test_playback.py @@ -115,7 +115,7 @@ class PlaybackOptionsHandlerTest(protocol.BaseTestCase): def test_replay_gain_status_default(self): self.send_request('replay_gain_status') self.assertInResponse('OK') - self.assertInResponse('off') + self.assertInResponse('replay_gain_mode: off') def test_mixrampdb(self): self.send_request('mixrampdb "10"') From f06e5adfa9f01a9304e08288c8baf0ef652851f0 Mon Sep 17 00:00:00 2001 From: SeppSTA Date: Wed, 1 Jun 2016 13:36:52 +0200 Subject: [PATCH 08/49] http: fix timeout value to seconds --- mopidy/stream/actor.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mopidy/stream/actor.py b/mopidy/stream/actor.py index 0861b5b0..4a7935fd 100644 --- a/mopidy/stream/actor.py +++ b/mopidy/stream/actor.py @@ -68,7 +68,7 @@ class StreamLibraryProvider(backend.LibraryProvider): track = tags.convert_tags_to_track(scan_result.tags).replace( uri=uri, length=scan_result.duration) else: - logger.warning('Problem looking up %s: %s', uri) + logger.warning('Problem looking up %s', uri) track = Track(uri=uri) return [track] @@ -142,7 +142,7 @@ def _unwrap_stream(uri, timeout, scanner, requests_session): uri, timeout) return None, None content = http.download( - requests_session, uri, timeout=download_timeout) + requests_session, uri, timeout=download_timeout/1000) if content is None: logger.info( From 18f4c1fa38001bd5ef719d0f0ee4fb7f31613859 Mon Sep 17 00:00:00 2001 From: SeppSTA Date: Wed, 1 Jun 2016 14:05:58 +0200 Subject: [PATCH 09/49] insert missing whitespace --- mopidy/stream/actor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mopidy/stream/actor.py b/mopidy/stream/actor.py index 4a7935fd..1bdd05ca 100644 --- a/mopidy/stream/actor.py +++ b/mopidy/stream/actor.py @@ -142,7 +142,7 @@ def _unwrap_stream(uri, timeout, scanner, requests_session): uri, timeout) return None, None content = http.download( - requests_session, uri, timeout=download_timeout/1000) + requests_session, uri, timeout=download_timeout / 1000) if content is None: logger.info( From ac92069dd5a9e86e33bcf426b16891f702d1f095 Mon Sep 17 00:00:00 2001 From: ismailof Date: Mon, 6 Jun 2016 21:45:18 +0200 Subject: [PATCH 10/49] Add nextsong/nextsongid to mpd status --- mopidy/mpd/protocol/status.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) mode change 100644 => 100755 mopidy/mpd/protocol/status.py diff --git a/mopidy/mpd/protocol/status.py b/mopidy/mpd/protocol/status.py old mode 100644 new mode 100755 index 16e9d013..27ce59f4 --- a/mopidy/mpd/protocol/status.py +++ b/mopidy/mpd/protocol/status.py @@ -173,6 +173,7 @@ def status(context): decimal places for millisecond precision. """ tl_track = context.core.playback.get_current_tl_track() + next_tlid = context.core.tracklist.next_tlid() futures = { 'tracklist.length': context.core.tracklist.get_length(), @@ -185,6 +186,8 @@ def status(context): 'playback.state': context.core.playback.get_state(), 'playback.current_tl_track': tl_track, 'tracklist.index': context.core.tracklist.index(tl_track.get()), + 'tracklist.next_tlid': next_tlid, + 'tracklist.next_index': context.core.tracklist.index(next_tlid.get()), 'playback.time_position': context.core.playback.get_time_position(), } pykka.get_all(futures.values()) @@ -199,10 +202,12 @@ def status(context): ('xfade', _status_xfade(futures)), ('state', _status_state(futures)), ] - # TODO: add nextsong and nextsongid if futures['playback.current_tl_track'].get() is not None: result.append(('song', _status_songpos(futures))) result.append(('songid', _status_songid(futures))) + if futures['tracklist.next_tlid'].get() is not None: + result.append(('nextsong', _status_nextsongpos(futures))) + result.append(('nextsongid', _status_nextsongid(futures))) if futures['playback.state'].get() in ( PlaybackState.PLAYING, PlaybackState.PAUSED): result.append(('time', _status_time(futures))) @@ -247,6 +252,10 @@ def _status_single(futures): return int(futures['tracklist.single'].get()) +def _status_songpos(futures): + return futures['tracklist.index'].get() + + def _status_songid(futures): current_tl_track = futures['playback.current_tl_track'].get() if current_tl_track is not None: @@ -255,8 +264,12 @@ def _status_songid(futures): return _status_songpos(futures) -def _status_songpos(futures): - return futures['tracklist.index'].get() +def _status_nextsongpos(futures): + return futures['tracklist.next_index'].get() + + +def _status_nextsongid(futures): + return futures['tracklist.next_tlid'].get() def _status_state(futures): From a1c219e25d67af8b94e970296f1a1ff4ee04b431 Mon Sep 17 00:00:00 2001 From: ismailof Date: Mon, 6 Jun 2016 22:59:59 +0200 Subject: [PATCH 11/49] Add nextsong/nextsongid to mpd status --- mopidy/mpd/protocol/status.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mopidy/mpd/protocol/status.py b/mopidy/mpd/protocol/status.py index 27ce59f4..d4aeb36f 100755 --- a/mopidy/mpd/protocol/status.py +++ b/mopidy/mpd/protocol/status.py @@ -173,7 +173,7 @@ def status(context): decimal places for millisecond precision. """ tl_track = context.core.playback.get_current_tl_track() - next_tlid = context.core.tracklist.next_tlid() + next_tlid = context.core.tracklist.get_next_tlid() futures = { 'tracklist.length': context.core.tracklist.get_length(), @@ -187,7 +187,8 @@ def status(context): 'playback.current_tl_track': tl_track, 'tracklist.index': context.core.tracklist.index(tl_track.get()), 'tracklist.next_tlid': next_tlid, - 'tracklist.next_index': context.core.tracklist.index(next_tlid.get()), + 'tracklist.next_index': context.core.tracklist.index( + tlid=next_tlid.get()), 'playback.time_position': context.core.playback.get_time_position(), } pykka.get_all(futures.values()) From 19818d3f68a57d06d9251ba2371156878ef926f4 Mon Sep 17 00:00:00 2001 From: ismailof Date: Mon, 6 Jun 2016 23:20:13 +0200 Subject: [PATCH 12/49] Add MPD nextsong/nextsongid test case --- tests/mpd/test_status.py | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) mode change 100644 => 100755 tests/mpd/test_status.py diff --git a/tests/mpd/test_status.py b/tests/mpd/test_status.py old mode 100644 new mode 100755 index 25b8dd72..9450808c --- a/tests/mpd/test_status.py +++ b/tests/mpd/test_status.py @@ -48,9 +48,9 @@ class StatusHandlerTest(unittest.TestCase): def tearDown(self): # noqa: N802 pykka.ActorRegistry.stop_all() - def set_tracklist(self, track): - self.backend.library.dummy_library = [track] - self.core.tracklist.add(uris=[track.uri]).get() + def set_tracklist(self, tracks): + self.backend.library.dummy_library = tracks + self.core.tracklist.add(uris=[track.uri for track in tracks]).get() def test_stats_method(self): result = status.stats(self.context) @@ -154,22 +154,35 @@ class StatusHandlerTest(unittest.TestCase): self.assertEqual(result['state'], 'pause') def test_status_method_when_playlist_loaded_contains_song(self): - self.set_tracklist(Track(uri='dummy:/a')) - + self.set_tracklist([Track(uri='dummy:/a')]) self.core.playback.play().get() result = dict(status.status(self.context)) self.assertIn('song', result) self.assertGreaterEqual(int(result['song']), 0) def test_status_method_when_playlist_loaded_contains_tlid_as_songid(self): - self.set_tracklist(Track(uri='dummy:/a')) + self.set_tracklist([Track(uri='dummy:/a')]) self.core.playback.play().get() result = dict(status.status(self.context)) self.assertIn('songid', result) self.assertEqual(int(result['songid']), 1) + def test_status_method_when_playlist_loaded_contains_nextsong(self): + self.set_tracklist([Track(uri='dummy:/a'), Track(uri='dummy:/b')]) + self.core.playback.play().get() + result = dict(status.status(self.context)) + self.assertIn('nextsong', result) + self.assertGreaterEqual(int(result['nextsong']), 0) + + def test_status_method_when_playlist_loaded_contains_nextsongid(self): + self.set_tracklist([Track(uri='dummy:/a'), Track(uri='dummy:/b')]) + self.core.playback.play().get() + result = dict(status.status(self.context)) + self.assertIn('nextsongid', result) + self.assertEqual(int(result['nextsongid']), 2) + def test_status_method_when_playing_contains_time_with_no_length(self): - self.set_tracklist(Track(uri='dummy:/a', length=None)) + self.set_tracklist([Track(uri='dummy:/a', length=None)]) self.core.playback.play().get() result = dict(status.status(self.context)) self.assertIn('time', result) @@ -179,7 +192,7 @@ class StatusHandlerTest(unittest.TestCase): self.assertLessEqual(position, total) def test_status_method_when_playing_contains_time_with_length(self): - self.set_tracklist(Track(uri='dummy:/a', length=10000)) + self.set_tracklist([Track(uri='dummy:/a', length=10000)]) self.core.playback.play() result = dict(status.status(self.context)) self.assertIn('time', result) @@ -189,7 +202,7 @@ class StatusHandlerTest(unittest.TestCase): self.assertLessEqual(position, total) def test_status_method_when_playing_contains_elapsed(self): - self.set_tracklist(Track(uri='dummy:/a', length=60000)) + self.set_tracklist([Track(uri='dummy:/a', length=60000)]) self.core.playback.play().get() self.core.playback.pause() self.core.playback.seek(59123) @@ -198,7 +211,7 @@ class StatusHandlerTest(unittest.TestCase): self.assertEqual(result['elapsed'], '59.123') def test_status_method_when_starting_playing_contains_elapsed_zero(self): - self.set_tracklist(Track(uri='dummy:/a', length=10000)) + self.set_tracklist([Track(uri='dummy:/a', length=10000)]) self.core.playback.play().get() self.core.playback.pause() result = dict(status.status(self.context)) @@ -206,7 +219,7 @@ class StatusHandlerTest(unittest.TestCase): self.assertEqual(result['elapsed'], '0.000') def test_status_method_when_playing_contains_bitrate(self): - self.set_tracklist(Track(uri='dummy:/a', bitrate=3200)) + self.set_tracklist([Track(uri='dummy:/a', bitrate=3200)]) self.core.playback.play().get() result = dict(status.status(self.context)) self.assertIn('bitrate', result) From 6787a044fc9679440fb40e4d50fddad89b93346f Mon Sep 17 00:00:00 2001 From: ismailof Date: Mon, 6 Jun 2016 23:20:49 +0200 Subject: [PATCH 13/49] Add MPD nextsong/nextsongid test case --- mopidy/mpd/protocol/status.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mopidy/mpd/protocol/status.py b/mopidy/mpd/protocol/status.py index d4aeb36f..3d76d35f 100755 --- a/mopidy/mpd/protocol/status.py +++ b/mopidy/mpd/protocol/status.py @@ -253,10 +253,6 @@ def _status_single(futures): return int(futures['tracklist.single'].get()) -def _status_songpos(futures): - return futures['tracklist.index'].get() - - def _status_songid(futures): current_tl_track = futures['playback.current_tl_track'].get() if current_tl_track is not None: @@ -265,14 +261,18 @@ def _status_songid(futures): return _status_songpos(futures) -def _status_nextsongpos(futures): - return futures['tracklist.next_index'].get() +def _status_songpos(futures): + return futures['tracklist.index'].get() def _status_nextsongid(futures): return futures['tracklist.next_tlid'].get() +def _status_nextsongpos(futures): + return futures['tracklist.next_index'].get() + + def _status_state(futures): state = futures['playback.state'].get() if state == PlaybackState.PLAYING: From fc26b7304ce99db643ba09fac9368a23d9e93bdc Mon Sep 17 00:00:00 2001 From: ismailof Date: Mon, 6 Jun 2016 23:22:40 +0200 Subject: [PATCH 14/49] chmod correction --- mopidy/mpd/protocol/status.py | 0 tests/mpd/test_status.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 mopidy/mpd/protocol/status.py mode change 100755 => 100644 tests/mpd/test_status.py diff --git a/mopidy/mpd/protocol/status.py b/mopidy/mpd/protocol/status.py old mode 100755 new mode 100644 diff --git a/tests/mpd/test_status.py b/tests/mpd/test_status.py old mode 100755 new mode 100644 From c3eb9b60c0b320a8cb0e76947287851ceae96e1d Mon Sep 17 00:00:00 2001 From: Tom Parker Date: Fri, 10 Jun 2016 12:41:02 +0100 Subject: [PATCH 15/49] If tags date isn't a valid value for Python, skip the tag --- mopidy/audio/tags.py | 14 ++++++++++---- tests/audio/test_tags.py | 8 ++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/mopidy/audio/tags.py b/mopidy/audio/tags.py index 5ae86468..459bb1e3 100644 --- a/mopidy/audio/tags.py +++ b/mopidy/audio/tags.py @@ -44,10 +44,16 @@ gstreamer-GstTagList.html value = taglist.get_value_index(tag, i) if isinstance(value, GLib.Date): - date = datetime.date( - value.get_year(), value.get_month(), value.get_day()) - result[tag].append(date.isoformat().decode('utf-8')) - if isinstance(value, Gst.DateTime): + try: + date = datetime.date( + value.get_year(), value.get_month(), value.get_day()) + result[tag].append(date.isoformat().decode('utf-8')) + except ValueError: + logger.log( + logging.DEBUG, + 'Ignoring dodgy date value: %d-%d-%d', + value.get_year(), value.get_month(), value.get_day()) + elif isinstance(value, Gst.DateTime): result[tag].append(value.to_iso8601_string().decode('utf-8')) elif isinstance(value, bytes): result[tag].append(value.decode('utf-8', 'replace')) diff --git a/tests/audio/test_tags.py b/tests/audio/test_tags.py index 01475124..d85bcc12 100644 --- a/tests/audio/test_tags.py +++ b/tests/audio/test_tags.py @@ -44,6 +44,14 @@ class TestConvertTaglist(object): assert isinstance(result[Gst.TAG_DATE][0], compat.text_type) assert result[Gst.TAG_DATE][0] == '2014-01-07' + def test_date_tag_bad_value(self): + date = GLib.Date.new_dmy(7, 1, 10000) + taglist = self.make_taglist(Gst.TAG_DATE, [date]) + + result = tags.convert_taglist(taglist) + + assert len(result[Gst.TAG_DATE]) == 0 + def test_date_time_tag(self): taglist = self.make_taglist(Gst.TAG_DATE_TIME, [ Gst.DateTime.new_from_iso8601_string(b'2014-01-07 14:13:12') From ffe32ab7c7cbb64997654077ad366b288e5ee751 Mon Sep 17 00:00:00 2001 From: Tom Parker Date: Mon, 13 Jun 2016 22:03:51 +0100 Subject: [PATCH 16/49] Use logger.debug, not logging.log(logging.DEBUG --- mopidy/audio/tags.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mopidy/audio/tags.py b/mopidy/audio/tags.py index 459bb1e3..7fabefd6 100644 --- a/mopidy/audio/tags.py +++ b/mopidy/audio/tags.py @@ -49,8 +49,7 @@ gstreamer-GstTagList.html value.get_year(), value.get_month(), value.get_day()) result[tag].append(date.isoformat().decode('utf-8')) except ValueError: - logger.log( - logging.DEBUG, + logger.debug( 'Ignoring dodgy date value: %d-%d-%d', value.get_year(), value.get_month(), value.get_day()) elif isinstance(value, Gst.DateTime): From 95ac2714ffc3e585abb5acf56e885fe75814bdca Mon Sep 17 00:00:00 2001 From: ismailof Date: Sun, 26 Jun 2016 11:18:34 +0200 Subject: [PATCH 17/49] Add changelog entry --- docs/changelog.rst | 2 ++ 1 file changed, 2 insertions(+) mode change 100644 => 100755 docs/changelog.rst diff --git a/docs/changelog.rst b/docs/changelog.rst old mode 100644 new mode 100755 index e47ba9af..1411d347 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -41,6 +41,8 @@ Bug fix release. - MPD: Fix MPD protocol for ``replay_gain_status`` command. The actual command remains unimplemented. (PR: :issue:`1520`) +- MPD: Add ``nextsong`` and ``nextsongid`` to the response of MPD ``status`` command. + (Fixes: :issue:`1133` :issue:`1516`, PR: :issue:`1523`) v2.0.0 (2016-02-15) =================== From 65498485fea09f6ef947160ad81a4f6d56462e69 Mon Sep 17 00:00:00 2001 From: ismailof Date: Sun, 26 Jun 2016 11:19:08 +0200 Subject: [PATCH 18/49] Add changelog entry --- docs/changelog.rst | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 docs/changelog.rst diff --git a/docs/changelog.rst b/docs/changelog.rst old mode 100755 new mode 100644 From d1449bcb6fe28044a0a2ddf79c746f9dc09f2af0 Mon Sep 17 00:00:00 2001 From: Nantas Nardelli Date: Sun, 24 Jul 2016 20:30:48 +0100 Subject: [PATCH 19/49] Properly get track position before change events In particular, this allows to send the right information when: 1. the track finishes and switches to the next one in the list; 2. user presses next / previous The cases of EOS and stop event were already handled properly. Note: we only have GStreamer's `about-to-finish` event to deal with the end of a track, which usually happens a few seconds before the end of the track. We set the position to the length of the track, which is not overridden unless the user generates a relevant callback. --- mopidy/core/playback.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mopidy/core/playback.py b/mopidy/core/playback.py index da505b22..ab0bee5b 100644 --- a/mopidy/core/playback.py +++ b/mopidy/core/playback.py @@ -251,6 +251,10 @@ class PlaybackController(object): if self._state == PlaybackState.STOPPED: return + # Unless overridden by other calls (e.g. next / previous / stop) this + # will be the last position recorded until the track gets reassigned. + self._last_position = self._current_tl_track.track.length + pending = self.core.tracklist.eot_track(self._current_tl_track) # avoid endless loop if 'repeat' is 'true' and no track is playable # * 2 -> second run to get all playable track in a shuffled playlist @@ -394,6 +398,10 @@ class PlaybackController(object): if not backend: return False + # This must happen before prepare_change gets called, otherwise the + # backend flushes the information of the track. + self._last_position = self.get_time_position() + # TODO: Wrap backend call in error handling. backend.playback.prepare_change() From 500ff70b87b11d167c72071fb889fbf56e0dc359 Mon Sep 17 00:00:00 2001 From: Nantas Nardelli Date: Sun, 24 Jul 2016 21:52:15 +0100 Subject: [PATCH 20/49] Add changelog entry for #1534, and fix #1523 typo --- docs/changelog.rst | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 1411d347..067adc46 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -42,7 +42,12 @@ Bug fix release. remains unimplemented. (PR: :issue:`1520`) - MPD: Add ``nextsong`` and ``nextsongid`` to the response of MPD ``status`` command. - (Fixes: :issue:`1133` :issue:`1516`, PR: :issue:`1523`) + (Fixes: :issue:`1133`, :issue:`1516`, PR: :issue:`1523`) + +- Core: Correctly record the last position of a track when switching to another + one. Particularly relevant for `mopidy-scrobbler` users, as before it was + essentially unusable. (Fixes: :issue:`1456`, PR: :issue:`1534`) + v2.0.0 (2016-02-15) =================== From 6e603a183b3b492a43c91d0833afc9e5f3a2f6ab Mon Sep 17 00:00:00 2001 From: Nantas Nardelli Date: Sun, 24 Jul 2016 22:26:59 +0100 Subject: [PATCH 21/49] Add TODO about checking length of track when null --- mopidy/core/playback.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mopidy/core/playback.py b/mopidy/core/playback.py index ab0bee5b..0106abf2 100644 --- a/mopidy/core/playback.py +++ b/mopidy/core/playback.py @@ -253,6 +253,8 @@ class PlaybackController(object): # Unless overridden by other calls (e.g. next / previous / stop) this # will be the last position recorded until the track gets reassigned. + # TODO: Check if case when track.length isn't populated needs to be + # handled. self._last_position = self._current_tl_track.track.length pending = self.core.tracklist.eot_track(self._current_tl_track) From fb823d1a7c396ec6b0bda4070c92cb0b7b3e1ac3 Mon Sep 17 00:00:00 2001 From: Thomas Adamcik Date: Mon, 25 Jul 2016 21:09:38 +0200 Subject: [PATCH 22/49] lint: Workaround and fix to account for new version of flake8 --- mopidy/__main__.py | 2 +- mopidy/config/__init__.py | 7 +++++-- tests/models/test_fields.py | 2 +- tox.ini | 3 ++- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/mopidy/__main__.py b/mopidy/__main__.py index 86a0c19c..7963900e 100644 --- a/mopidy/__main__.py +++ b/mopidy/__main__.py @@ -5,7 +5,7 @@ import os import signal import sys -from mopidy.internal.gi import Gst # noqa: Import to initialize +from mopidy.internal.gi import Gst # noqa: F401 try: # Make GObject's mainloop the event loop for python-dbus diff --git a/mopidy/config/__init__.py b/mopidy/config/__init__.py index 21a6a00b..ec5c9a99 100644 --- a/mopidy/config/__init__.py +++ b/mopidy/config/__init__.py @@ -9,12 +9,15 @@ import re from mopidy import compat from mopidy.compat import configparser from mopidy.config import keyring -from mopidy.config.schemas import * # noqa -from mopidy.config.types import * # noqa +from mopidy.config.schemas import * +from mopidy.config.types import * from mopidy.internal import path, versioning logger = logging.getLogger(__name__) +# flake8: noqa: +# TODO: Update this to be flake8 compliant + _core_schema = ConfigSchema('core') _core_schema['cache_dir'] = Path() _core_schema['config_dir'] = Path() diff --git a/tests/models/test_fields.py b/tests/models/test_fields.py index bf842fd5..3374c822 100644 --- a/tests/models/test_fields.py +++ b/tests/models/test_fields.py @@ -2,7 +2,7 @@ from __future__ import absolute_import, unicode_literals import unittest -from mopidy.models.fields import * # noqa: F403 +from mopidy.models.fields import Collection, Field, Integer, String def create_instance(field): diff --git a/tox.ini b/tox.ini index da6bcc38..b39fc68b 100644 --- a/tox.ini +++ b/tox.ini @@ -37,7 +37,8 @@ commands = sphinx-build -b html -d {envtmpdir}/doctrees . {envtmpdir}/html [testenv:flake8] deps = flake8 - flake8-import-order +# TODO: Re-enable once https://github.com/PyCQA/flake8-import-order/issues/79 is released. +# flake8-import-order pep8-naming commands = flake8 --show-source --statistics mopidy tests From c199fb1c814eb9e3998a30c0bc1f6cf620c46755 Mon Sep 17 00:00:00 2001 From: Thomas Adamcik Date: Mon, 25 Jul 2016 21:09:38 +0200 Subject: [PATCH 23/49] lint: Workaround and fix to account for new version of flake8 --- mopidy/__main__.py | 2 +- mopidy/config/__init__.py | 7 +++++-- tests/models/test_fields.py | 2 +- tox.ini | 3 ++- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/mopidy/__main__.py b/mopidy/__main__.py index 86a0c19c..7963900e 100644 --- a/mopidy/__main__.py +++ b/mopidy/__main__.py @@ -5,7 +5,7 @@ import os import signal import sys -from mopidy.internal.gi import Gst # noqa: Import to initialize +from mopidy.internal.gi import Gst # noqa: F401 try: # Make GObject's mainloop the event loop for python-dbus diff --git a/mopidy/config/__init__.py b/mopidy/config/__init__.py index 21a6a00b..ec5c9a99 100644 --- a/mopidy/config/__init__.py +++ b/mopidy/config/__init__.py @@ -9,12 +9,15 @@ import re from mopidy import compat from mopidy.compat import configparser from mopidy.config import keyring -from mopidy.config.schemas import * # noqa -from mopidy.config.types import * # noqa +from mopidy.config.schemas import * +from mopidy.config.types import * from mopidy.internal import path, versioning logger = logging.getLogger(__name__) +# flake8: noqa: +# TODO: Update this to be flake8 compliant + _core_schema = ConfigSchema('core') _core_schema['cache_dir'] = Path() _core_schema['config_dir'] = Path() diff --git a/tests/models/test_fields.py b/tests/models/test_fields.py index bf842fd5..3374c822 100644 --- a/tests/models/test_fields.py +++ b/tests/models/test_fields.py @@ -2,7 +2,7 @@ from __future__ import absolute_import, unicode_literals import unittest -from mopidy.models.fields import * # noqa: F403 +from mopidy.models.fields import Collection, Field, Integer, String def create_instance(field): diff --git a/tox.ini b/tox.ini index da6bcc38..b39fc68b 100644 --- a/tox.ini +++ b/tox.ini @@ -37,7 +37,8 @@ commands = sphinx-build -b html -d {envtmpdir}/doctrees . {envtmpdir}/html [testenv:flake8] deps = flake8 - flake8-import-order +# TODO: Re-enable once https://github.com/PyCQA/flake8-import-order/issues/79 is released. +# flake8-import-order pep8-naming commands = flake8 --show-source --statistics mopidy tests From 3ee91240a0c4bb4403ef1c636a12cd96300b40d7 Mon Sep 17 00:00:00 2001 From: Thomas Adamcik Date: Mon, 13 Jun 2016 22:44:03 +0200 Subject: [PATCH 24/49] Merge pull request #1496 from dublok/fix/1462-flac-seek-freeze audio: Ignore position of _on_position_changed callback (fixes #1462) --- mopidy/core/playback.py | 4 ++-- tests/core/test_playback.py | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/mopidy/core/playback.py b/mopidy/core/playback.py index ab96171e..da505b22 100644 --- a/mopidy/core/playback.py +++ b/mopidy/core/playback.py @@ -230,8 +230,8 @@ class PlaybackController(object): self._seek(self._pending_position) def _on_position_changed(self, position): - if self._pending_position == position: - self._trigger_seeked(position) + if self._pending_position is not None: + self._trigger_seeked(self._pending_position) self._pending_position = None def _on_about_to_finish_callback(self): diff --git a/tests/core/test_playback.py b/tests/core/test_playback.py index 3572800c..34c9d367 100644 --- a/tests/core/test_playback.py +++ b/tests/core/test_playback.py @@ -734,6 +734,7 @@ class EventEmissionTest(BaseTest): self.core.playback.play(tl_tracks[0]) self.trigger_about_to_finish(replay_until='stream_changed') + self.replay_events() listener_mock.reset_mock() self.core.playback.seek(1000) From 5e2b44ab44afd2e4db0387fae5e36578df7ef6d9 Mon Sep 17 00:00:00 2001 From: Thomas Adamcik Date: Mon, 13 Jun 2016 22:12:56 +0200 Subject: [PATCH 25/49] Merge pull request #1522 from SeppSTA/fix/1521-download-timeout-sec fix/1521 download timeout sec --- mopidy/stream/actor.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mopidy/stream/actor.py b/mopidy/stream/actor.py index 0861b5b0..1bdd05ca 100644 --- a/mopidy/stream/actor.py +++ b/mopidy/stream/actor.py @@ -68,7 +68,7 @@ class StreamLibraryProvider(backend.LibraryProvider): track = tags.convert_tags_to_track(scan_result.tags).replace( uri=uri, length=scan_result.duration) else: - logger.warning('Problem looking up %s: %s', uri) + logger.warning('Problem looking up %s', uri) track = Track(uri=uri) return [track] @@ -142,7 +142,7 @@ def _unwrap_stream(uri, timeout, scanner, requests_session): uri, timeout) return None, None content = http.download( - requests_session, uri, timeout=download_timeout) + requests_session, uri, timeout=download_timeout / 1000) if content is None: logger.info( From 0c6be281dfd01df80f0d4a95f925dace19b31f7c Mon Sep 17 00:00:00 2001 From: Thomas Adamcik Date: Mon, 25 Jul 2016 21:47:10 +0200 Subject: [PATCH 26/49] doc: Add changelog entry for PR#1496 and PR#1522 --- docs/changelog.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/changelog.rst b/docs/changelog.rst index 8830edd3..60255266 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -23,6 +23,9 @@ Bug fix release. (Fixes: :issue:`935`, :issue:`1453`, :issue:`1474` and :issue:`1480`, PR: :issue:`1487`) +- Audio: Better handling of seek when position does not match the expected + pending position. (Fixes: :issue:`1462` PR: :issue:`1496`) + - Core: Avoid endless loop if all tracks in the tracklist are unplayable and consume mode is off. (Fixes: :issue:`1221`, :issue:`1454`, PR: :issue:`1455`) @@ -30,6 +33,9 @@ Bug fix release. where a :confval:`file/media_dirs` path contained non-ASCII characters. (Fixes: :issue:`1345`, PR: :issue:`1493`) +- Stream: Fix milliseconds vs seconds mistake in timeout handling. + (Fixes: :issue:`1521` PR: :issue:`1522`) + v2.0.0 (2016-02-15) =================== From 692138a51e146d1b25a8d0db4ad057773406c6c5 Mon Sep 17 00:00:00 2001 From: Thomas Adamcik Date: Mon, 25 Jul 2016 22:00:51 +0200 Subject: [PATCH 27/49] Merge pull request #1525 from palfrey/dodgy-date-tags If the date in a tag is invalid, skip it --- mopidy/audio/tags.py | 13 +++++++++---- tests/audio/test_tags.py | 8 ++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/mopidy/audio/tags.py b/mopidy/audio/tags.py index 5ae86468..7fabefd6 100644 --- a/mopidy/audio/tags.py +++ b/mopidy/audio/tags.py @@ -44,10 +44,15 @@ gstreamer-GstTagList.html value = taglist.get_value_index(tag, i) if isinstance(value, GLib.Date): - date = datetime.date( - value.get_year(), value.get_month(), value.get_day()) - result[tag].append(date.isoformat().decode('utf-8')) - if isinstance(value, Gst.DateTime): + try: + date = datetime.date( + value.get_year(), value.get_month(), value.get_day()) + result[tag].append(date.isoformat().decode('utf-8')) + except ValueError: + logger.debug( + 'Ignoring dodgy date value: %d-%d-%d', + value.get_year(), value.get_month(), value.get_day()) + elif isinstance(value, Gst.DateTime): result[tag].append(value.to_iso8601_string().decode('utf-8')) elif isinstance(value, bytes): result[tag].append(value.decode('utf-8', 'replace')) diff --git a/tests/audio/test_tags.py b/tests/audio/test_tags.py index 01475124..d85bcc12 100644 --- a/tests/audio/test_tags.py +++ b/tests/audio/test_tags.py @@ -44,6 +44,14 @@ class TestConvertTaglist(object): assert isinstance(result[Gst.TAG_DATE][0], compat.text_type) assert result[Gst.TAG_DATE][0] == '2014-01-07' + def test_date_tag_bad_value(self): + date = GLib.Date.new_dmy(7, 1, 10000) + taglist = self.make_taglist(Gst.TAG_DATE, [date]) + + result = tags.convert_taglist(taglist) + + assert len(result[Gst.TAG_DATE]) == 0 + def test_date_time_tag(self): taglist = self.make_taglist(Gst.TAG_DATE_TIME, [ Gst.DateTime.new_from_iso8601_string(b'2014-01-07 14:13:12') From 44ff6697444574da3ad8035c1dc5eaaa4b34bfd1 Mon Sep 17 00:00:00 2001 From: Thomas Adamcik Date: Mon, 25 Jul 2016 22:05:34 +0200 Subject: [PATCH 28/49] Merge pull request #1534 from edran/fix-scrobbling Get correct track position on change events --- docs/changelog.rst | 4 ++++ mopidy/core/playback.py | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/docs/changelog.rst b/docs/changelog.rst index 60255266..8ed0bbb9 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -29,6 +29,10 @@ Bug fix release. - Core: Avoid endless loop if all tracks in the tracklist are unplayable and consume mode is off. (Fixes: :issue:`1221`, :issue:`1454`, PR: :issue:`1455`) +- Core: Correctly record the last position of a track when switching to another + one. Particularly relevant for `mopidy-scrobbler` users, as before it was + essentially unusable. (Fixes: :issue:`1456`, PR: :issue:`1534`) + - File: Ensure path comparision is done between bytestrings only. Fixes crash where a :confval:`file/media_dirs` path contained non-ASCII characters. (Fixes: :issue:`1345`, PR: :issue:`1493`) diff --git a/mopidy/core/playback.py b/mopidy/core/playback.py index da505b22..0106abf2 100644 --- a/mopidy/core/playback.py +++ b/mopidy/core/playback.py @@ -251,6 +251,12 @@ class PlaybackController(object): if self._state == PlaybackState.STOPPED: return + # Unless overridden by other calls (e.g. next / previous / stop) this + # will be the last position recorded until the track gets reassigned. + # TODO: Check if case when track.length isn't populated needs to be + # handled. + self._last_position = self._current_tl_track.track.length + pending = self.core.tracklist.eot_track(self._current_tl_track) # avoid endless loop if 'repeat' is 'true' and no track is playable # * 2 -> second run to get all playable track in a shuffled playlist @@ -394,6 +400,10 @@ class PlaybackController(object): if not backend: return False + # This must happen before prepare_change gets called, otherwise the + # backend flushes the information of the track. + self._last_position = self.get_time_position() + # TODO: Wrap backend call in error handling. backend.playback.prepare_change() From c1679964ff2a5062ddc637cb3add9d3938cc05b1 Mon Sep 17 00:00:00 2001 From: Thomas Adamcik Date: Mon, 25 Jul 2016 22:09:52 +0200 Subject: [PATCH 29/49] docs: Add PR#1525 and PR#1517 to changelog --- docs/changelog.rst | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 8ed0bbb9..e63204c5 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -24,7 +24,11 @@ Bug fix release. :issue:`1487`) - Audio: Better handling of seek when position does not match the expected - pending position. (Fixes: :issue:`1462` PR: :issue:`1496`) + pending position. (Fixes: :issue:`1462`, PR: :issue:`1496`) + +- Audio: Handle bad date tags from audio, thanks to Mario Lang and Tom Parker + who fixed this in parallel. (Fixes: :issue:`1506`, PR: :issue:`1525`, + :issue:`1517`) - Core: Avoid endless loop if all tracks in the tracklist are unplayable and consume mode is off. (Fixes: :issue:`1221`, :issue:`1454`, PR: :issue:`1455`) @@ -38,7 +42,7 @@ Bug fix release. (Fixes: :issue:`1345`, PR: :issue:`1493`) - Stream: Fix milliseconds vs seconds mistake in timeout handling. - (Fixes: :issue:`1521` PR: :issue:`1522`) + (Fixes: :issue:`1521`, PR: :issue:`1522`) v2.0.0 (2016-02-15) From 242a771062ab4da277096cdd94f73e1aab118ced Mon Sep 17 00:00:00 2001 From: Thomas Adamcik Date: Mon, 25 Jul 2016 23:48:53 +0200 Subject: [PATCH 30/49] docs: Add sphinx_rtd_theme in docs/requirements.txt --- docs/requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/requirements.txt b/docs/requirements.txt index c75793d9..62c7e3e5 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,2 +1,3 @@ Sphinx >= 1.0 +sphinx_rtd_theme pygraphviz From ad4225d38d717d1c1e88e4ca517419290995c914 Mon Sep 17 00:00:00 2001 From: Thomas Adamcik Date: Tue, 26 Jul 2016 21:16:31 +0200 Subject: [PATCH 31/49] audio: Make scanner handle media with not duration (Fixes: #1526) --- docs/changelog.rst | 3 +++ mopidy/audio/scan.py | 20 +++++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index e63204c5..c69514da 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -30,6 +30,9 @@ Bug fix release. who fixed this in parallel. (Fixes: :issue:`1506`, PR: :issue:`1525`, :issue:`1517`) +- Audio: Make sure scanner handles streams without a duration. + (Fixes: :issue:`1526`) + - Core: Avoid endless loop if all tracks in the tracklist are unplayable and consume mode is off. (Fixes: :issue:`1221`, :issue:`1454`, PR: :issue:`1455`) diff --git a/mopidy/audio/scan.py b/mopidy/audio/scan.py index 27888638..f99c4489 100644 --- a/mopidy/audio/scan.py +++ b/mopidy/audio/scan.py @@ -135,6 +135,17 @@ def _start_pipeline(pipeline): pipeline.set_state(Gst.State.PLAYING) +def _query_duration(pipeline): + success, duration = pipeline.query_duration(Gst.Format.TIME) + if not success: + duration = None # Make sure error case preserves None. + elif duration < 0: + duration = None # Stream without duration. + else: + duration = duration // Gst.MSECOND + return success, duration + + def _query_seekable(pipeline): query = Gst.Query.new_seeking(Gst.Format.TIME) pipeline.query(query) @@ -187,13 +198,8 @@ def _process(pipeline, timeout_ms): elif message.type == Gst.MessageType.EOS: return tags, mime, have_audio, duration elif message.type == Gst.MessageType.ASYNC_DONE: - success, duration = pipeline.query_duration(Gst.Format.TIME) - if success: - duration = duration // Gst.MSECOND - else: - duration = None - - if tags and duration is not None: + success, duration = _query_duration(pipeline) + if tags and success: return tags, mime, have_audio, duration # Workaround for upstream bug which causes tags/duration to arrive From e594d560ff66b9795fb744e64d3ddd378d37b148 Mon Sep 17 00:00:00 2001 From: Thomas Adamcik Date: Tue, 26 Jul 2016 21:33:16 +0200 Subject: [PATCH 32/49] audio: Make sure tags are never none (Fixes #1449) --- docs/changelog.rst | 2 ++ mopidy/audio/actor.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index c69514da..e82b2d06 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -33,6 +33,8 @@ Bug fix release. - Audio: Make sure scanner handles streams without a duration. (Fixes: :issue:`1526`) +- Audio: Ensure audio tags are never `None`. (Fixes: :issue:`1449`) + - Core: Avoid endless loop if all tracks in the tracklist are unplayable and consume mode is off. (Fixes: :issue:`1221`, :issue:`1454`, PR: :issue:`1455`) diff --git a/mopidy/audio/actor.py b/mopidy/audio/actor.py index 1fb4fec6..61a8e008 100644 --- a/mopidy/audio/actor.py +++ b/mopidy/audio/actor.py @@ -368,7 +368,7 @@ class _Handler(object): # Emit any postponed tags that we got after about-to-finish. tags, self._audio._pending_tags = self._audio._pending_tags, None - self._audio._tags = tags + self._audio._tags = tags or {} if tags: logger.debug('Audio event: tags_changed(tags=%r)', tags.keys()) From 8707a7c9cf1d581911b76b2379fab8d014044e3b Mon Sep 17 00:00:00 2001 From: Thomas Adamcik Date: Tue, 26 Jul 2016 21:41:49 +0200 Subject: [PATCH 33/49] lint: Re-enable flake8-import-order --- tox.ini | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index b39fc68b..da6bcc38 100644 --- a/tox.ini +++ b/tox.ini @@ -37,8 +37,7 @@ commands = sphinx-build -b html -d {envtmpdir}/doctrees . {envtmpdir}/html [testenv:flake8] deps = flake8 -# TODO: Re-enable once https://github.com/PyCQA/flake8-import-order/issues/79 is released. -# flake8-import-order + flake8-import-order pep8-naming commands = flake8 --show-source --statistics mopidy tests From 02a2788da0e52d73675d9fa665ebb70747e9e381 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Sun, 7 Aug 2016 08:37:44 +0200 Subject: [PATCH 34/49] docs: Cleanup changelog --- docs/changelog.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index e82b2d06..4dfa761d 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -20,7 +20,7 @@ Bug fix release. - Audio: Update scan logic to workaround GStreamer issue where tags and duration might only be available after we start playing. - (Fixes: :issue:`935`, :issue:`1453`, :issue:`1474` and :issue:`1480`, PR: + (Fixes: :issue:`935`, :issue:`1453`, :issue:`1474`, :issue:`1480`, PR: :issue:`1487`) - Audio: Better handling of seek when position does not match the expected @@ -33,13 +33,13 @@ Bug fix release. - Audio: Make sure scanner handles streams without a duration. (Fixes: :issue:`1526`) -- Audio: Ensure audio tags are never `None`. (Fixes: :issue:`1449`) +- Audio: Ensure audio tags are never ``None``. (Fixes: :issue:`1449`) - Core: Avoid endless loop if all tracks in the tracklist are unplayable and consume mode is off. (Fixes: :issue:`1221`, :issue:`1454`, PR: :issue:`1455`) - Core: Correctly record the last position of a track when switching to another - one. Particularly relevant for `mopidy-scrobbler` users, as before it was + one. Particularly relevant for Mopidy-Scrobbler users, as before it was essentially unusable. (Fixes: :issue:`1456`, PR: :issue:`1534`) - File: Ensure path comparision is done between bytestrings only. Fixes crash From 4ec06ef8f969f1a4aa17e40020c403aa87a494cc Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Sun, 7 Aug 2016 08:37:55 +0200 Subject: [PATCH 35/49] docs: Remove broken download stats --- README.rst | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.rst b/README.rst index 88072eb5..6720e9e8 100644 --- a/README.rst +++ b/README.rst @@ -61,10 +61,6 @@ To get started with Mopidy, check out :target: https://pypi.python.org/pypi/Mopidy/ :alt: Latest PyPI version -.. image:: https://img.shields.io/pypi/dm/Mopidy.svg?style=flat - :target: https://pypi.python.org/pypi/Mopidy/ - :alt: Number of PyPI downloads - .. image:: https://img.shields.io/travis/mopidy/mopidy/develop.svg?style=flat :target: https://travis-ci.org/mopidy/mopidy :alt: Travis CI build status From 12e0c87c99f56a03d5af764023aada70a7edbb7b Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Sun, 7 Aug 2016 08:51:20 +0200 Subject: [PATCH 36/49] docs: Fix warnings about unknown options --- docs/changelog.rst | 57 +++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 4dfa761d..7f0e5508 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -2091,10 +2091,10 @@ A release with a number of small and medium fixes, with no specific focus. - Converted from the optparse to the argparse library for handling command line options. -- :option:`mopidy --show-config` will now take into consideration any +- ``mopidy --show-config`` will now take into consideration any :option:`mopidy --option` arguments appearing later on the command line. This helps you see the effective configuration for runs with the same - :option:`mopidy --options` arguments. + ``mopidy --options`` arguments. **Audio** @@ -2168,7 +2168,7 @@ v0.14.1 (2013-04-28) ==================== This release addresses an issue in v0.14.0 where the new -:option:`mopidy-convert-config` tool and the new :option:`mopidy --option` +``mopidy-convert-config`` tool and the new :option:`mopidy --option` command line option was broken because some string operations inadvertently converted some byte strings to unicode. @@ -2198,7 +2198,7 @@ one new. As part of this change we have cleaned up the naming of our config values. - To ease migration we've made a tool named :option:`mopidy-convert-config` for + To ease migration we've made a tool named ``mopidy-convert-config`` for automatically converting the old ``settings.py`` to a new ``mopidy.conf`` file. This tool takes care of all the renamed config values as well. See ``mopidy-convert-config`` for details on how to use it. @@ -2231,11 +2231,11 @@ one new. **Command line options** -- The command option :option:`mopidy --list-settings` is now named - :option:`mopidy --show-config`. +- The command option ``mopidy --list-settings`` is now named + ``mopidy --show-config``. -- The command option :option:`mopidy --list-deps` is now named - :option:`mopidy --show-deps`. +- The command option ``mopidy --list-deps`` is now named + ``mopidy --show-deps``. - What configuration files to use can now be specified through the command option :option:`mopidy --config`, multiple files can be specified using colon @@ -2245,8 +2245,8 @@ one new. :option:`mopidy --option`. For example: ``mopidy --option spotify/enabled=false``. -- The GStreamer command line options, :option:`mopidy --gst-*` and - :option:`mopidy --help-gst` are no longer supported. To set GStreamer debug +- The GStreamer command line options, ``mopidy --gst-*`` and + ``mopidy --help-gst`` are no longer supported. To set GStreamer debug flags, you can use environment variables such as :envvar:`GST_DEBUG`. Refer to GStreamer's documentation for details. @@ -2295,7 +2295,7 @@ already have. **Core** - Removed the :attr:`mopidy.settings.DEBUG_THREAD` setting and the - :option:`--debug-thread` command line option. Sending SIGUSR1 to + ``mopidy --debug-thread`` command line option. Sending SIGUSR1 to the Mopidy process will now always make it log tracebacks for all alive threads. @@ -2576,9 +2576,8 @@ We've added an HTTP frontend for those wanting to build web clients for Mopidy! - Make ``mopidy-scan`` ignore invalid dates, e.g. dates in years outside the range 1-9999. -- Make ``mopidy-scan`` accept :option:`-q`/:option:`--quiet` and - :option:`-v`/:option:`--verbose` options to control the amount of logging - output when scanning. +- Make ``mopidy-scan`` accept ``-q``/``--quiet`` and ``-v``/``--verbose`` + options to control the amount of logging output when scanning. - The scanner can now handle files with other encodings than UTF-8. Rebuild your tag cache with ``mopidy-scan`` to include tracks that may have been @@ -2703,7 +2702,7 @@ long time been our most requested feature. Finally, it's here! **Developer support** - Added optional background thread for debugging deadlocks. When the feature is - enabled via the ``--debug-thread`` option or + enabled via the ``mopidy --debug-thread`` option or :attr:`mopidy.settings.DEBUG_THREAD` setting a ``SIGUSR1`` signal will dump the traceback for all running threads. @@ -2915,9 +2914,9 @@ resolved a bunch of related issues. known setting, and suggests to the user what we think the setting should have been. -- Added :option:`--list-deps` option to the ``mopidy`` command that lists - required and optional dependencies, their current versions, and some other - information useful for debugging. (Fixes: :issue:`74`) +- Added ``mopidy --list-deps`` option that lists required and optional + dependencies, their current versions, and some other information useful for + debugging. (Fixes: :issue:`74`) - Added ``tools/debug-proxy.py`` to tee client requests to two backends and diff responses. Intended as a developer tool for checking for MPD protocol @@ -3197,12 +3196,12 @@ Please note that 0.5.0 requires some updated dependencies, as listed under - Command line usage: - - Support passing options to GStreamer. See :option:`--help-gst` for a list + - Support passing options to GStreamer. See ``mopidy --help-gst`` for a list of available options. (Fixes: :issue:`95`) - - Improve :option:`--list-settings` output. (Fixes: :issue:`91`) + - Improve ``mopidy --list-settings`` output. (Fixes: :issue:`91`) - - Added :option:`--interactive` for reading missing local settings from + - Added ``mopidy --interactive`` for reading missing local settings from ``stdin``. (Fixes: :issue:`96`) - Improve shutdown procedure at CTRL+C. Add signal handler for ``SIGTERM``, @@ -3345,8 +3344,8 @@ loading from Mopidy 0.3.0 is still present. - Settings: - - Fix crash on ``--list-settings`` on clean installation. Thanks to Martins - Grunskis for the bug report and patch. (Fixes: :issue:`63`) + - Fix crash on ``mopidy --list-settings`` on clean installation. Thanks to + Martins Grunskis for the bug report and patch. (Fixes: :issue:`63`) - Packaging: @@ -3574,11 +3573,11 @@ to Valentin David. - Simplify the default log format, :attr:`mopidy.settings.CONSOLE_LOG_FORMAT`. From a user's point of view: Less noise, more information. - - Rename the :option:`--dump` command line option to - :option:`--save-debug-log`. + - Rename the ``mopidy --dump`` command line option to + :option:`mopidy --save-debug-log`. - Rename setting :attr:`mopidy.settings.DUMP_LOG_FORMAT` to - :attr:`mopidy.settings.DEBUG_LOG_FORMAT` and use it for :option:`--verbose` - too. + :attr:`mopidy.settings.DEBUG_LOG_FORMAT` and use it for + :option:`mopidy --verbose` too. - Rename setting :attr:`mopidy.settings.DUMP_LOG_FILENAME` to :attr:`mopidy.settings.DEBUG_LOG_FILENAME`. @@ -3644,7 +3643,7 @@ fixing the OS X issues for a future release. You can track the progress at - Exit early if not Python >= 2.6, < 3. - Validate settings at startup and print useful error messages if the settings has not been updated or anything is misspelled. -- Add command line option :option:`--list-settings` to print the currently +- Add command line option ``mopidy --list-settings`` to print the currently active settings. - Include Sphinx scripts for building docs, pylintrc, tests and test data in the packages created by ``setup.py`` for i.e. PyPI. @@ -3826,7 +3825,7 @@ the established pace of at least a release per month. - Improvements to MPD protocol handling, making Mopidy work much better with a group of clients, including ncmpc, MPoD, and Theremin. -- New command line flag :option:`--dump` for dumping debug log to ``dump.log`` +- New command line flag ``mopidy --dump`` for dumping debug log to ``dump.log`` in the current directory. - New setting :attr:`mopidy.settings.MIXER_ALSA_CONTROL` for forcing what ALSA control :class:`mopidy.mixers.alsa.AlsaMixer` should use. From 0d16502da130c9311b6523e316849ac8d0fc2764 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Sun, 7 Aug 2016 08:58:13 +0200 Subject: [PATCH 37/49] docs: Require Pykka for docs building (fixes #1500) Pykka is a pure Python dependency, so we might as well depend on it for docs building so that :autoclass: works on Pykka subclasses in the docs. --- docs/changelog.rst | 5 +++++ docs/conf.py | 1 - docs/requirements.txt | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 7f0e5508..22199087 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -49,6 +49,11 @@ Bug fix release. - Stream: Fix milliseconds vs seconds mistake in timeout handling. (Fixes: :issue:`1521`, PR: :issue:`1522`) +- Docs: Fix the rendering of :class:`mopidy.core.Core` and + :class:`mopidy.audio.Audio` docs. This should also contribute towards making + the Mopidy Debian package build bit-by-bit reproducible. (Fixes: + :issue:`1500`) + v2.0.0 (2016-02-15) =================== diff --git a/docs/conf.py b/docs/conf.py index 208822a2..cb04a671 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -40,7 +40,6 @@ MOCK_MODULES = [ 'dbus.mainloop.glib', 'dbus.service', 'mopidy.internal.gi', - 'pykka', ] for mod_name in MOCK_MODULES: sys.modules[mod_name] = Mock() diff --git a/docs/requirements.txt b/docs/requirements.txt index 62c7e3e5..f0cc5e6c 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,3 +1,4 @@ Sphinx >= 1.0 -sphinx_rtd_theme pygraphviz +Pykka >= 1.1 +sphinx_rtd_theme From 3e12ed1f69d63bbab57d0bcde1ff9f6a7d2674d6 Mon Sep 17 00:00:00 2001 From: Thomas Adamcik Date: Thu, 28 Jul 2016 21:16:21 +0200 Subject: [PATCH 38/49] audio: Postpone set_metadata until track is playing --- docs/changelog.rst | 3 +++ mopidy/audio/actor.py | 14 +++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 22199087..a13baa3d 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -35,6 +35,9 @@ Bug fix release. - Audio: Ensure audio tags are never ``None``. (Fixes: :issue:`1449`) +- Audio: Update :meth:`mopidy.audio.Audio.set_metadata` to postpone sending + tags if there is a pending track change. (Fixes: :issue:`1357`) + - Core: Avoid endless loop if all tracks in the tracklist are unplayable and consume mode is off. (Fixes: :issue:`1221`, :issue:`1454`, PR: :issue:`1455`) diff --git a/mopidy/audio/actor.py b/mopidy/audio/actor.py index 61a8e008..f96834e7 100644 --- a/mopidy/audio/actor.py +++ b/mopidy/audio/actor.py @@ -374,6 +374,10 @@ class _Handler(object): logger.debug('Audio event: tags_changed(tags=%r)', tags.keys()) AudioListener.send('tags_changed', tags=tags.keys()) + if self._audio._pending_metadata: + self._audio._playbin.send_event(self._audio._pending_metadata) + self._audio._pending_metadata = None + def on_segment(self, segment): gst_logger.debug( 'Got SEGMENT pad event: ' @@ -412,6 +416,7 @@ class Audio(pykka.ThreadingActor): self._tags = {} self._pending_uri = None self._pending_tags = None + self._pending_metadata = None self._playbin = None self._outputs = None @@ -800,12 +805,11 @@ class Audio(pykka.ThreadingActor): if track.album and track.album.name: set_value(Gst.TAG_ALBUM, track.album.name) - gst_logger.debug( - 'Sending TAG event for track %r: %r', - track.uri, taglist.to_string()) event = Gst.Event.new_tag(taglist) - # TODO: check if we get this back on our own bus? - self._playbin.send_event(event) + if not self._pending_uri: + self._playbin.send_event(event) + else: + self._pending_metadata = event def get_current_tags(self): """ From 5e8682cc51d751bef70c7e7a795f91ac9be9ed24 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Sun, 7 Aug 2016 09:24:45 +0200 Subject: [PATCH 39/49] audio: Address my own comments on PR#1538 --- docs/changelog.rst | 3 ++- mopidy/audio/actor.py | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index a13baa3d..84bac249 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -36,7 +36,8 @@ Bug fix release. - Audio: Ensure audio tags are never ``None``. (Fixes: :issue:`1449`) - Audio: Update :meth:`mopidy.audio.Audio.set_metadata` to postpone sending - tags if there is a pending track change. (Fixes: :issue:`1357`) + tags if there is a pending track change. (Fixes: :issue:`1357`, PR: + :issue:`1538`) - Core: Avoid endless loop if all tracks in the tracklist are unplayable and consume mode is off. (Fixes: :issue:`1221`, :issue:`1454`, PR: :issue:`1455`) diff --git a/mopidy/audio/actor.py b/mopidy/audio/actor.py index f96834e7..6020bc1b 100644 --- a/mopidy/audio/actor.py +++ b/mopidy/audio/actor.py @@ -805,11 +805,14 @@ class Audio(pykka.ThreadingActor): if track.album and track.album.name: set_value(Gst.TAG_ALBUM, track.album.name) + gst_logger.debug( + 'Sending TAG event for track %r: %r', + track.uri, taglist.to_string()) event = Gst.Event.new_tag(taglist) - if not self._pending_uri: - self._playbin.send_event(event) - else: + if self._pending_uri: self._pending_metadata = event + else: + self._playbin.send_event(event) def get_current_tags(self): """ From a3164ca43b29fc67cf3dfe6b4eba79bbea58ae46 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Sun, 7 Aug 2016 09:30:46 +0200 Subject: [PATCH 40/49] docs: PR#1496 fixed #1505 --- docs/changelog.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 84bac249..d6548865 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -24,7 +24,7 @@ Bug fix release. :issue:`1487`) - Audio: Better handling of seek when position does not match the expected - pending position. (Fixes: :issue:`1462`, PR: :issue:`1496`) + pending position. (Fixes: :issue:`1462`, :issue:`1505`, PR: :issue:`1496`) - Audio: Handle bad date tags from audio, thanks to Mario Lang and Tom Parker who fixed this in parallel. (Fixes: :issue:`1506`, PR: :issue:`1525`, From 6a01a2e90618a78201175f09f4b5a12841bea409 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Sun, 7 Aug 2016 21:25:46 +0200 Subject: [PATCH 41/49] models: Test Identifier field type --- tests/models/test_fields.py | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/tests/models/test_fields.py b/tests/models/test_fields.py index 3374c822..69f4cd91 100644 --- a/tests/models/test_fields.py +++ b/tests/models/test_fields.py @@ -2,7 +2,7 @@ from __future__ import absolute_import, unicode_literals import unittest -from mopidy.models.fields import Collection, Field, Integer, String +from mopidy.models.fields import Collection, Field, Identifier, Integer, String def create_instance(field): @@ -126,6 +126,37 @@ class StringTest(unittest.TestCase): self.assertEqual('', instance.attr) +class IdentifierTest(unittest.TestCase): + def test_default_handling(self): + instance = create_instance(Identifier(default='abc')) + self.assertEqual('abc', instance.attr) + + def test_native_str_allowed(self): + instance = create_instance(Identifier()) + instance.attr = str('abc') + self.assertEqual('abc', instance.attr) + + def test_bytes_allowed(self): + instance = create_instance(Identifier()) + instance.attr = b'abc' + self.assertEqual(b'abc', instance.attr) + + def test_unicode_allowed(self): + instance = create_instance(Identifier()) + instance.attr = u'abc' + self.assertEqual(u'abc', instance.attr) + + def test_other_disallowed(self): + instance = create_instance(Identifier()) + with self.assertRaises(TypeError): + instance.attr = 1234 + + def test_empty_string(self): + instance = create_instance(Identifier()) + instance.attr = '' + self.assertEqual('', instance.attr) + + class IntegerTest(unittest.TestCase): def test_default_handling(self): instance = create_instance(Integer(default=1234)) From 2d4439a03a16766ceaabd0e3deb4e1c07b6b4803 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Sun, 7 Aug 2016 21:25:36 +0200 Subject: [PATCH 42/49] audio: Formatting --- mopidy/audio/tags.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mopidy/audio/tags.py b/mopidy/audio/tags.py index 7fabefd6..e4d86dc7 100644 --- a/mopidy/audio/tags.py +++ b/mopidy/audio/tags.py @@ -136,12 +136,11 @@ def convert_tags_to_track(tags): return Track(**track_kwargs) -def _artists( - tags, artist_name, artist_id=None, artist_sortname=None): - +def _artists(tags, artist_name, artist_id=None, artist_sortname=None): # Name missing, don't set artist if not tags.get(artist_name): return None + # One artist name and either id or sortname, include all available fields if len(tags[artist_name]) == 1 and \ (artist_id in tags or artist_sortname in tags): From 4e91f289448b99df62af5b1a890d04d968e3eb02 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Tue, 9 Aug 2016 22:37:44 +0200 Subject: [PATCH 43/49] docs: Remove GlobalSign as cert has expired --- docs/sponsors.rst | 7 ------- 1 file changed, 7 deletions(-) diff --git a/docs/sponsors.rst b/docs/sponsors.rst index 2d8b7f4e..2528247b 100644 --- a/docs/sponsors.rst +++ b/docs/sponsors.rst @@ -31,10 +31,3 @@ accelerate requests to all Mopidy services, including: - https://dl.mopidy.com/pimusicbox/, which is used to distribute Pi Musicbox images. - - -GlobalSign -========== - -`GlobalSign `_ provides Mopidy with a free SSL -certificate for mopidy.com, which we use to secure access to all our web sites. From 3346778c4118f6e6e3f679d4b1280e4b47b50de3 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Sun, 7 Aug 2016 21:29:14 +0200 Subject: [PATCH 44/49] models: Fix encoding error in Identifier field Fixes #1508 --- docs/changelog.rst | 4 ++++ mopidy/models/fields.py | 7 +++++-- tests/models/test_fields.py | 7 +++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index d6548865..8a3fd869 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -46,6 +46,10 @@ Bug fix release. one. Particularly relevant for Mopidy-Scrobbler users, as before it was essentially unusable. (Fixes: :issue:`1456`, PR: :issue:`1534`) +- Models: Fix encoding error if :class:`~mopidy.models.fields.Identifier` + fields, like the ``musicbrainz_id`` model fields, contained non-ASCII Unicode + data. (Fixes: :issue:`1508`, PR: :issue:`1546`) + - File: Ensure path comparision is done between bytestrings only. Fixes crash where a :confval:`file/media_dirs` path contained non-ASCII characters. (Fixes: :issue:`1345`, PR: :issue:`1493`) diff --git a/mopidy/models/fields.py b/mopidy/models/fields.py index c686b447..c5800eba 100644 --- a/mopidy/models/fields.py +++ b/mopidy/models/fields.py @@ -88,14 +88,17 @@ class Date(String): class Identifier(String): """ - :class:`Field` for storing ASCII values such as GUIDs or other identifiers. + :class:`Field` for storing values such as GUIDs or other identifiers. Values will be interned. :param default: default value for field """ def validate(self, value): - return compat.intern(str(super(Identifier, self).validate(value))) + value = super(Identifier, self).validate(value) + if isinstance(value, compat.text_type): + value = value.encode('utf-8') + return compat.intern(value) class URI(Identifier): diff --git a/tests/models/test_fields.py b/tests/models/test_fields.py index 69f4cd91..a4788e4d 100644 --- a/tests/models/test_fields.py +++ b/tests/models/test_fields.py @@ -1,3 +1,5 @@ +# encoding: utf-8 + from __future__ import absolute_import, unicode_literals import unittest @@ -146,6 +148,11 @@ class IdentifierTest(unittest.TestCase): instance.attr = u'abc' self.assertEqual(u'abc', instance.attr) + def test_unicode_with_nonascii_allowed(self): + instance = create_instance(Identifier()) + instance.attr = u'æøå' + self.assertEqual(u'æøå'.encode('utf-8'), instance.attr) + def test_other_disallowed(self): instance = create_instance(Identifier()) with self.assertRaises(TypeError): From 4c3309814f61a67c4baa2a92914e030ab3c9240e Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Fri, 12 Aug 2016 01:16:53 +0200 Subject: [PATCH 45/49] docs: Fix typos in changelog --- docs/changelog.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 8a3fd869..f3482ea2 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -50,7 +50,7 @@ Bug fix release. fields, like the ``musicbrainz_id`` model fields, contained non-ASCII Unicode data. (Fixes: :issue:`1508`, PR: :issue:`1546`) -- File: Ensure path comparision is done between bytestrings only. Fixes crash +- File: Ensure path comparison is done between bytestrings only. Fixes crash where a :confval:`file/media_dirs` path contained non-ASCII characters. (Fixes: :issue:`1345`, PR: :issue:`1493`) @@ -401,7 +401,7 @@ Bug fix release. proceed startup. (Fixes: :issue:`1248`, PR: :issue:`1254`) - Stream: Fix bug in new playlist parser. A non-ASCII char in an urilist - comment would cause a crash while parsing due to comparision of a non-ASCII + comment would cause a crash while parsing due to comparison of a non-ASCII bytestring with a Unicode string. (Fixes: :issue:`1265`) - File: Adjust log levels when failing to expand ``$XDG_MUSIC_DIR`` into a real From 1ec465bb5dfd75d38588cf3e5960319309ec17c8 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Fri, 12 Aug 2016 20:50:19 +0200 Subject: [PATCH 46/49] docs: Add v2.0.1 release date --- docs/changelog.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index f3482ea2..97ac8676 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -5,7 +5,7 @@ Changelog This changelog is used to track all major changes to Mopidy. -v2.0.1 (UNRELEASED) +v2.0.1 (2016-08-16) =================== Bug fix release. From 30115192312c9da764c9b22439f59f646f917aef Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Fri, 12 Aug 2016 20:51:15 +0200 Subject: [PATCH 47/49] Bump version to 2.0.1 --- docs/releasing.rst | 3 +-- mopidy/__init__.py | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/releasing.rst b/docs/releasing.rst index 8d489146..5bd4dfeb 100644 --- a/docs/releasing.rst +++ b/docs/releasing.rst @@ -13,8 +13,7 @@ Creating releases #. Update changelog and commit it. -#. Bump the version number in ``mopidy/__init__.py``. Remember to update the - test case in ``tests/test_version.py``. +#. Bump the version number in ``mopidy/__init__.py``. #. Merge the release branch (``develop`` in the example) into master:: diff --git a/mopidy/__init__.py b/mopidy/__init__.py index 4a6370e8..184f5991 100644 --- a/mopidy/__init__.py +++ b/mopidy/__init__.py @@ -14,4 +14,4 @@ if not (2, 7) <= sys.version_info < (3,): warnings.filterwarnings('ignore', 'could not open display') -__version__ = '2.0.0' +__version__ = '2.0.1' From 5973c0f6b9e3b63e00698b958287827e50422866 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Fri, 12 Aug 2016 21:19:43 +0200 Subject: [PATCH 48/49] docs: Deb packaging is done on Debian infrastructure as part of the pkg-mopidy team --- docs/releasing.rst | 92 +--------------------------------------------- 1 file changed, 2 insertions(+), 90 deletions(-) diff --git a/docs/releasing.rst b/docs/releasing.rst index 5bd4dfeb..e7ef251c 100644 --- a/docs/releasing.rst +++ b/docs/releasing.rst @@ -62,93 +62,5 @@ Creating releases #. Spread the word through the topic on #mopidy on IRC, @mopidy on Twitter, and on the mailing list. -#. Update the Debian package. - - -Updating Debian packages -======================== - -This howto is not intended to learn you all the details, just to give someone -already familiar with Debian packaging an overview of how Mopidy's Debian -packages is maintained. - -#. Install the basic packaging tools:: - - sudo apt-get install build-essential git-buildpackage - -#. Create a Wheezy pbuilder env if running on Ubuntu and this the first time. - See :issue:`561` for details about why this is needed:: - - DIST=wheezy sudo git-pbuilder update --mirror=http://mirror.rackspace.com/debian/ --debootstrapopts --keyring=/usr/share/keyrings/debian-archive-keyring.gpg - -#. Check out the ``debian`` branch of the repo:: - - git checkout -t origin/debian - git pull - -#. Merge the latest release tag into the ``debian`` branch:: - - git merge v0.16.0 - -#. Update the ``debian/changelog`` with a "New upstream release" entry:: - - dch -v 0.16.0-0mopidy1 - git add debian/changelog - git commit -m "debian: New upstream release" - -#. Check if any dependencies in ``debian/control`` or similar needs updating. - -#. Install any Build-Deps listed in ``debian/control``. - -#. Build the package and fix any issues repeatedly until the build succeeds and - the Lintian check at the end of the build is satisfactory:: - - git buildpackage -uc -us - - If you are using the pbuilder make sure this command is:: - - sudo git buildpackage -uc -us --git-ignore-new --git-pbuilder --git-dist=wheezy --git-no-pbuilder-autoconf - -#. Install and test newly built package:: - - sudo debi - - Again for pbuilder use:: - - sudo debi --debs-dir /var/cache/pbuilder/result/ - -#. If everything is OK, build the package a final time to tag the package - version:: - - git buildpackage -uc -us --git-tag - - Pbuilder:: - - sudo git buildpackage -uc -us --git-ignore-new --git-pbuilder --git-dist=wheezy --git-no-pbuilder-autoconf --git-tag - -#. Push the changes you've done to the ``debian`` branch and the new tag:: - - git push - git push --tags - -#. If you're building for multiple architectures, checkout the ``debian`` - branch on the other builders and run:: - - git buildpackage -uc -us - - Modify as above to use the pbuilder as needed. - -#. Copy files to the APT server. Make sure to select the correct part of the - repo, e.g. main, contrib, or non-free:: - - scp ../mopidy*_0.16* bonobo.mopidy.com:/srv/apt.mopidy.com/app/incoming/stable/main - -#. Update the APT repo:: - - ssh bonobo.mopidy.com - /srv/apt.mopidy.com/app/update.sh - -#. Test installation from apt.mopidy.com:: - - sudo apt-get update - sudo apt-get dist-upgrade +#. Notify distribution packagers, including but not limited to: Debian, Arch + Linux, Homebrew. From 633d87bdbdce054cbb6d4afa8cf06af6db42d25d Mon Sep 17 00:00:00 2001 From: Naglis Jonaitis Date: Wed, 17 Aug 2016 21:31:38 +0300 Subject: [PATCH 49/49] docs: Remove link to the Mopidy-LeftAsRain plugin --- docs/ext/backends.rst | 9 --------- 1 file changed, 9 deletions(-) diff --git a/docs/ext/backends.rst b/docs/ext/backends.rst index 2349006b..9e5f4a9c 100644 --- a/docs/ext/backends.rst +++ b/docs/ext/backends.rst @@ -97,15 +97,6 @@ Extension for playing music and audio from the `Internet Archive `_. -Mopidy-LeftAsRain -================= - -https://github.com/naglis/mopidy-leftasrain - -Extension for playing music from the `leftasrain.com -`_ music blog. - - Mopidy-Local ============