Exemplo n.º 1
0
        public void DeleteTrack(string trackId)
        {
            var track = TrackDao.ReadTrackById(trackId);

            if (track == null)
            {
                return;
            }

            var trackReference = track.TrackReference;

            SubFingerprintDao.DeleteSubFingerprintsByTrackReference(trackReference);
            TrackDao.DeleteTrack(trackReference);
        }
Exemplo n.º 2
0
        public TrackInfo ReadTrackById(string trackId)
        {
            var trackData = TrackDao.ReadTrackById(trackId);

            if (trackData == null)
            {
                return(null);
            }

            var metaFields = CopyMetaFields(trackData.MetaFields);

            metaFields.Add("TrackLength", $"{trackData.Length: 0.000}");
            return(new TrackInfo(trackData.Id, trackData.Title, trackData.Artist, metaFields, trackData.MediaType));
        }
Exemplo n.º 3
0
        public AVHashes ReadHashesByTrackId(string trackId)
        {
            var track = TrackDao.ReadTrackById(trackId);

            if (track == null)
            {
                return(AVHashes.Empty);
            }

            var fingerprints = SubFingerprintDao
                               .ReadHashedFingerprintsByTrackReference(track.TrackReference)
                               .Select(subFingerprint => new HashedFingerprint(subFingerprint.Hashes, subFingerprint.SequenceNumber, subFingerprint.SequenceAt, subFingerprint.OriginalPoint));

            return(new AVHashes(new Hashes(fingerprints, track.Length, MediaType.Audio), Hashes.GetEmpty(MediaType.Video)));
        }
Exemplo n.º 4
0
        public void UpdateTrack(TrackInfo trackInfo)
        {
            if (trackInfo.MediaType.HasFlag(MediaType.Video))
            {
                throw new NotSupportedException(VIDEO_NOT_SUPPORTED_MESSAGE);
            }

            var track = TrackDao.ReadTrackById(trackInfo.Id);

            if (track == null)
            {
                throw new ArgumentException($"Could not find track {trackInfo.Id} to update", nameof(trackInfo.Id));
            }

            var subFingerprints = SubFingerprintDao.ReadHashedFingerprintsByTrackReference(track.TrackReference);
            var hashes          = new Hashes(subFingerprints.Select(subFingerprint => new HashedFingerprint(subFingerprint.Hashes, subFingerprint.SequenceNumber, subFingerprint.SequenceAt, subFingerprint.OriginalPoint)), track.Length, track.MediaType);

            DeleteTrack(trackInfo.Id);
            Insert(trackInfo, new AVHashes(hashes, null));
        }