stream: Don't parse as playlist if playable
This commit is contained in:
parent
e361ac6b54
commit
6f32bdc083
@ -4,6 +4,16 @@ Changelog
|
|||||||
|
|
||||||
This changelog is used to track all major changes to Mopidy.
|
This changelog is used to track all major changes to Mopidy.
|
||||||
|
|
||||||
|
v1.1.2 (UNRELEASED)
|
||||||
|
===================
|
||||||
|
|
||||||
|
Bug fix release.
|
||||||
|
|
||||||
|
- Stream: If an URI is considered playable, don't consider it as a candidate
|
||||||
|
for playlist parsing. Just looking at MIME type prefixes isn't enough, as for
|
||||||
|
example Ogg Vorbis has the MIME type ``application/ogg``. (Fixes:
|
||||||
|
:issue:`1299`)
|
||||||
|
|
||||||
|
|
||||||
v1.1.1 (2015-09-14)
|
v1.1.1 (2015-09-14)
|
||||||
===================
|
===================
|
||||||
|
|||||||
@ -123,12 +123,14 @@ def _unwrap_stream(uri, timeout, scanner, requests_session):
|
|||||||
logger.debug('GStreamer failed scanning URI (%s): %s', uri, exc)
|
logger.debug('GStreamer failed scanning URI (%s): %s', uri, exc)
|
||||||
scan_result = None
|
scan_result = None
|
||||||
|
|
||||||
if scan_result is not None and not (
|
if scan_result is not None:
|
||||||
scan_result.mime.startswith('text/') or
|
if scan_result.playable or (
|
||||||
scan_result.mime.startswith('application/')):
|
not scan_result.mime.startswith('text/') and
|
||||||
logger.debug(
|
not scan_result.mime.startswith('application/')
|
||||||
'Unwrapped potential %s stream: %s', scan_result.mime, uri)
|
):
|
||||||
return uri
|
logger.debug(
|
||||||
|
'Unwrapped potential %s stream: %s', scan_result.mime, uri)
|
||||||
|
return uri
|
||||||
|
|
||||||
download_timeout = deadline - time.time()
|
download_timeout = deadline - time.time()
|
||||||
if download_timeout < 0:
|
if download_timeout < 0:
|
||||||
|
|||||||
@ -38,7 +38,9 @@ def audio():
|
|||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def scanner():
|
def scanner():
|
||||||
return mock.Mock(spec=scan.Scanner)
|
scan_mock = mock.Mock(spec=scan.Scanner)
|
||||||
|
scan_mock.scan.return_value = None
|
||||||
|
return scan_mock
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
@ -58,7 +60,24 @@ class TestTranslateURI(object):
|
|||||||
|
|
||||||
@responses.activate
|
@responses.activate
|
||||||
def test_audio_stream_returns_same_uri(self, scanner, provider):
|
def test_audio_stream_returns_same_uri(self, scanner, provider):
|
||||||
scanner.scan.return_value.mime = 'audio/mpeg'
|
scanner.scan.side_effect = [
|
||||||
|
# Set playable to False to test detection by mimetype
|
||||||
|
mock.Mock(mime='audio/mpeg', playable=False),
|
||||||
|
]
|
||||||
|
|
||||||
|
result = provider.translate_uri(STREAM_URI)
|
||||||
|
|
||||||
|
scanner.scan.assert_called_once_with(STREAM_URI, timeout=mock.ANY)
|
||||||
|
assert result == STREAM_URI
|
||||||
|
|
||||||
|
@responses.activate
|
||||||
|
def test_playable_ogg_stream_is_not_considered_a_playlist(
|
||||||
|
self, scanner, provider):
|
||||||
|
|
||||||
|
scanner.scan.side_effect = [
|
||||||
|
# Set playable to True to ignore detection as possible playlist
|
||||||
|
mock.Mock(mime='application/ogg', playable=True),
|
||||||
|
]
|
||||||
|
|
||||||
result = provider.translate_uri(STREAM_URI)
|
result = provider.translate_uri(STREAM_URI)
|
||||||
|
|
||||||
@ -70,8 +89,10 @@ class TestTranslateURI(object):
|
|||||||
self, scanner, provider, caplog):
|
self, scanner, provider, caplog):
|
||||||
|
|
||||||
scanner.scan.side_effect = [
|
scanner.scan.side_effect = [
|
||||||
mock.Mock(mime='text/foo'), # scanning playlist
|
# Scanning playlist
|
||||||
mock.Mock(mime='audio/mpeg'), # scanning stream
|
mock.Mock(mime='text/foo', playable=False),
|
||||||
|
# Scanning stream
|
||||||
|
mock.Mock(mime='audio/mpeg', playable=True),
|
||||||
]
|
]
|
||||||
responses.add(
|
responses.add(
|
||||||
responses.GET, PLAYLIST_URI,
|
responses.GET, PLAYLIST_URI,
|
||||||
@ -100,8 +121,10 @@ class TestTranslateURI(object):
|
|||||||
@responses.activate
|
@responses.activate
|
||||||
def test_xml_playlist_with_mpeg_stream(self, scanner, provider):
|
def test_xml_playlist_with_mpeg_stream(self, scanner, provider):
|
||||||
scanner.scan.side_effect = [
|
scanner.scan.side_effect = [
|
||||||
mock.Mock(mime='application/xspf+xml'), # scanning playlist
|
# Scanning playlist
|
||||||
mock.Mock(mime='audio/mpeg'), # scanning stream
|
mock.Mock(mime='application/xspf+xml', playable=False),
|
||||||
|
# Scanning stream
|
||||||
|
mock.Mock(mime='audio/mpeg', playable=True),
|
||||||
]
|
]
|
||||||
responses.add(
|
responses.add(
|
||||||
responses.GET, PLAYLIST_URI,
|
responses.GET, PLAYLIST_URI,
|
||||||
@ -120,8 +143,10 @@ class TestTranslateURI(object):
|
|||||||
self, scanner, provider, caplog):
|
self, scanner, provider, caplog):
|
||||||
|
|
||||||
scanner.scan.side_effect = [
|
scanner.scan.side_effect = [
|
||||||
exceptions.ScannerError('some failure'), # scanning playlist
|
# Scanning playlist
|
||||||
mock.Mock(mime='audio/mpeg'), # scanning stream
|
exceptions.ScannerError('some failure'),
|
||||||
|
# Scanning stream
|
||||||
|
mock.Mock(mime='audio/mpeg', playable=True),
|
||||||
]
|
]
|
||||||
responses.add(
|
responses.add(
|
||||||
responses.GET, PLAYLIST_URI,
|
responses.GET, PLAYLIST_URI,
|
||||||
@ -169,7 +194,9 @@ class TestTranslateURI(object):
|
|||||||
|
|
||||||
@responses.activate
|
@responses.activate
|
||||||
def test_playlist_references_itself(self, scanner, provider, caplog):
|
def test_playlist_references_itself(self, scanner, provider, caplog):
|
||||||
scanner.scan.return_value.mime = 'text/foo'
|
scanner.scan.side_effect = [
|
||||||
|
mock.Mock(mime='text/foo', playable=False)
|
||||||
|
]
|
||||||
responses.add(
|
responses.add(
|
||||||
responses.GET, PLAYLIST_URI,
|
responses.GET, PLAYLIST_URI,
|
||||||
body=BODY.replace(STREAM_URI, PLAYLIST_URI),
|
body=BODY.replace(STREAM_URI, PLAYLIST_URI),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user