Exemple #1
0
 // Extension to aid deserialization of lists :)
 public static void Deserialize <T>(this IEnumerable <T> aItems, DeezerClient aClient) where T : IDeserializable <DeezerClient>
 {
     foreach (T item in aItems)
     {
         item.Deserialize(aClient);
     }
 }
Exemple #2
0
        public void Search()
        {
            //See Setup Example
            DeezerSession session = new DeezerSession(string.Empty, string.Empty, string.Empty, DeezerPermissions.BasicAccess);
            DeezerClient client = new DeezerClient(session);

            //The Search Query
            string SearchQuery = "<Insert Search Query>";

            //You can search Deezer for TRACKS / ARTISTS / ALBUMS / PLAYLISTS
            //Each has a method in the client with the signature - Search<ITEM>(SearchQuery)
            //Returns a paged result
            var searchTask = client.SearchArtists(SearchQuery);

            //Grab the result from the task
            //Contains the A book of results
            var items = searchTask.Result.Data;

            //We can get the total results found from the search
            var total = searchTask.Result.Total;

            //We can get the links to the next/previous pages in the search
            var nextPage = searchTask.Result.Next;
            var previousPage = searchTask.Result.Previous;

            //Alternatively we can get the pages directly
            //TODO NotYetImplemented
            var nextPageTask = searchTask.Result.GetNextPage();
            var previousPageTask = searchTask.Result.GetPreviousPage();
        }
Exemple #3
0
        //Simple method getting us a Deezer Client object so we can use the API 
        public void SetupMethod()
        {
            //The username of the account you wish to browse the API with
            //NOTE: You don't need to specify this to BROWSE the API,
            //The username is only used when accessing user information, history or favourites.
            string Username = "******";

            //Your application ID found at http://developers.deezer.com
            //NOTE: Since Deezer require a webwindow to authenticate users. E.Deezer currently doesn't
            //provide this feature and so this param is ignored.
            string ApplicationID = string.Empty;

            //Your application secret found at http://developers.deezer.com
            //NOTE: Since Deezer require a webwindow to authenticate users. E.Deezer currently doesn't
            //provide this feature and so this param is ignored.
            string ApplicationSecret = string.Empty;

            //Permissions that will be requested when authenticating users
            //See http://developers.deezer.com/api/permissions
            //NOTE: Since Deezer require a webwindow to authenticate users. E.Deezer currently doesn't
            //provide this feature and so this param is ignored.
            DeezerPermissions Permissions = DeezerPermissions.BasicAccess;


            //Create a DeezerSession
            //NOTE: This will be used to authenticate users. E.Deezer doesn't provide this feature yet.
            DeezerSession session = new DeezerSession(Username, ApplicationID, ApplicationSecret, Permissions);

            //We use this session to create a DeezerClient
            DeezerClient client = new DeezerClient(session);

            //All done :)
            //Use the DeezerClient object to get data from the Deezer API
        }
Exemple #4
0
        private async Task <byte[]> DownloadArtistPictureFromDeezer(string artistName)
        {
            var deezerClient = new DeezerClient();
            var deezerArtist = await deezerClient.GetArtistInfo(artistName);

            if (deezerArtist == null)
            {
                return(null);
            }
            if (deezerArtist.Images == null)
            {
                return(null);
            }
            try
            {
                var clientPic = new HttpClient();
                HttpResponseMessage responsePic = await clientPic.GetAsync(deezerArtist.Images.LastOrDefault().Url);

                string uri = responsePic.RequestMessage.RequestUri.AbsoluteUri;
                // A cheap hack to avoid using Deezers default image for bands.
                if (uri.Equals("http://cdn-images.deezer.com/images/artist//400x400-000000-80-0-0.jpg"))
                {
                    return(null);
                }
                byte[] img = await responsePic.Content.ReadAsByteArrayAsync();

                return(img);
            }
            catch (Exception)
            {
                Debug.WriteLine("Error getting or saving art from deezer.");
                return(null);
            }
        }
Exemple #5
0
        public BrowseEndpoint(DeezerClient aClient)
        {
            iClient = aClient;

            iGenre        = new GenreEndpoint(iClient);
            iCharts       = new ChartsEndpoint(iClient);
            iUserEndpoint = new UserEndpoint(aClient);
        }
Exemple #6
0
        internal Deezer(DeezerSession aSession)
        {
            iSession = aSession;
            iClient = new DeezerClient(iSession);

            iBrowse = new BrowseEndpoint(iClient);
            iSearch = new SearchEndpoint(iClient);
            iUser =   new UserEndpoint(iClient);
            iRadio = new RadioEndpoint(iClient);
        }
        public BrowseEndpoint(DeezerClient aClient)
        {
            iClient = aClient;

            iAlbums = new AlbumEndpoint(iClient);
            iArtists = new ArtistEndpoint(iClient);
            iPlaylists = new PlaylistEndpoint(iClient);
            iTracks = new TrackEndpoint(iClient);
            iGenre = new GenreEndpoint(iClient);
            iCharts = new ChartsEndpoint(iClient);
        }
Exemple #8
0
        public BrowseEndpoint(DeezerClient aClient)
        {
            iClient = aClient;

            iAlbums    = new AlbumEndpoint(iClient);
            iArtists   = new ArtistEndpoint(iClient);
            iPlaylists = new PlaylistEndpoint(iClient);
            iTracks    = new TrackEndpoint(iClient);
            iGenre     = new GenreEndpoint(iClient);
            iCharts    = new ChartsEndpoint(iClient);
        }
        public void Infos()
        {
            //See Setup Example
            DeezerSession session = new DeezerSession(string.Empty, string.Empty, string.Empty, DeezerPermissions.BasicAccess);
            DeezerClient client = new DeezerClient(session);

            //We can get some service information from Deezer using GetInfos() method
            var serviceinfo = client.GetInfos();

            //From this we can get the current user's country
            //NOTE: Based on IP address
            var country = serviceinfo.Result.Country;
            var countryISO = serviceinfo.Result.Iso;

            //We can see if Deezer is available in this country
            var serviceAvailable = serviceinfo.Result.IsAvailable;
        }
Exemple #10
0
		internal void Deserialize(DeezerClient aClient) { Client = aClient; }
Exemple #11
0
 public AlbumEndpoint(DeezerClient aClient)
 {
     iClient = aClient;
 }
Exemple #12
0
 public SearchEndpoint(DeezerClient aClient)
 {
     iClient = aClient;
 }
Exemple #13
0
 public GenreEndpoint(DeezerClient aClient)
 {
     iClient = aClient;
 }
 public PlaylistEndpoint(DeezerClient aClient) {  iClient = aClient;  }
Exemple #15
0
 public AlbumEndpoint(DeezerClient aClient) {  iClient = aClient;  }
Exemple #16
0
 public TrackEndpoint(DeezerClient aClient)
 {
     iClient = aClient;
 }
Exemple #17
0
 public ArtistEndpoint(DeezerClient aClient)
 {
     iClient = aClient;
 }
Exemple #18
0
 public TrackEndpoint(DeezerClient aClient) {  iClient = aClient;  }
 public ArtistEndpoint(DeezerClient aClient) {  iClient = aClient;  }
Exemple #20
0
 public RadioEndpoint(DeezerClient aClient)
 {
     iClient = aClient;
 }
Exemple #21
0
 public UserEndpoint(DeezerClient aClient)
 {
     iClient = aClient;
 }
Exemple #22
0
 public UserEndpoint(DeezerClient aClient) { iClient = aClient; }
Exemple #23
0
 public RadioEndpoint(DeezerClient aClient) { iClient = aClient; }
Exemple #24
0
 public ChartsEndpoint(DeezerClient aClient)
 {
     iClient = aClient;
 }
Exemple #25
0
 public PlaylistEndpoint(DeezerClient aClient)
 {
     iClient = aClient;
 }