Track duration is None

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Track duration is None

Jeffrey Barish
When I look up the track duration for a particular recording using the API
thusly:

rel_filter = mbws.ReleaseFilter(discId='Uet7Ne0jNNwhz206YC0rPlDJELw-')
result = query.getReleases(rel_filter)
release = result[0].release
release.tracks[0].title
u'Adagio \u2013 Allegro molto'
print release.tracks[0].duration

I get None.

I figured that I should check the duration using the web interface, but I
cannot find the recording.  It must be in the database -- right? -- because I
get a result when I search using the API.  Is there a way to look up a
recording using the disc ID?  How does it happen that the duration of the
tracks on this recording are all None?  Is this record erroneous, or do I have
to protect against this value?

Jeffrey Barish

_______________________________________________
MusicBrainz-users mailing list
[hidden email]
http://lists.musicbrainz.org/mailman/listinfo/musicbrainz-users
Reply | Threaded
Open this post in threaded view
|

Re: Track duration is None

Ian McEwen
Okay, so, first of all, python-musicbrainz2 is deprecated, since the webservice version it uses (/ws/1) is deprecated. So I'd suggest moving away from that. However:

https://musicbrainz.org/ws/1/release/?discid=Uet7Ne0jNNwhz206YC0rPlDJELw- is the url it constructs initially. You can see the result it found.

Issue: that endpoint includes CDStubs[1] by default. As you can see, https://musicbrainz.org/ws/1/release/?discid=Uet7Ne0jNNwhz206YC0rPlDJELw-&cdstubs=no does not include that result. Also, CDStubs don't support many of the various ?inc parameters, and they don't have much info.

The CDStub is: https://musicbrainz.org/cdstub/Uet7Ne0jNNwhz206YC0rPlDJELw-

I'm not sure why it's not including durations, but I'd bet it's because it's a CDStub.

In general, I'd recommend a.) moving away from python-musicbrainz2 and /ws/1, b.) if you must, figure out the proper way to exclude CDStubs, and c.) sometimes things just don't have durations even after all that. So you'll just have to account for that somewhere :)

Hopefully this helps.

[1]: http://wiki.musicbrainz.org/CD_Stub

On Tue, Apr 16, 2013 at 11:32:16AM -0600, Jeffrey Barish wrote:

> When I look up the track duration for a particular recording using the API
> thusly:
>
> rel_filter = mbws.ReleaseFilter(discId='Uet7Ne0jNNwhz206YC0rPlDJELw-')
> result = query.getReleases(rel_filter)
> release = result[0].release
> release.tracks[0].title
> u'Adagio \u2013 Allegro molto'
> print release.tracks[0].duration
>
> I get None.
>
> I figured that I should check the duration using the web interface, but I
> cannot find the recording.  It must be in the database -- right? -- because I
> get a result when I search using the API.  Is there a way to look up a
> recording using the disc ID?  How does it happen that the duration of the
> tracks on this recording are all None?  Is this record erroneous, or do I have
> to protect against this value?
>
> Jeffrey Barish
>
> _______________________________________________
> MusicBrainz-users mailing list
> [hidden email]
> http://lists.musicbrainz.org/mailman/listinfo/musicbrainz-users
--
Ian McEwen <[hidden email]> <[hidden email]>
A262 D5C4 40CB 0E1C 5F24 C3A1 ABED 1ABD 7131 A76F
http://ianmcorvidae.net/

_______________________________________________
MusicBrainz-users mailing list
[hidden email]
http://lists.musicbrainz.org/mailman/listinfo/musicbrainz-users

attachment0 (205 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Track duration is None

Jeffrey Barish
Thanks.  Your reply helps very much.

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).

On Tuesday, 16 April 2013 11:33:51 Ian McEwen wrote:

> Okay, so, first of all, python-musicbrainz2 is deprecated, since the
> webservice version it uses (/ws/1) is deprecated. So I'd suggest moving
> away from that. However:
>
> https://musicbrainz.org/ws/1/release/?discid=Uet7Ne0jNNwhz206YC0rPlDJELw- is
> the url it constructs initially. You can see the result it found.
>
> Issue: that endpoint includes CDStubs[1] by default. As you can see,
> https://musicbrainz.org/ws/1/release/?discid=Uet7Ne0jNNwhz206YC0rPlDJELw-&c
> dstubs=no does not include that result. Also, CDStubs don't support many of
> the various ?inc parameters, and they don't have much info.
>
> The CDStub is: https://musicbrainz.org/cdstub/Uet7Ne0jNNwhz206YC0rPlDJELw-
>
> I'm not sure why it's not including durations, but I'd bet it's because it's
> a CDStub.
>
> In general, I'd recommend a.) moving away from python-musicbrainz2 and
> /ws/1, b.) if you must, figure out the proper way to exclude CDStubs, and
> c.) sometimes things just don't have durations even after all that. So
> you'll just have to account for that somewhere :)
>
> Hopefully this helps.
>
> [1]: http://wiki.musicbrainz.org/CD_Stub
>
> On Tue, Apr 16, 2013 at 11:32:16AM -0600, Jeffrey Barish wrote:
> > When I look up the track duration for a particular recording using the API
> > thusly:
> >
> > rel_filter = mbws.ReleaseFilter(discId='Uet7Ne0jNNwhz206YC0rPlDJELw-')
> > result = query.getReleases(rel_filter)
> > release = result[0].release
> > release.tracks[0].title
> > u'Adagio \u2013 Allegro molto'
> > print release.tracks[0].duration
> >
> > I get None.
> >
> > I figured that I should check the duration using the web interface, but I
> > cannot find the recording.  It must be in the database -- right? --
> > because I get a result when I search using the API.  Is there a way to
> > look up a recording using the disc ID?  How does it happen that the
> > duration of the tracks on this recording are all None?  Is this record
> > erroneous, or do I have to protect against this value?
> >
> > Jeffrey Barish
> >
> > _______________________________________________
> > MusicBrainz-users mailing list
> > [hidden email]
> > http://lists.musicbrainz.org/mailman/listinfo/musicbrainz-users
>
> --
> Ian McEwen <[hidden email]> <[hidden email]>
> A262 D5C4 40CB 0E1C 5F24 C3A1 ABED 1ABD 7131 A76F
> http://ianmcorvidae.net/
--
Jeffrey Barish 303-775-9550
612 Wild Ridge Ln
Lafayette, CO  80026


_______________________________________________
MusicBrainz-users mailing list
[hidden email]
http://lists.musicbrainz.org/mailman/listinfo/musicbrainz-users
Reply | Threaded
Open this post in threaded view
|

Re: Track duration is None

Ian McEwen
The documentation is not completely good for that, no -- you'll need to provide some include parameters; if you look at musicbrainz.VALID_INCLUDES further down on that page you'll see the valid things to include for each endpoint (in this case, 'discid'). To get recording information, you'll want to probably include at least 'media', 'artist-credits', and 'recordings').

python-musicbrainz-ngs is also a pretty small wrapper around the webservice itself, so you may want to look at https://musicbrainz.org/doc/Development/XML_Web_Service/Version_2 which gives a basic overview of the webservice. Specifically, https://musicbrainz.org/doc/Development/XML_Web_Service/Version_2#discid is the section you'll care about here, of course.

On Tue, Apr 16, 2013 at 03:37:11PM -0600, Jeffrey Barish wrote:

> Thanks.  Your reply helps very much.
>
> 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).
>
> On Tuesday, 16 April 2013 11:33:51 Ian McEwen wrote:
> > Okay, so, first of all, python-musicbrainz2 is deprecated, since the
> > webservice version it uses (/ws/1) is deprecated. So I'd suggest moving
> > away from that. However:
> >
> > https://musicbrainz.org/ws/1/release/?discid=Uet7Ne0jNNwhz206YC0rPlDJELw- is
> > the url it constructs initially. You can see the result it found.
> >
> > Issue: that endpoint includes CDStubs[1] by default. As you can see,
> > https://musicbrainz.org/ws/1/release/?discid=Uet7Ne0jNNwhz206YC0rPlDJELw-&c
> > dstubs=no does not include that result. Also, CDStubs don't support many of
> > the various ?inc parameters, and they don't have much info.
> >
> > The CDStub is: https://musicbrainz.org/cdstub/Uet7Ne0jNNwhz206YC0rPlDJELw-
> >
> > I'm not sure why it's not including durations, but I'd bet it's because it's
> > a CDStub.
> >
> > In general, I'd recommend a.) moving away from python-musicbrainz2 and
> > /ws/1, b.) if you must, figure out the proper way to exclude CDStubs, and
> > c.) sometimes things just don't have durations even after all that. So
> > you'll just have to account for that somewhere :)
> >
> > Hopefully this helps.
> >
> > [1]: http://wiki.musicbrainz.org/CD_Stub
> >
> > On Tue, Apr 16, 2013 at 11:32:16AM -0600, Jeffrey Barish wrote:
> > > When I look up the track duration for a particular recording using the API
> > > thusly:
> > >
> > > rel_filter = mbws.ReleaseFilter(discId='Uet7Ne0jNNwhz206YC0rPlDJELw-')
> > > result = query.getReleases(rel_filter)
> > > release = result[0].release
> > > release.tracks[0].title
> > > u'Adagio \u2013 Allegro molto'
> > > print release.tracks[0].duration
> > >
> > > I get None.
> > >
> > > I figured that I should check the duration using the web interface, but I
> > > cannot find the recording.  It must be in the database -- right? --
> > > because I get a result when I search using the API.  Is there a way to
> > > look up a recording using the disc ID?  How does it happen that the
> > > duration of the tracks on this recording are all None?  Is this record
> > > erroneous, or do I have to protect against this value?
> > >
> > > Jeffrey Barish
> > >
> > > _______________________________________________
> > > MusicBrainz-users mailing list
> > > [hidden email]
> > > http://lists.musicbrainz.org/mailman/listinfo/musicbrainz-users
> >
> > --
> > Ian McEwen <[hidden email]> <[hidden email]>
> > A262 D5C4 40CB 0E1C 5F24 C3A1 ABED 1ABD 7131 A76F
> > http://ianmcorvidae.net/
> --
> Jeffrey Barish 303-775-9550
> 612 Wild Ridge Ln
> Lafayette, CO  80026
>
>
> _______________________________________________
> MusicBrainz-users mailing list
> [hidden email]
> http://lists.musicbrainz.org/mailman/listinfo/musicbrainz-users
--
Ian McEwen <[hidden email]> <[hidden email]>
A262 D5C4 40CB 0E1C 5F24 C3A1 ABED 1ABD 7131 A76F
http://ianmcorvidae.net/

_______________________________________________
MusicBrainz-users mailing list
[hidden email]
http://lists.musicbrainz.org/mailman/listinfo/musicbrainz-users

attachment0 (205 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Track duration is None

Jeffrey Barish
Here's what I came up with:

releases = m.get_releases_by_discid("<discid>", includes=['recordings'])

duration = releases['disc']['release-list'][0]['medium-list'][0]['track-list']
[i]['recording']['length']

where i is the track index.  Also,

ttitle = releases['disc']['release-list'][0]['medium-list'][0]['track-list']
[i]['recording']['title']

It's a far cry from release.tracks[i].duration, but at least I'm not getting
CDStubs anymore.

BTW, how to a modify the above if I *do* want CDStubs?

On Tuesday, 16 April 2013 14:52:12 Ian McEwen wrote:

> The documentation is not completely good for that, no -- you'll need to
> provide some include parameters; if you look at musicbrainz.VALID_INCLUDES
> further down on that page you'll see the valid things to include for each
> endpoint (in this case, 'discid'). To get recording information, you'll
> want to probably include at least 'media', 'artist-credits', and
> 'recordings').
>
> python-musicbrainz-ngs is also a pretty small wrapper around the webservice
> itself, so you may want to look at
> https://musicbrainz.org/doc/Development/XML_Web_Service/Version_2 which
> gives a basic overview of the webservice. Specifically,
> https://musicbrainz.org/doc/Development/XML_Web_Service/Version_2#discid is
> the section you'll care about here, of course.
> On Tue, Apr 16, 2013 at 03:37:11PM -0600, Jeffrey Barish wrote:
> > Thanks.  Your reply helps very much.
> >
> > 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).
> >
> > On Tuesday, 16 April 2013 11:33:51 Ian McEwen wrote:
> > > Okay, so, first of all, python-musicbrainz2 is deprecated, since the
> > > webservice version it uses (/ws/1) is deprecated. So I'd suggest moving
> > > away from that. However:
> > >
> > > https://musicbrainz.org/ws/1/release/?discid=Uet7Ne0jNNwhz206YC0rPlDJELw
> > > - is the url it constructs initially. You can see the result it found.
> > >
> > > Issue: that endpoint includes CDStubs[1] by default. As you can see,
> > > https://musicbrainz.org/ws/1/release/?discid=Uet7Ne0jNNwhz206YC0rPlDJELw
> > > -&c
> > > dstubs=no does not include that result. Also, CDStubs don't support many
> > > of
> > > the various ?inc parameters, and they don't have much info.
> > >
> > > The CDStub is:
> > > https://musicbrainz.org/cdstub/Uet7Ne0jNNwhz206YC0rPlDJELw-
> > >
> > > I'm not sure why it's not including durations, but I'd bet it's because
> > > it's a CDStub.
> > >
> > > In general, I'd recommend a.) moving away from python-musicbrainz2 and
> > > /ws/1, b.) if you must, figure out the proper way to exclude CDStubs,
> > > and
> > > c.) sometimes things just don't have durations even after all that. So
> > > you'll just have to account for that somewhere :)
> > >
> > > Hopefully this helps.
> > >
> > > [1]: http://wiki.musicbrainz.org/CD_Stub
> > >
> > > On Tue, Apr 16, 2013 at 11:32:16AM -0600, Jeffrey Barish wrote:
> > > > When I look up the track duration for a particular recording using the
> > > > API
> > > > thusly:
> > > >
> > > > rel_filter = mbws.ReleaseFilter(discId='Uet7Ne0jNNwhz206YC0rPlDJELw-')
> > > > result = query.getReleases(rel_filter)
> > > > release = result[0].release
> > > > release.tracks[0].title
> > > > u'Adagio \u2013 Allegro molto'
> > > > print release.tracks[0].duration
> > > >
> > > > I get None.
> > > >
> > > > I figured that I should check the duration using the web interface,
> > > > but I
> > > > cannot find the recording.  It must be in the database -- right? --
> > > > because I get a result when I search using the API.  Is there a way to
> > > > look up a recording using the disc ID?  How does it happen that the
> > > > duration of the tracks on this recording are all None?  Is this record
> > > > erroneous, or do I have to protect against this value?
> > > >
> > > > Jeffrey Barish
> > > >
> > > > _______________________________________________
> > > > MusicBrainz-users mailing list
> > > > [hidden email]
> > > > http://lists.musicbrainz.org/mailman/listinfo/musicbrainz-users
> > >
> > > --
> > > Ian McEwen <[hidden email]> <[hidden email]>
> > > A262 D5C4 40CB 0E1C 5F24 C3A1 ABED 1ABD 7131 A76F
> > > http://ianmcorvidae.net/
> >
> > --
> > _______________________________________________
> > MusicBrainz-users mailing list
> > [hidden email]
> > http://lists.musicbrainz.org/mailman/listinfo/musicbrainz-users
>
> --
> Ian McEwen <[hidden email]> <[hidden email]>
> A262 D5C4 40CB 0E1C 5F24 C3A1 ABED 1ABD 7131 A76F
> http://ianmcorvidae.net/


_______________________________________________
MusicBrainz-users mailing list
[hidden email]
http://lists.musicbrainz.org/mailman/listinfo/musicbrainz-users
Reply | Threaded
Open this post in threaded view
|

Re: Track duration is None

Johannes Dewender
In reply to this post by Jeffrey Barish
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
[hidden email]
http://lists.musicbrainz.org/mailman/listinfo/musicbrainz-users

signature.asc (205 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Track duration is None

Johannes Dewender
In reply to this post by Jeffrey Barish
Am Dienstag 16 April 2013, 18:29:57 schrieb Jeffrey Barish:

> Here's what I came up with:
>
> releases = m.get_releases_by_discid("<discid>",
> includes=['recordings'])
>
> duration =
> releases['disc']['release-list'][0]['medium-list'][0]['track-list']
> [i]['recording']['length']
>
> where i is the track index.  Also,
>
> ttitle =
> releases['disc']['release-list'][0]['medium-list'][0]['track-list']
> [i]['recording']['title']
>
> It's a far cry from release.tracks[i].duration, but at least I'm not
> getting CDStubs anymore.
>
> BTW, how to a modify the above if I *do* want CDStubs?
Hm, currently with python-musicbraiz-ngs you will never get cdstubs,
because they are not considered "valid elements".

I opened a bug report:
https://github.com/alastair/python-musicbrainz-ngs/issues/99

There should be some way to get them.


--
JonnyJD
_______________________________________________
MusicBrainz-users mailing list
[hidden email]
http://lists.musicbrainz.org/mailman/listinfo/musicbrainz-users

signature.asc (205 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Track duration is None

Jeffrey Barish
In reply to this post by Johannes Dewender
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

_______________________________________________
MusicBrainz-users mailing list
[hidden email]
http://lists.musicbrainz.org/mailman/listinfo/musicbrainz-users