public void Submit(YouTubeEntry song) { if (!IsLoged) { return; } try { string Artist = string.Empty; string Title = string.Empty; int length = 0; string _title = song.Title.Text; if (_title.Contains("-")) { Artist = _title.Split('-')[0].Trim(); Title = _title.Split('-')[1].Trim(); } if (song.Duration != null && song.Duration.Seconds != null) { length = Convert.ToInt32(song.Duration.Seconds, 10); } if (!string.IsNullOrEmpty(Artist) && !string.IsNullOrEmpty(Title) && length > 0) { Entry entry = new Entry(Artist, Title, DateTime.Now, PlaybackSource.User, new TimeSpan(0, 0, length), ScrobbleMode.Played); manager.Queue(entry); //manager.Submit(); } } catch (Exception exception) { Log.Error(exception); } }
async Task <bool> SubmitScrobbleToLastFm(Song song, double position, double duration) { try { if (position < 30) { return(true); } manager.Queue(new Entry(song.Artist, song.Name, song.Album, DateTime.UtcNow, PlaybackSource.User, TimeSpan.FromSeconds(duration), ScrobbleMode.Played)); return(true); } catch (Exception ex) { Console.WriteLine(ex); return(false); } }