public override void Delete()
 {
     if (DownloadState == DownloadState.Error || DownloadState == DownloadState.Ready)
     {
         return;
     }
     try {
         var title     = DownloadHelper.GetLegalPath(Title);
         var videoFile = VideoFolder.CreateFile(title + VideoExtension);
         if (videoFile.Exists())
         {
             videoFile.Delete();
         }
         if (MediaType == MediaType.Audio)
         {
             var audioFile = DownloadFolder.CreateFile(title + ".mp3");
             if (audioFile.Exists())
             {
                 audioFile.Delete();
             }
         }
     } catch { }
     base.Delete();
     UpdateStatus(DownloadState.Deleted);
 }
        public void DownloadAsync(MediaType mediaType)
        {
            if (ExecutionStatus == ExecutionStatus.Deleted)
            {
                Delete(); return;
            }
            // Now Download Async calls this
            // UpdateStatus(DownloadState.DownloadStart, 0.0);
            MediaType      = mediaType;
            BaseFolder     = KnownFolders.VideosLibrary;
            ProviderFolder = BaseFolder.GetFolder(Enum.GetName(typeof(ContentProviderType), YoutubeUrl.Provider));
            VideoFolder    = ProviderFolder.GetFolder(DownloadHelper.GetLegalPath(ChannelName));

            if (MediaType == MediaType.Audio)
            {
                var audioFolder = KnownFolders.MusicLibrary;
                ProviderFolder = audioFolder.GetFolder(Enum.GetName(typeof(ContentProviderType), YoutubeUrl.Provider));
                DownloadFolder = ProviderFolder.GetFolder(DownloadHelper.GetLegalPath(ChannelName));
            }

            var videoInCache = false;

            if (!String.IsNullOrEmpty(Title))
            {
                VideoExtension = ".mp4";
                var videoFile1   = DownloadHelper.GetLegalPath(Title) + VideoExtension;
                var storageFile1 = VideoFolder.CreateFile(videoFile1);
                if (!CacheManager.Instance.NeedsDownload(YoutubeUrl.VideoId, storageFile1))
                {
                    videoInCache = true;
                }
            }
            if (!videoInCache)
            {
                var       videoInfos = DownloadHelper.GetDownloadUrlsAsync(Uri);
                VideoInfo videoInfo  = null;
                foreach (VideoInfo info in videoInfos)
                {
                    if (info.VideoType == VideoType.Mp4 && info.Resolution == 360)
                    {
                        videoInfo = info;
                        break;
                    }
                }
                if (videoInfo == null)
                {
                    UpdateStatus(DownloadState.Error);
                    return;
                }
                Title          = videoInfo.Title;
                VideoExtension = videoInfo.VideoExtension;
                var videoFile = DownloadHelper.GetLegalPath(Title) + VideoExtension;
                UpdateStatus(DownloadState.TitleChanged, Percentage);
                var storageFile = VideoFolder.CreateFile(videoFile);
                if (CacheManager.Instance.NeedsDownload(YoutubeUrl.VideoId, storageFile))
                {
                    CacheManager.Instance.SetFinished(YoutubeUrl.VideoId, storageFile.ToString(), false);
                    DownloadHelper.DownloadToFileAsync(this, videoInfo.DownloadUri, storageFile, OnYoutubeLoading);
                    CacheManager.Instance.SetFinished(YoutubeUrl.VideoId, storageFile.ToString(), true);
                    if (OnEntryDownloadStatusChange != null)
                    {
                        OnEntryDownloadStatusChange(this, DownloadState.UpdateCache, Percentage);
                    }
                }
            }
            DownloadState = DownloadState.DownloadFinish;
            //UpdateStatus(DownloadState, (MediaType == MediaType.Audio) ? 50 : 100);
            if (MediaType == MediaType.Audio)
            {
                Percentage = 50.0;
                var converter = new AudioConverter(this, OnAudioConversionStatusChange);
                converter.ConvertToMp3();
            }
            else if (OnEntryDownloadStatusChange != null)
            {
                UpdateStatus(DownloadState.Ready);
            }
        }