Spotify url validation

I created this class for a project I am working on where I need to validate Spotify playlist and track URLs. I hope someone will get some use out of it or maybe improve it. It provides two static methods for validating and allows you to specify the return type which currently is a HTTP or Spotify URL format.

SpotifyUtil

Here is an example of how to use the method which will convert the link variable below to “spotify:user:user_name:playlist:3WbWswJtOPIdKBQmZs9pGr”:

var link : String = "http://open.spotify.com/user/user_name/playlist/3WbWswJtOPIdKBQmZs9pGr";

var validUrl : String = SpotifyUtil.validatePlaylist( link, SpotifyUtil.URL_FORMAT_SPOTIFY );

if( validUrl )
{
	trace( link );
}
This entry was posted in development and tagged , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

2 Comments

  1. Posted April 15, 2011 at 12:16 pm | Permalink

    How does this work within your project? I must admit I’m pretty useless when it comes down to this type of thing but am curious as to how it would be used.

  2. Posted April 15, 2011 at 1:20 pm | Permalink

    We created an app using the libSpotify APIs where users could dynamically add songs to playlists in a competition setting. It came in handy for validation (like email but for Spotify URLs) before we sent them off to the server for submission. Hope that helps!

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>