Ejemplo n.º 1
0
        async Task <FullTrackData> updateServerMetaData(CloudNode node)
        {
            string id = "";

            //Dictionary<string, string> properties;
            //if (node.Properties?.TryGetValue(ApiConstants.AmazonAppIdentifier,out properties) ?? false && properties.TryGetValue("Id",out id) && !string.IsNullOrWhiteSpace(id))
            //{
            //	return true;
            //}
            Models.FullTrackData fileInfo = null;
            try
            {
                fileInfo = await GetTrackDataFromWebServer(Api, node.TempLink);

                fileInfo.ServiceType   = ServiceType.Amazon;
                fileInfo.ServiceId     = Id;
                fileInfo.Id            = node.Id;
                fileInfo.FileExtension = node.ContentProperties.Extension;
                fileInfo.MediaType     = node.ContentProperties.Video != null ? MediaType.Video : node.ContentProperties.image != null ? MediaType.Photo : MediaType.Audio;

                await Api.UpdateMetaDataProperty(node.Id, ApiConstants.AmazonAppIdentifier, "Id", fileInfo.SongId);

                await Api.UpdateMetaDataProperty(node.Id, ApiConstants.AmazonAppIdentifier, "Artist", fileInfo.Artist);

                await Api.UpdateMetaDataProperty(node.Id, ApiConstants.AmazonAppIdentifier, "Album", fileInfo.Album);

                await Api.UpdateMetaDataProperty(node.Id, ApiConstants.AmazonAppIdentifier, "Title", fileInfo.Title);

                if (!string.IsNullOrWhiteSpace(fileInfo.Genre))
                {
                    await Api.UpdateMetaDataProperty(node.Id, ApiConstants.AmazonAppIdentifier, "Genre", fileInfo.Genre);
                }

                if (fileInfo.Year > 0)
                {
                    await Api.UpdateMetaDataProperty(node.Id, ApiConstants.AmazonAppIdentifier, "Year", fileInfo.Year.ToString());
                }
                return(fileInfo);
            }
            catch (Exception ex)
            {
                //TODO: Add to heavy indexing!
                //Console.WriteLine(ex);
                return(fileInfo);
            }
        }
Ejemplo n.º 2
0
 FullTrackData CreateFromNode(CloudNode node)
 {
     try
     {
         string title;
         string id;
         string album;
         string artist;
         string genre;
         int    year = 0;
         string yearStr;
         var    dict = node.Properties[ApiConstants.AmazonAppIdentifier];
         dict.TryGetValue("Title", out title);
         dict.TryGetValue("Id", out id);
         dict.TryGetValue("Album", out album);
         dict.TryGetValue("Artist", out artist);
         dict.TryGetValue("Genre", out genre);
         int    rating = 0;
         string ratingString;
         if (dict.TryGetValue("Year", out yearStr))
         {
             year = int.Parse(yearStr);
         }
         if (dict.TryGetValue("Rating", out ratingString))
         {
             rating = int.Parse(ratingString);
         }
         var track = new FullTrackData(title, artist, "", album, genre)
         {
             Year          = year,
             SongId        = id,
             Id            = node.Id,
             ServiceId     = Id,
             Rating        = rating,
             ServiceType   = ServiceType.Amazon,
             MediaType     = node.ContentProperties.Video != null ? MediaType.Video : node.ContentProperties.image != null ? MediaType.Photo : MediaType.Audio,
             FileExtension = node.ContentProperties.Extension,
         };
         return(track);
     }
     catch (Exception ex)
     {
         LogManager.Shared.Report(ex);
     }
     return(null);
 }
Ejemplo n.º 3
0
        public async Task <FullTrackData> UpdateServerMetaData(CloudNode node)
        {
            var success = await MetaDataQueue.Enqueue(5, () => updateServerMetaData(node));

            return(success);
        }