Inheritance: LastFMTrackBase
Esempio n. 1
0
        /// <summary>
        /// Scrobble track to last.fm showing as played on user profile on last.fm website
        /// </summary>
        /// <param name="artist">artist of track that was played</param>
        /// <param name="trackTitle">name of track that was played</param>
        /// <param name="album">album that track that was played is part of</param>
        /// <param name="isUserSubmitted">True if track was selected by user or false if by system (radio / auto DJ etc)</param>
        /// <param name="dtPlayed">Date track was played</param>
        /// <exception cref="LastFMException">when things go wrong.</exception>
        public static void Scrobble(string artist, string trackTitle, string album, bool isUserSubmitted,
                                    DateTime dtPlayed)
        {
            var track = new LastFMScrobbleTrack
            {
                ArtistName   = artist,
                TrackTitle   = trackTitle,
                AlbumName    = album,
                DatePlayed   = dtPlayed,
                UserSelected = isUserSubmitted
            };

            var tracks = new List <LastFMScrobbleTrack> {
                track
            };

            ScrobbleTracks(tracks);
        }
 /// <summary>
 /// Read cached scrobbles and submit
 /// </summary>
 public static void SubmitCachedScrobbles()
 {
   var tracks = new List<LastFMScrobbleTrack>();
   var path = Config.GetFile(Config.Dir.Database, "lastfmcache.txt");
   using (StreamReader sr = File.OpenText(path))
   {
     string s;
     while ((s = sr.ReadLine()) != null)
     {
       var t = s.Split('\t');
       var a = new LastFMScrobbleTrack
         {
           ArtistName = t[0],
           TrackTitle = t[1],
           AlbumName = t[2],
           UserSelected = t[3] == "true",
           DatePlayed = DateTime.UtcNow
         };
       tracks.Add(a);
     }
   }
   
   LastFMLibrary.ScrobbleTracks(tracks);
 }