Skip to content
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

Track Duration Property Mismatch #7

Closed
Bonfire opened this issue May 1, 2024 · 1 comment
Closed

Track Duration Property Mismatch #7

Bonfire opened this issue May 1, 2024 · 1 comment

Comments

@Bonfire
Copy link

Bonfire commented May 1, 2024

I've found that when fetching Bandcamp Track information using BandcampFetch().track.getInfo(), track duration information is not returned. Setting includeRawData: true allows us to see that the duration property is not called duration_secs but rather duration, and can be found under raw.basic.duration. This duration property is not a number representing the duration in seconds but rather a string that tells how long the song is in hours, minutes, and seconds: "P00H05M19S"

Code responsible for parsing the duration from TrackInfo:

const duration = getAdditionalPropertyValue<number>(basic, 'duration_secs');

const p = o.additionalProperty.find((prop) => prop.name === propName);

I believe there may have been a change at some point in the Bandcamp API that is causing this issue. Or possibly that some tracks return the usual duration_secs info, but other tracks return this weird duration string instead.

I have prepared a RunKit playground for you if you'd like to run some sample code that showcases this odd behavior. Also included is a workaround method that I've written to fetch the duration for the time being.
https://runkit.com/bonfire/bandcamp-fetch-duration

Thank you!

@patrickkfkan
Copy link
Owner

Hi there! Thanks for pointing this out. I have fixed this in v1.2.1. Please feel free to test it. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants