Example #1
0
        public void AddEntry <T>(T download, DownloadSettings settings, string fileName) where T : IDownloadable, IMusicInformation
        {
            HasEntries = true;
            var entry = new DownloadEntry
            {
                IsWaiting         = true,
                DownloadFilename  = fileName,
                Trackname         = download.WebTrack.SongName,
                DownloadParameter = download.DownloadParameter,
                DownloadMethod    = download.DownloadMethod,
                MusicInformation  = download,
                DownloadSettings  = settings.Clone()
            };

            Entries.Add(entry);
            _hasToCheck = true;
            DownloadTracks();
        }
Example #2
0
 /// <summary>
 /// Converts the file
 /// </summary>
 /// <param name="fileName">The path to the file which should become converted</param>
 /// <param name="newFileName">The name of the new file WITHOUT extension</param>
 /// <param name="settings"></param>
 public static Task ConvertFile(string fileName, string newFileName, DownloadSettings settings)
 {
     return(ConvertFile(fileName, newFileName, settings.Bitrate, settings.Format));
 }
Example #3
0
        public async static Task <bool> DownloadAndConfigureTrack(IDownloadable downloadInformation, IMusicInformation musicInformation, string fileName, Action <double> progressChangedAction, DownloadSettings settings)
        {
            if (string.IsNullOrEmpty(CommonHelper.GetLocation(downloadInformation.DownloadParameter)))
            {
                return(false);
            }
            if (!await DownloadTrack(downloadInformation, fileName, progressChangedAction))
            {
                return(false);
            }

            if (settings.IsConverterEnabled)
            {
                var oldFile = new FileInfo(fileName);
                oldFile.MoveTo(GeneralHelper.GetFreeFileName(oldFile.Directory, oldFile.Extension).FullName); //We move the downloaded file to a temp location
                await ffmpeg.ConvertFile(oldFile.FullName, fileName, settings.Bitrate, settings.Format);
            }

            //TagLib# destroys all aac files...
            if (settings.AddTags && settings.Format != AudioFormat.AAC)
            {
                await AddTags(musicInformation, fileName);
            }
            return(true);
        }
Example #4
0
        public async static Task <bool> DownloadAndConfigureTrack(IDownloadable downloadInformation, IMusicInformation musicInformation, string fileName, Action <double> progressChangedAction, DownloadSettings settings)
        {
            var link = CommonHelper.GetLocation(downloadInformation.DownloadParameter);

            if (string.IsNullOrEmpty(link))
            {
                return(false);
            }
            downloadInformation.DownloadParameter = link;
            var format = CommonHelper.GetFormat(link);

            if (!fileName.EndsWith(format))
            {
                fileName =
                    // ReSharper disable once StringLastIndexOfIsCultureSpecific.1
                    fileName.Substring(0, fileName.LastIndexOf(".")) + format;
            }
            downloadInformation.DownloadFilename = fileName;
            if (!await DownloadTrack(downloadInformation, fileName, progressChangedAction))
            {
                return(false);
            }

            if (settings.IsConverterEnabled)
            {
                var oldFile = new FileInfo(fileName);
                oldFile.MoveTo(GeneralHelper.GetFreeFileName(oldFile.Directory, oldFile.Extension).FullName); //We move the downloaded file to a temp location
                await ffmpeg.ConvertFile(oldFile.FullName, fileName, settings.Bitrate, settings.Format);
            }

            //TagLib# destroys all aac files...
            if (settings.AddTags && settings.Format != AudioFormat.AAC)
            {
                await AddTags(musicInformation, fileName);
            }
            return(true);
        }