Ejemplo n.º 1
0
        public bool RefreshEditionInfo(List <Edition> add, List <Edition> update, List <Tuple <Edition, Edition> > merge, List <Edition> delete, List <Edition> upToDate, List <Edition> remoteEditions, bool forceUpdateFileTags)
        {
            var updateList = new List <Edition>();

            // for editions that need updating, just grab the remote edition and set db ids
            foreach (var edition in update)
            {
                var remoteEdition = remoteEditions.Single(e => e.ForeignEditionId == edition.ForeignEditionId);
                edition.UseMetadataFrom(remoteEdition);

                // make sure title is not null
                edition.Title = edition.Title ?? "Unknown";
                updateList.Add(edition);
            }

            _editionService.DeleteMany(delete.Concat(merge.Select(x => x.Item1)).ToList());
            _editionService.UpdateMany(updateList);

            var tagsToUpdate = updateList;

            if (forceUpdateFileTags)
            {
                _logger.Debug("Forcing tag update due to Author/Book/Edition updates");
                tagsToUpdate = updateList.Concat(upToDate).ToList();
            }

            _audioTagService.SyncTags(tagsToUpdate);
            _eBookTagService.SyncTags(tagsToUpdate);

            return(add.Any() || delete.Any() || updateList.Any() || merge.Any());
        }
Ejemplo n.º 2
0
        public bool RefreshTrackInfo(List <Track> add, List <Track> update, List <Tuple <Track, Track> > merge, List <Track> delete, List <Track> upToDate, List <Track> remoteTracks, bool forceUpdateFileTags)
        {
            var updateList = new List <Track>();

            // for tracks that need updating, just grab the remote track and set db ids
            foreach (var track in update)
            {
                var remoteTrack = remoteTracks.Single(e => e.ForeignTrackId == track.ForeignTrackId);
                track.UseMetadataFrom(remoteTrack);

                // make sure title is not null
                track.Title = track.Title ?? "Unknown";
                updateList.Add(track);
            }

            // Move trackfiles from merged entities into new one
            foreach (var item in merge)
            {
                var trackToMerge = item.Item1;
                var mergeTarget  = item.Item2;

                if (mergeTarget.TrackFileId == 0)
                {
                    mergeTarget.TrackFileId = trackToMerge.TrackFileId;
                }

                if (!updateList.Contains(mergeTarget))
                {
                    updateList.Add(mergeTarget);
                }
            }

            _trackService.DeleteMany(delete.Concat(merge.Select(x => x.Item1)).ToList());
            _trackService.UpdateMany(updateList);

            var tagsToUpdate = updateList;

            if (forceUpdateFileTags)
            {
                _logger.Debug("Forcing tag update due to Artist/Album/Release updates");
                tagsToUpdate = updateList.Concat(upToDate).ToList();
            }

            _audioTagService.SyncTags(tagsToUpdate);

            return(add.Any() || delete.Any() || updateList.Any() || merge.Any());
        }
Ejemplo n.º 3
0
 public void SyncTags(List <Edition> editions)
 {
     _audioTagService.SyncTags(editions);
     _eBookTagService.SyncTags(editions);
 }