Coder Social home page Coder Social logo

lastfm's Introduction

Inflatable Last.fm .NET SDK Build status

MIT licensed. Maintained by @rikkilt.

Feature request? Bug? Or just wanna help out? Check out the issues on GitHub.

If you have comments or need some help, post to our chat room on ![Gitter](https://badges.gitter.im/Join Chat.svg).

Project Goals

  • Provide complete, and completely tested, bindings for the Last.fm REST API for use on modern .NET platforms.
  • Provide functionality beyond API bindings, to spread the joy of Last.fm to developers everywhere.
  • To be the very best, like no-one ever was.

Quickstart

Installing the SDK

If you want to work with the Last.fm API, you should install the NuGet package. Search for Inflatable.Lastfm in the NuGet package browser or run this commmand in the NuGet package console:

PM> Install-Package Inflatable.Lastfm

You can also clone this repo and build from source, referencing IF.Lastfm.Core in your project. Keep in mind this requires a version of Visual Studio that supports portable class libraries and PCL profile 259 - Visual Studio 2012/3 Pro or higher running on Windows 8 or higher.

Using the SDK

Once IF.Lastfm.Core is referenced, it's pretty simple to get started. First, sign up for Last.fm API access if you haven't already

This is how to get album info:

var auth = new LastAuth("apikey", "apisecret");
var albumApi = new AlbumApi(auth); // this is an unauthenticated call to the API
var response = await albumApi.GetAlbumInfoAsync("Grimes", "Visions");
var visions = response.Content; // visions is a LastAlbum

For methods that return several items, you can simply iterate over the response

var pageResponse = await artistApi.GetTopTracksForArtistAsync("Ben Frost", page: 5, itemsPerPage: 100);

foreach (var wallOfSound in pageResponse)
{
	// wallOfSound is a LastTrack
}

Several API methods require user authentication. Once you have your user's Last.fm username and password:

var auth = new LastAuth("apikey", "apisecret");

// wait for authentication
var response = await auth.GetSessionTokenAsync("username", "pass");

if (response.Success && auth.HasAuthenticated) {
	var trackApi = new TrackApi(auth);
	var loved = await trackApi.LoveTrackAsync("CIRCLONT6A [141.98][Syrobonkus mix]", "Aphex Twin");
}

Some documentation is available on the GitHub wiki. You can also check the Windows Phone demo project for some example code.

Any problems, just ask in Gitter.

Dependency Injection

The SDK is built to work with IoC libraries like MvvmLight and Ninject. To inject an API as a dependency to a viewmodel, you just need to register ILastAuth to an instance of LastAuth:

// mvvmlight
var auth = new LastAuth("apikey", "apisecret");
SimpleIoc.Default.Register<ILastAuth>(() => auth);

// ...

var artistApi = ServiceLocator.Current.GetInstance<ArtistApi>();
var response = await artistApi.GetArtistInfoAsync("The Knife");
var theKnife = artist.Content;

Implemented Features

Check the progress report for a list of implemented methods.

Planned Features

Everyone working with Last.fm is likely to need similar kinds of features, so it makes sense for us to work on them together. Here are a few things to look for in the future:

  • Fire-and-forget scrobbling: transparent handling of scrobbles made offline
  • Built-in request cache for API calls
  • Improved identification of poorly tagged tracks using audio fingerprints and the MusicBrainz API

If you have any other neat ideas, post them in our Gitter so we can talk ๐Ÿ˜„

Platform Compatibility

The current PCL profile is

  • .NET Framework 4.5
  • Windows 8.0
  • Windows Phone 8.1
  • Windows Phone Silverlight 8

If you need support for Mono, Windows Phone 7, or another .NET platform, please ask: the current profile was chosen to reduce dependencies for the most common use cases. The SDK should be trivial to port to any platform which supports Async, HttpClient and Json.Net.

lastfm's People

Contributors

haroldma-zz avatar pcurd avatar prashantkhandelwal avatar rikkit avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.