Re: [mb-users] Track duration is None

Johannes Dewender <[email protected]> Wed, 17 Apr 2013 02:50:38 +0200
Newsgroups gmane.comp.audio.musicbrainz.user
Message-ID <7193961.BF8KfYrXms@haljo>
Am Dienstag 16 April 2013, 15:37:11 schrieb Jeffrey Barish:
> I am changing my code to use python-musicbrainzngs.  I figured that
> the change wouldn't be too hard because I am using MB only for simple
> operations. However, the documentation for musicbrainzngs seems
> incomplete.  I found get_releases_by_discid -- which looks relevant
> -- but I have not been able to figure out how to get a list of the
> tracks (release.tracks, previously).
> 
> I am looking at the documentation on this page:
> 
> https://python-musicbrainz-ngs.readthedocs.org/en/latest/api/#getting-> data
> 
> Is that the right place to be looking?  Are there any examples other
> than query.py, collection.py, and releasesearch.py?  All I need to
> know is how to get information about the recording (artist, title)
> and the tracks (title, duration).

get_releases_by_discid is a bit of a mess, since what you get are no 
releases. You get "disc" objects, which in return contain lists of 
releases.

There is an example that requests data by disc ID:
isrcsubmit (version 2):
https://github.com/JonnyJD/musicbrainz-isrcsubmit/blob/master/isrcsubmit.py#L383

I basically uses it like that:

  includes=["artists", "labels", "recordings", "isrcs",
            "artist-credits"] # the last one only for cleanup
  results = get_releases_by_discid(self.id, includes=includes)

  if results and results.get("disc"):
    releases = result["disc"]["release-list"]
  else:
    return []

You then have release = realeases[0] and release["title"] etc.

FYI:
We might rename that function, see:
https://github.com/alastair/python-musicbrainz-ngs/pull/92

The documentation about what is returned by the web service
(or by python-musicbrainzngs) is quite incomplete.
Your best bet is currently to try a query (or web request) and have
a look at the complete output.
In python you can just do print(result) to figure out what it is what 
you get. It is a dict.


--
JonnyJD

_______________________________________________
MusicBrainz-users mailing list
[email protected]
http://lists.musicbrainz.org/mailman/listinfo/musicbrainz-users
signature.asc (application/pgp-signature, 198 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.19 (GNU/Linux)

iEYEABECAAYFAlFt8eEACgkQaDBIOMxoZgfoBgCfSmK3QfuTWTd5uA51V4u3iYVq
xPUAn1IYVq/41XfsthGu7WT1CcUs72Jk
=+llN
-----END PGP SIGNATURE-----