BandcampEnhancementSuite icon indicating copy to clipboard operation
BandcampEnhancementSuite copied to clipboard

One Click Purchase

Open sabjorn opened this issue 3 years ago • 4 comments

Problem:

adding a record to the cart takes too long.

Solution:

1-click add to cart.

Details:

When adding a purchase to the cart, here is the minimum request required:

curl 'https://halfpastvibe.bandcamp.com/cart/cb' \
  --data-raw 'req=add&item_type=a&item_id=3895330325&unit_price=1.50&quantity=1band_id=857243381&client_id=47553DD1BB1C596CB470D15D816841095A483E4E449BC0AEB354F655DA82EF15&sync_num=6' \
  --compressed

The client_id is likely the cart ID which appears to be available from a script tag on page load.

Potential Issues

It is easy to get the purchase price for releases that have a price but for "pay what you want" there is an issue. Perhaps a default value can be set (say 1 USD) but could be updated in configs by user.

Alternatively, there could be a field next to the "add to cart" button to input a price which would be automatically set to the correct value except for "pay what you want" where the user would be required to enter a number.

sabjorn avatar May 23 '21 16:05 sabjorn

More Potential Issues

some releases do not let you buy individual tracks. there will need to be some way of checking for this

Continued Potential Iusse

for the "pay what you want" edge case, it may make sense to have a little window that can pop up which shows the setting for "pay what you want" default price.

sabjorn avatar Feb 26 '22 20:02 sabjorn

JSON on page has:

  • album_is_preorder field -- might be necessary to check if trying to one click full album
  • is_downloadable field -- per track, should help prevent the issue when you can't buy individual tracks
  • current["minimume_price"] field -- this only really works on track pages (might have to iterate over all tracks... which would be slow)
  • defaultPrice field -- this is for albums, could be helpful for full album purchases

sabjorn avatar May 10 '22 23:05 sabjorn

Based on the info above, it looks like it will be necessary to iterate over all tracks in an album to get the minimum cost. Unfortunately, I have been unable to find any API endpoint for getting price per item and an album's page does not give any info about the track price within the album (just the whole album cost).

BUT if we have to make the request anyways--and adding to the cart doesn't instantly change naything visually for the user--could just have the cart adding step check for the price first if not available (rather than slowing down adding a track to a playlist)

sabjorn avatar May 11 '22 00:05 sabjorn

~try scoping the API from the iPhone app with: https://hub.docker.com/r/mitmproxy/mitmproxy maybe price and music data can be acquired from API instead of loading full webpages... ~

the above will not work since on iPhone there is no way to purchases in app. Android may be an option...

sabjorn avatar May 11 '22 19:05 sabjorn

this has been solved and is part of playlists

sabjorn avatar Jan 21 '23 03:01 sabjorn