コード例 #1
0
ファイル: Searching.cs プロジェクト: xfischer/E.Deezer
        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();
        }
コード例 #2
0
        public static async Task GetTracks()
        {
            var deezer = DeezerSession.CreateNew();

            for (int i = 0; i < SpotifyTracks.tracks.items.Count(); i++)
            {
                IEnumerable <ITrack> tracks = await deezer.Search.Tracks(SpotifyTracks.tracks.items[i].track.name, 0, 100);

                IEnumerable <ITrack> tracks1 = tracks;
                ITrack track = FindCorrectTrack(tracks1, i);
                if (track != null)
                {
                    totalTracksChecked++;
                    totalTracksFound++;
                    //Console.WriteLine("Track found on Deezer!");
                    Utilities.Utilities.DrawTextProgressBar(totalTracksChecked, totalTracks);
                    SerializeTrack(track.Id.ToString(), track.Title, track.ArtistName);
                }
                else
                {
                    totalTracksChecked++;
                    Utilities.Utilities.DrawTextProgressBar(totalTracksChecked, totalTracks);
                    //Console.WriteLine("TRACK NOT FOUND ON DEEZER");
                }
            }
            File.WriteAllText("deezertracks.json", JsonConvert.SerializeObject(DeezerTracks));
            Console.WriteLine(DeezerTracks.Count);
            Console.WriteLine("Conversion to Deezer json file complete. {0} tracks found on Deezer out of {1} tracks.", totalTracksFound, totalTracks);
        }
コード例 #3
0
ファイル: Setup.cs プロジェクト: xfischer/E.Deezer
        //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
        }
コード例 #4
0
        public ChartsEndpointTests()
            : base("ChartsEndpoint")
        {
            this.handler = new OfflineMessageHandler();

            this.session = new DeezerSession(this.handler);
        }
コード例 #5
0
        public static void Initialise(IPlatformServices platformServices,
                                      ISecrets secrets)
        {
            PlatformServices = platformServices;

            ViewModelFactory = new ViewModelFactory();
            DeezerSession    = new DeezerSession(new HttpClientHandler());

            AuthenticationService = new AuthenticationService(DeezerSession,
                                                              platformServices.SecureStorage);

            FavouritesService = new FavouritesService(DeezerSession, AuthenticationService);

            // TODO: Need to work out how to dispose of services when they are dying off
            Register <IGenreListDataController>(new GenreListDataController(DeezerSession));
            Register <IWhatsNewDataController>(new WhatsNewDataController(DeezerSession));
            Register <IChartsDataController>(new ChartsDataController(DeezerSession));
            Register <ISearchDataController>(new SearchDataController(DeezerSession));
            Register <ITracklistDataController>(new TracklistDataController(DeezerSession));
            Register <IArtistOverviewDataController>(new ArtistOverviewDataController(DeezerSession));
            Register <IUserOverviewDataController>(new UserOverviewDataController(DeezerSession));
            Register <IMyDeezerDataController>(new MyDeezerDataController(DeezerSession, AuthenticationService, FavouritesService));



            Register <IOAuthClient>(new OAuthClient(secrets.AppId,
                                                    secrets.AppSecret,
                                                    secrets.OAuthRedirectUri,
                                                    secrets.DesiredPermissions));
        }
コード例 #6
0
        public async Task <ActionResult> Artists(string q)
        {
            //Create a new DeezerSession for your application
            //You'll retrieve a 'Deezer' object which you can browse the API from.
            var Deezer = DeezerSession.CreateNew();

            //This performs an async search on Deezer for albums matching "Abba"
            //Mapping to API: search/album?q=Abba&index=0&limit=25
            //var search = await Deezer.Search.Albums("Abba");

            //You can vary the size and starting position of querys...

            //Will only return UP-TO a maximum of 10 artists matching "Queen"
            //Mapping to API: search/artist?q=Queen&index=0&limit=10
            var small_search = await Deezer.Search.Artists(q, 10);

            //This will return for UP-TO a maximum of 15 tracks by Elvis.
            //These will be offset by 20 places in the results. This is useful for pagination.
            //Mapping to API: search/track/?q=Elivs&index=20&limt=15
            //var offset_search = await Deezer.Search.Tracks("Elivs", 20, 15);

            var artists = small_search.Select(x => x.Name).ToList();

            return(Json(artists, JsonRequestBehavior.AllowGet));
        }
コード例 #7
0
        public void TestCreateNew()
        {
            var actual = DeezerSession.CreateNew();

            Assert.IsNotNull(actual);
            Assert.IsFalse(actual.IsAuthenticated);
        }
コード例 #8
0
        public void OneTimeSetUp()
        {
            var    deezer = DeezerSession.CreateNew();
            string token  = "frmFoXgyyO1ATzluA6gZIFIoWAf8b8G4tGWHaoxtDN9oCKMghM";

            if (string.IsNullOrEmpty(token))
            {
                throw new NotLoggedInException();
            }

            deezer.Login(token)
            .GetAwaiter().GetResult();

            _user = deezer.User;

            _album = deezer.Browse.GetAlbumById(302127)
                     .GetAwaiter().GetResult();

            _artist = deezer.Browse.GetArtistById(27)
                      .GetAwaiter().GetResult();

            _track = deezer.Browse.GetTrackById(3135556)
                     .GetAwaiter().GetResult();

            _playlist = deezer.Browse.GetPlaylistById(908622995)
                        .GetAwaiter().GetResult();

            _radio = deezer.Browse.GetRadioById(6)
                     .GetAwaiter().GetResult();
        }
コード例 #9
0
        public DeezerSession GetDeezerApi()
        {
            if (_deezerSession == null)
            {
                _deezerSession = new DeezerSession(new HttpClientHandler());
            }

            return(_deezerSession);
        }
コード例 #10
0
        public UserEndpointLiveApiTests()
        {
            this.random  = new Random((int)DateTime.UtcNow.Ticks);
            this.session = new DeezerSession(new HttpClientHandler());

            LoginSession();

            FetchObjects();
        }
コード例 #11
0
ファイル: Deezer.cs プロジェクト: projectgoav/E.Deezer
        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);
        }
コード例 #12
0
        public void SetUp()
        {
            this.handler = new OfflineAuthenticationMessageHandler();

            this.session = new DeezerSession(this.handler);

            bool didLogin = this.session.Login("access_token", CancellationToken.None)
                            .Result;

            Assert.IsTrue(didLogin);
        }
コード例 #13
0
        /// <summary>
        /// permet de se connecter a Deezer, retourne true si la connection reussi et
        /// false sinon
        /// </summary>
        /// <returns></returns>
        public override bool ConnectClient()
        {
            if (m_deezer == null)
            {
                m_deezer = DeezerSession.CreateNew();
            }

            if (m_deezer == null)
            {
                return(false);
            }
            return(true);
        }
コード例 #14
0
        /// <summary>
        /// permet de s authentifier aupres de Deezer, retourne true si l operation
        /// reussie et false sinon
        /// </summary>
        /// <returns></returns>
        public override async Task <bool> RunAuthentication()
        {
            if (m_deezer == null)
            {
                await Task.Run(() => m_deezer = DeezerSession.CreateNew());
            }

            if (m_deezer == null)
            {
                return(false);
            }
            return(true);
        }
コード例 #15
0
        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;
        }
コード例 #16
0
ファイル: Form1.cs プロジェクト: xfischer/PlaylistYearizeer
        private async void btnConnect_Click(object sender, EventArgs e)
        {
            try
            {
                _deezer = DeezerSession.CreateNew();

                await _deezer.Login(txtToken.Text);

                AddToLog("Logged in.");

                panel1.Enabled = true;
            }
            catch (Exception v_ex)
            {
                MessageBox.Show(v_ex.ToString());
            }
        }
コード例 #17
0
 public ChartsEndpointLiveApiTests()
 {
     this.session = new DeezerSession(new HttpClientHandler());
 }
コード例 #18
0
 public GetByIdLiveApiTests()
 {
     this.session = new DeezerSession(new HttpClientHandler());
 }
コード例 #19
0
 public static void OneTimeSetUp()
 {
     _charts = DeezerSession.CreateNew().Browse.Charts;
 }
コード例 #20
0
 public static void OneTimeSetUp()
 {
     _radio = DeezerSession.CreateNew().Radio;
 }
コード例 #21
0
 public static void OneTimeSetUp()
 {
     _genre = DeezerSession.CreateNew().Browse.Genre;
 }
コード例 #22
0
 public static void OneTimeSetUp()
 {
     _search = DeezerSession.CreateNew().Search;
 }
コード例 #23
0
 public static void OneTimeSetUp()
 {
     _browse = DeezerSession.CreateNew().Browse;
 }
コード例 #24
0
 private OfflineDeezerSession(OfflineMessageHandler messageHandler)
 {
     MessageHandler = messageHandler;
     Library        = DeezerSession.CreateNew(MessageHandler);
 }
コード例 #25
0
 public DeezerConnector()
 {
     this.deezer = DeezerSession.CreateNew();
 }
コード例 #26
0
ファイル: GetByIdTests.cs プロジェクト: AllsGamingHD/E.Deezer
 public GetByIdTests()
     : base("BrowseEndpoint")
 {
     this.handler = new OfflineMessageHandler();
     this.session = new DeezerSession(this.handler);
 }