Giter Club home page Giter Club logo

lastfm's Introduction

Inflatable Last.fm .NET SDK

Project logo

Code licence

Maintenence help wanted

Hi there! The maintainer of this library @rikkit is now mostly a TypeScript + React dev, and has been for the last several years. Since this is a .Net library, the maintainer will probably not be able to keep it up-to-date to the latest .Net standards. If you spot something wrong, please file and issue or better yet, a pull request. Thanks!

Project Goals

  • To provide complete .NET bindings for the Last.fm REST API
  • To build useful components for Last.fm applications
  • To be the very best, like no-one ever was

Contributing

Input is always welcome! Raise an issue on GitHub, or send a message to the Gitter chatroom if you need help with the library.

If you're interested in contributing code or documentation, this short introduction to the library will help you get started.

Quickstart

Installing

NuGet

Install Inflatable.Lastfm from NuGet.

NuGet - prerelease code

  1. Install the .NET Core SDK
  2. Clone this repo and checkout to the commit you need
  3. Run dotnet pack
  4. Reference the built NuGet package file in your project

Examples

First, sign up for Last.fm API access if you haven't already.

Create a LastfmClient:

var client = new LastfmClient("apikey", "apisecret");

Get information about an album:

var response = await client.Album.GetInfoAsync("Grimes", "Visions");

LastAlbum visions = response.Content;

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

var pageResponse = await client.Artist.GetTopTracksAsync("Ben Frost", page: 5, itemsPerPage: 100);

var trackNames = pageResponse.Select(track => track.Name);

Several API methods require user authentication. Once you have your user's Last.fm username and password, you can authenticate your instance of LastfmClient:

var response = await client.Auth.GetSessionTokenAsync("username", "pass");

// or load an existing session
UserSession cachedSession;
var succesful = client.Auth.LoadSession(cachedSession);

Authenticated methods then work like any other

if (client.Auth.HasAuthenticated) {
	var response = await client.Track.LoveAsync("Ibi Dreams of Pavement (A Better Day)", "Broken Social Scene");
}

Documentation

Platform Compatibility

The main package targets netstandard1.1. Development is on the master branch.

Dependencies

  • Newtonsoft.Json 9.0.1 =<
  • System.Net.Http 4.3.0 =<

Supported platforms

Check this table for supported platforms.

Other platforms

If you need support for a .NET platform that doesn't support .Net Standard 1.1, first see if the feature you need is available in v0.3 or earlier - that version targeted PCL profile 259, and so is compatible with e.g. Windows 8.0 and Windows Phone 7.

If you need a feature for these older platforms, please raise an issue.

Credits

Maintained by @rikkilt. Thanks to all contributors!

lastfm's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lastfm's Issues

Change naming convention

For example Track, Album, and Artist. I'm using the library for a music project and it just makes it harder to work with different classes of the same name.

I suggest refactoring them to be FmTrack, FmArtist and FmAlbum. You can easily distinguish the purpose of the object using that simple prefix.

Tag API

Issue to track remaining tag methods

  • tag.getInfo
  • tag.getSimilar
  • tag.getTopAlbums
  • tag.getTopArtists
  • tag.getTopTags
  • tag.getTopTracks
  • tag.getWeeklyArtistChart
  • tag.getWeeklyChartList
  • tag.search
  • track.addTags
  • track.getTags
  • track.getTopTags
  • track.removeTag
  • user.getPersonalTags
  • user.getTopTags
  • album.addTags
  • album.removeTag
  • artist.addTags
  • artist.removeTag
  • chart.getTopTags

Artist API

Issue to track remaining artist commands

API Progress

  • artist.getTopArtists
  • artist.addTags
  • artist.getCorrection
  • artist.getPastEvents
  • artist.getPodcast
  • artist.getTopFans
  • artist.removeTag

Share API

Issue to track remaining share methods

Api Progress

  • album.share
  • artist.share
  • track.share
  • event.share

Can't login with LastAuth

Testing the demo, it doesn't throw an exception is just keeps waiting.

Debugging I found out that the problem is in the signature generation, in ToMD5()

Anybody else experiencing this?

EDIT: there is a System.IO.FileNotFoundException happening, not sure if is trying to load an assembly and failing.

EDIT: decided to use a custom implementation of MD5 instead of the MyConvert package and everything is working. See here

Track API

Issue to track remaining track methods.

API Progress

  • track.addTags
  • track.ban
  • track.getBuylinks
  • track.getCorrection
  • track.getFingerprintMetadata
  • track.getTags
  • track.getTopFans
  • track.getTopTags
  • track.removeTag
  • track.unban

Last object tags bug

In reference to PR #29

When getting info for the album "Shrek the Third" by "Harry Chapin", a beta tester found a bug. Further looking into it and it seems to be related to Last.FM using an object instead of an array when there is only one tag.

MyConvert causing windows phone store certification failure

Any way to avoid this dependency?

Error Found: The supported APIs test detected the following errors:
This API is not supported for this application type - Api=System.Security.Cryptography.MD5CryptoServiceProvider. Module=MSCORLIB, PUBLICKEYTOKEN=B77A5C561934E089. File=MyConvert.dll.
This API is not supported for this application type - Api=System.Security.Cryptography.HashAlgorithm. Module=MSCORLIB, PUBLICKEYTOKEN=B77A5C561934E089. File=MyConvert.dll.
This API is not supported for this application type - Api=System.Security.Cryptography.MD5. Module=MSCORLIB, PUBLICKEYTOKEN=B77A5C561934E089. File=MyConvert.dll.
This API is not supported for this application type - Api=System.SerializableAttribute. Module=MSCORLIB, PUBLICKEYTOKEN=B77A5C561934E089. File=MyConvert.dll.
This API is not supported for this application type - Api=System.Char.ToString(System.IFormatProvider). Module=MSCORLIB, PUBLICKEYTOKEN=B77A5C561934E089. File=MyConvert.dll.
This API is not supported for this application type - Api=System.Security.Cryptography.MD5CryptoServiceProvider.#ctor. Module=MSCORLIB, PUBLICKEYTOKEN=B77A5C561934E089. File=MyConvert.dll.
This API is not supported for this application type - Api=System.Security.Cryptography.HashAlgorithm.ComputeHash(System.Byte[]). Module=MSCORLIB, PUBLICKEYTOKEN=B77A5C561934E089. File=MyConvert.dll.
This API is not supported for this application type - Api=System.Globalization.TextInfo.ToTitleCase(System.String). Module=MSCORLIB, PUBLICKEYTOKEN=B77A5C561934E089. File=MyConvert.dll.
This API is not supported for this application type - Api=System.Text.Encoding.get_ASCII. Module=MSCORLIB, PUBLICKEYTOKEN=B77A5C561934E089. File=MyConvert.dll.
This API is not supported for this application type - Api=System.Text.Encoding.GetString(System.Byte[]). Module=MSCORLIB, PUBLICKEYTOKEN=B77A5C561934E089. File=MyConvert.dll.
This API is not supported for this application type - Api=System.String.Format(System.String,System.Object,System.Object,System.Object). Module=MSCORLIB, PUBLICKEYTOKEN=B77A5C561934E089. File=MyConvert.dll.
This API is not supported for this application type - Api=System.Globalization.CultureInfo.GetCultureInfo(System.String). Module=MSCORLIB, PUBLICKEYTOKEN=B77A5C561934E089. File=MyConvert.dll.
This API is not supported for this application type - Api=System.Reflection.PropertyInfo.op_Inequality(System.Reflection.PropertyInfo,System.Reflection.PropertyInfo). Module=MSCORLIB, PUBLICKEYTOKEN=B77A5C561934E089. File=MyConvert.dll.
This API is not supported for this application type - Api=System.SerializableAttribute.#ctor. Module=MSCORLIB, PUBLICKEYTOKEN=B77A5C561934E089. File=MyConvert.dll.
This API is not supported for this application type - Api=System.Reflection.PropertyInfo.op_Equality(System.Reflection.PropertyInfo,System.Reflection.PropertyInfo). Module=MSCORLIB, PUBLICKEYTOKEN=B77A5C561934E089. File=MyConvert.dll.

Scrobble with "Various" artist fails, but response is successful

{
    "scrobbles": {
        "scrobble": {
            "track": {
                "#text": "Again",
                "corrected": "0"
            },
            "artist": {
                "#text": "Various",
                "corrected": "0"
            },
            "album": {
                "#text": "",
                "corrected": "0"
            },
            "albumArtist": {
                "#text": "",
                "corrected": "0"
            },
            "timestamp": "1425152860",
            "ignoredMessage": {
                "#text": "Artist name failed filter: Various",
                "code": "1"
            }
        },
        "@attr": {
            "accepted": "0",
            "ignored": "1"
        }
    }
}

Should look at @attr.ignored

Event API

This issue is to track progress on all event-related methods.

API Progress

  • event poco
  • event.attend
  • event.getAttendees
  • event.getInfo
  • event.getShouts
  • event.shout
  • artist.getEvents
  • artist.getPastEvents
  • get.getEvents
  • user.getEvents
  • user.getPastEvents
  • user.getRecommendedEvents
  • venue.getEvents
  • venue.getPastEvents

Command names are confusing

Proposing renaming them all according to the API method they implement:

AlbumApi.AddShoutCommand -> album.addShout -> AlbumAddShoutCommand
AlbumApi.GetAlbumInfoCommand -> album.getInfo -> AlbumGetInfoCommand
TrackApi.LoveTrackCommand -> track.love -> TrackLoveCommand
TrackApi.AddShoutCommand -> track.addShout -> TrackAddShoutCommand
TrackApi.GetSimilarTracksCommand -> track.getSimilar -> TrackGetSimilarCommand

etc.

All-in-one api class

To simplify DI and example code. Existing *Api classes presented as properties on new class object.

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");
}

becomes

var lastApi = new SuperLastApi(apikey, apisecret, httpclient, scrobbler);

var response = lastApi.Auth.GetSessionTokenAsync();
if (response.Success && lastApi.Auth.HasAuthenticated)
{
var loved = lastApi.Track.LoveAsync("CIRCLONT6A [141.98][Syrobonkus mix]", "Aphex Twin");
}

Geo API

Issue to track remaining geo methods

  • geo.getEvents
  • geo.getMetroArtistChart
  • geo.getMetroHypeArtistChart
  • geo.getMetroHypeTrackChart
  • geo.getMetroTrackChart
  • geo.getMetroUniqueArtistChart
  • geo.getMetroUniqueTrackChart
  • geo.getMetroWeeklyChartlist
  • geo.getMetros
  • geo.getTopArtists
  • geo.getTopTracks

Buylinks API

This issue is to track progress of methods relating to buy links on the API.

API Progress

  • Create buylink poco
  • album.getBuyLinks
  • track.getBuyLinks

Post commands do not work in WPF

Identical commands send different headers on WPF vs Windows Phone

WPF
Content-Type: application/x-www-form-urlencoded
Host: ws.audioscrobbler.com
Content-Length: 260
Expect: 100-continue
Windows Phone
Accept: */*
Content-Length: 260
Accept-Encoding: identity
Content-Type: application/x-www-form-urlencoded
User-Agent: NativeHost
Host: ws.audioscrobbler.com
Connection: Keep-Alive
Pragma: no-cache

After some testing it seems that the Last.fm API doesn't handle the Expect: 100-continue header.

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.