private async Task DeleteMedia(string yid, string fileType) { // use YId as the key for deleting var mediaPathFolder = await StorageFolder.GetFolderFromPathAsync(mediaPath); if (mediaPathFolder != null) { // get extra content folder if it exists & delete it await StorageHelper.TryDeleteFolder(yid, mediaPathFolder); // delete root images await StorageHelper.TryDeleteFile($"{yid}-high.jpg", mediaPathFolder); await StorageHelper.TryDeleteFile($"{yid}-medium.jpg", mediaPathFolder); await StorageHelper.TryDeleteFile($"{yid}-low.jpg", mediaPathFolder); await StorageHelper.TryDeleteFile($"{yid}-max.jpg", mediaPathFolder); await StorageHelper.TryDeleteFile($"{yid}-standard.jpg", mediaPathFolder); // delete root mp3/mp4 await StorageHelper.TryDeleteFile($"{yid}.{fileType}", mediaPathFolder); } // delete DB data EntitiesHelper.DeleteAllByYID(yid); }
private void LoadPlaylistItems() { var result = EntitiesHelper.RetrievePlaylistMetadataAsViewCollection(lastSelectedPlaylistId); gvPlaylists.ItemsSource = result.source; lastSelectedPlaylistId = result.lastSelectedPlaylistId; }
private async Task ProcessYoutubeVideo(VideoDetails videoDetails, string mediaType, string quality) { if (videoDetails == null) { return; } await DownloadThumbnails(videoDetails); var path = mediaPath + $"\\{videoDetails.id}.{mediaType}"; try { if (File.Exists(path)) { File.Delete(path); } await clientHelper.DownloadMedia(videoDetails.id, quality, path, mediaType); var fileInfo = new FileInfo(path); EntitiesHelper.AddMediaMetadata(videoDetails, mediaType, quality, fileInfo.Length); } catch (Exception ex) { // todo: handle error } UpdateLibraryStatistics(); UpdateJobStatistics(); isProcessingJob = false; ProcessJobFromQueue(); }
private void SetupInitialView() { if (lastSelectedPlaylistId != Guid.Empty) { var result = EntitiesHelper.RetrievePlaylistMediaMetadataAsViewCollection(lastSelectedPlaylistId, mediaPath); icMediaItems.ItemsSource = result.source; lastSelectedPlaylistId = result.lastSelectedPlaylistId; } }
private void CreatePlaylist(object sender, RoutedEventArgs e) { if (!string.IsNullOrEmpty(tbTitle.Text)) { EntitiesHelper.AddPlaylistMetadata(tbTitle.Text); tbTitle.Text = string.Empty; } OnPlaylistCreated?.Invoke(null, null); }
private void LoadLibraryItems(bool load) { if (load) { icLibraryItems.ItemsSource = EntitiesHelper.RetrieveMediaMetadataAsViewCollection(mediaPath); } else { //icLibraryItems.Items.Clear(); icLibraryItems.ItemsSource = null; } }
private void OnPlaylistSelected(object sender, EventArgs e) { XamlHelper.CloseFlyout(sender); if (e is PlaylistSelectedEventArgs && sender is FrameworkElement) { var uie = (FrameworkElement)sender; if (uie != null && uie.DataContext is ViewMediaMetadata) { var playlistSelectedEventArgs = (PlaylistSelectedEventArgs)e; var viewMediaMetadata = (ViewMediaMetadata)uie.DataContext; EntitiesHelper.AddPlaylistMediaMetadata(viewMediaMetadata.UniqueId, playlistSelectedEventArgs.SelectedPlaylist.UniqueId); OnMediaAddedToPlaylist?.Invoke(null, null); } } }
private void PlaylistChanged(object sender, SelectionChangedEventArgs e) { icMediaItems.ItemsSource = null; if (e.AddedItems.Count > 0) { foreach (var item in e.AddedItems) { if (item is ViewPlaylistMetadata) { var result = EntitiesHelper.RetrievePlaylistMediaMetadataAsViewCollection(((ViewPlaylistMetadata)item).UniqueId, mediaPath); icMediaItems.ItemsSource = result.source; lastSelectedPlaylistId = result.lastSelectedPlaylistId; } } } }
private async void SaveSnapshots(object sender, RoutedEventArgs e) { if (DataContext is ViewMediaMetadata) { SendSystemNotification("Saving all snapshots ..."); ClearDemoTiles(); var viewMediaMetadata = (ViewMediaMetadata)DataContext; var mediaPathFolder = await StorageFolder.GetFolderFromPathAsync(App.mediaPath); if (mediaPathFolder != null) { // if folder exists delete it await StorageHelper.TryDeleteFolder(viewMediaMetadata.YID, mediaPathFolder); // delete DB ImageMetadata's if they exist EntitiesHelper.DeleteAllImageEditorMetadata(viewMediaMetadata.UniqueId); // create folder var yidFolder = await mediaPathFolder.CreateFolderAsync(viewMediaMetadata.YID); foreach (var snapshot in snapshots) { // save each snapshot as an image into the new folder var newSnapshotFile = await yidFolder.CreateFileAsync($"{viewMediaMetadata.YID}-{snapshot.Number}.jpg"); SaveSoftwareBitmapToFile(snapshot.Bitmap, newSnapshotFile); // create DB record for each snapshot EntitiesHelper.AddImageEditorMetadata(viewMediaMetadata.UniqueId, snapshot.Number, snapshot.Position.TotalSeconds); } SendSystemNotification("Snapshots saved!"); CreateDemoTiles(); } } }
private void UpdatePlaylistStatistics() => tbPlaylistCount.Text = EntitiesHelper.RetrievePlaylistMetadataAsCount().ToString();
private void UpdateLibraryStatistics() => tbLibraryCount.Text = EntitiesHelper.RetrieveMediaMetadataAsCount().ToString();
private void LoadPlaylistItems() => gvPlaylists.ItemsSource = EntitiesHelper.RetrievePlaylistMetadataAsViewCollection();