Re: [mb-users] Track duration is None
Jeffrey Barish <[email protected]> Wed, 24 Apr 2013 12:29:10 -0600
| Newsgroups | gmane.comp.audio.musicbrainz.devel,gmane.comp.audio.musicbrainz.user |
|---|---|
| Message-ID | <3125210.vkLlNWKl69@sextet> |
On Wednesday, 17 April 2013 02:50:38 Johannes Dewender wrote:
> 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
I appreciate your efforts to rename functions with misleading names. Here is
another misnomer:
m.get_releases_by_discid("BG.iuI50.qn1DOBAWIk8fUYoeHM-",
includes=['recordings', 'artists'])['disc']['release-list'][0]['artist-
credit']
returns a list. To be consistent with "release-list", "medium-list", and
"track-list", the key ought to be "artist-credit-list".
I am moving this discussion to devel because that mailing list seems more
appropriate to me. Apologies if I am mistaken.
Jeffrey Barish