New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add typefinding / MIME guess to scan code. #1033

merged 13 commits into from Mar 13, 2015


2 participants

adamcik commented Mar 12, 2015

With this in place we can scan a playlist without our playlist elements installed, check if it's text/* or application/xml try and urlopen it and parse it as a playlist (that is until we switch to totemplparser) without any gstreamer element magic.

This also improves:

  • Missing plugin messages on errors.
  • Seekable lookup which I want to try and use.
  • Got rid of some code that wasn't really doing much for us.

Changelog entry will be forthcoming tomorrow :-)

adamcik added some commits Mar 11, 2015

audio: Add support for checking seekable state in scanner
Return type of scanner changed to a named tuple with (uri, tags, duration,
seekable). This should help with #872 and the related "live" issues.

Tests, local scan and stream metadata lookup have been updated to account for
the changes.
audio: Switch to decodebin2 in scanner and handle our own sources
This is needed to be able to put in our own typefind and catch playlists before
they make it to the decoder.
audio: Add typefinder to scanner and add mime to result
This should allow us to move playlist handling out of GStreamer
as we will short circuit for text/* and application/xml now.
audio: Recreate scan pipeline for each scan
Turns out this code runs a lot faster when we fully destroy the decodebins
between scans. And since going to NULL isn't enough I opted to just go for
redoing the whole pipeline instead of adding and removing decodebins all the

As part of this almost all the logic has been ripped out of the scan class and
into internal functions. The external interface has been kept the same for now.
But we could easily switch to `scan(uri, timeout=1000, proxy=None)`
elif message.type == gst.MESSAGE_APPLICATION:
mime = message.structure.get_name()
if mime.startswith('text/') or mime == 'application/xml':

This comment has been minimized.


adamcik Mar 12, 2015


From the decodebin2 code I know that the only thing the explicitly mess with, and break for us is text/plain other things I might be able to let through and handle in a more generic way. Waiting for the error and then using the MIME, though that being said that could probably also be done for the text/plain case.

So the contract would basically be that we raise ScannerError(message, mime=mime) and then you can do stuff based on that instead of having MIME in the result.


This comment has been minimized.


jodal commented Mar 13, 2015

Reviewed both commit by commit and everything together. Looks good to me. No comments on anything in particular.


This comment has been minimized.


adamcik commented Mar 13, 2015

Two more quick code change, and the changelog as promised.

@adamcik adamcik added this to the v0.20 - Audio cleanup 1 milestone Mar 13, 2015

jodal added a commit that referenced this pull request Mar 13, 2015

Merge pull request #1033 from adamcik/feature/scanner-with-typefind
Add typefinding / MIME guess to scan code.

@jodal jodal merged commit 30badf6 into mopidy:develop Mar 13, 2015

2 checks passed

Scrutinizer 2 updated code elements
continuous-integration/travis-ci/pr The Travis CI build passed

@adamcik adamcik added the 3 - Done label Mar 13, 2015

@jodal jodal removed the 3 - Done label Mar 13, 2015

@adamcik adamcik deleted the adamcik:feature/scanner-with-typefind branch Mar 13, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment