Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Drag & Drop from Spotify to Winforms app

If someone drags and drops a spotify track from the spotify desktop app to Excel, than Excel shows the artist and title of a song.

I have a winforms application in which I want to do the same. If I drag and drop to a listbox like this....

Private Sub ListBox1_DragEnter(sender As Object, e As DragEventArgs) Handles ListBox1.DragEnter
    ListBox1.Items.Add(e.Data.GetData(DataFormats.Text))
End sub

.... all it ever does, is show the spotify track ID. Since Excel is not designed to read Spotify url's, the data must be in the drag-drop. But whatever dataformat I choose, I only get the ID.

like image 427
Richard Lleram Avatar asked Jan 08 '19 08:01

Richard Lleram


People also ask

How do I click and drag on a laptop?

To drag an item, double-tap but don't lift your finger after the second tap. Drag the item where you want it, then lift your finger to drop. If your touchpad supports multi-finger taps, right-click by tapping with two fingers at once. Otherwise, you still need to use hardware buttons to right-click.

How do you drag with mouse?

To move an object, place the mouse cursor over it, press and hold down the left mouse button, then move the mouse while still holding down the left mouse button. When you have "dragged" the object to the location you want, let go of the mouse button.


1 Answers

if you drag the track and paste it on text editor you will see it is a uri

So within VB.NET DragEventArgs holds the URI

So we need to know what is Spotify URI here is post about that

so Quoting From Spotify post you are dealing with 2 Types of URIs

Spotify URI Codes

  • Desktop Application URI which looks like that spotify:album:27ftYHLeunzcSzb33Wk1hf
  • Web Application URI which looks like that https://open.spotify.com/album/6btauNVZRPm75SILUUOLJY

What you need to do is register yourself as a developer get a token (your key as developer) to use their service

using that token to authorize yourself to them you can use their Rest API and give them that URI to get the data you would like to have in json

Here is the documentation to the Rest API Spotify Rest API Documentation

Here is another way you could do if that service costs you money to have it

Convert DesktopURI to Web URI using String.Split(":") or Regex both ways works

Thus creating your custom web uri and then paste that web uri to a crawler and fetch your data

Ofcourse you can use .NET URI builder Class to validate it before doing the extra step

Each platform in Spotify has 3 types of uri for so make sure to categorize it to Track , Album , PlayList because what your crawler would be fetching is different

I think their Rest API is free service however make sure you don't violate their SLA Spotify SLA

Funny I am telling you that when my second solution suggestion is not following their SLA

like image 60
Rosh Avatar answered Oct 02 '22 12:10

Rosh