Esempio n. 1
0
        public async Task <HttpResponseMessage> StartScrobble(SongDetails song)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }

            await _lastFmService.StartScrobble(song);

            return(new HttpResponseMessage(HttpStatusCode.OK));
        }
Esempio n. 2
0
        public async Task <string> StartScrobble()
        {
            var pandoraInfo = _playerService.GetCurrentSongInfo();
            var song        = new SongDetails()
            {
                Album  = pandoraInfo.Album,
                Artist = pandoraInfo.Artist,
                Song   = pandoraInfo.Song
            };

            return(await _lastFmService.StartScrobble(song));
        }
Esempio n. 3
0
        public async Task SongChange(DeezerState deezerState)
        {
            if (File.Exists("deezer.json"))
            {
                var lastSong = _playerFactoryService.GetCurrentSongInfo();

                if ((DateTime.UtcNow - lastSong.LastModifed) > TimeSpan.FromMinutes(1))
                {
                    await _lastFMService.StartScrobble(new SongDetails
                    {
                        Album  = lastSong.Album,
                        Song   = lastSong.Song,
                        Artist = lastSong.Artist
                    });
                }
            }

            var context = Microsoft.AspNet.SignalR.GlobalHost.ConnectionManager.GetHubContext <ServerHub>();

            if (context == null)
            {
                return;
            }

            var pandoraInfo = new PandoraResult
            {
                Album       = deezerState.AlbumName,
                AlbumUri    = deezerState.AlbumUri,
                Artist      = deezerState.ArtistName,
                IsPlaying   = deezerState.IsPlaying,
                LastModifed = deezerState.UpdatedUtc,
                Loved       = false,
                Radio       = deezerState.StreamName,
                Song        = deezerState.SongName
            };

            RabbitMqService.SongChange(pandoraInfo);
            context.Clients.All.pandoraRefresh(pandoraInfo);

            var song = new SongDetails()
            {
                Album  = pandoraInfo.Album,
                Artist = pandoraInfo.Artist,
                Song   = pandoraInfo.Song
            };

            await _lastFMService.UpdateNowPlaying(song);

            var json = JsonConvert.SerializeObject(deezerState);

            File.WriteAllText("deezer.json", json, Encoding.UTF8);
        }