arrow key nav,binding bt server to arrow key event,scanning ask if new can or to just add new stuff,fatal scanning error fixed.now skips broken or corrupt files,if file has missing permisions also skip
This commit is contained in:
@@ -256,216 +256,274 @@ public partial class MainWindow : Window
|
||||
}
|
||||
|
||||
|
||||
private async void scanButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
Muvie.clear();
|
||||
Serie.clear();
|
||||
Music.clear();
|
||||
Photo.clear();
|
||||
log.Log("Scanning files...");
|
||||
|
||||
List<string> tmp = new List<string>();
|
||||
|
||||
switch (option)
|
||||
private async void scanButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
case 0:
|
||||
foreach (var VARIABLE in dirs)
|
||||
{
|
||||
var scanResult = await fileScanner.ScanDriveParallel(VARIABLE);
|
||||
tmp.AddRange(scanResult);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
var scanResult1 = await fileScanner.ScanDriveParallel(dirs[specificOption]);
|
||||
tmp.AddRange(scanResult1);
|
||||
break;
|
||||
case 2:
|
||||
var scanResult2 = await fileScanner.ScanDriveParallel(rootPath);
|
||||
tmp.AddRange(scanResult2);
|
||||
break;
|
||||
}
|
||||
|
||||
log.Log($"Total scanned files: {tmp.Count}");
|
||||
|
||||
var classifier = new FileClassifier();
|
||||
var (musicFiles, videoFiles, photoFiles) = await classifier.ClassifyFilesAsync(tmp, suportedMusicFiles, suportedVidioFiles, suportedPhotoFiles);
|
||||
|
||||
var separator = new VideoSeparator();
|
||||
var (series, movies) = await separator.SeparateVideosAsync(videoFiles);
|
||||
|
||||
log.Log($"musicFiles count: {musicFiles.Count}");
|
||||
log.Log($"videoFiles count: {videoFiles.Count}");
|
||||
log.Log($"photoFiles count: {photoFiles.Count}");
|
||||
log.Log($"series count: {series.Count}");
|
||||
log.Log($"movies count: {movies.Count}");
|
||||
|
||||
progressScann = new ProgressBar("ImageGen", musicFiles.Count + videoFiles.Count + photoFiles.Count);
|
||||
progressScann.Show();
|
||||
videoFiles = null;
|
||||
|
||||
log.Log("files sorted");
|
||||
|
||||
List<locJason> muviesJS = new List<locJason>();
|
||||
List<locJason> seriesJS = new List<locJason>();
|
||||
List<locJason> photosJS = new List<locJason>();
|
||||
List<locJason> musicJS = new List<locJason>();
|
||||
|
||||
JasonToString jasonToString = new JasonToString();
|
||||
|
||||
var movieItems = await ItemCreater(movies, "Muvie", false);
|
||||
foreach (var item in movieItems)
|
||||
{
|
||||
BitmapImage bitmapImage = item.getImage();
|
||||
if (bitmapImage != null)
|
||||
try
|
||||
{
|
||||
try
|
||||
MessageBoxResult result =
|
||||
MessageBox.Show(
|
||||
"Do you want to replace existing items\nyes will delite existing items/no keeps them",
|
||||
"replace items", MessageBoxButton.YesNoCancel);
|
||||
|
||||
if (result == MessageBoxResult.Cancel)
|
||||
return;
|
||||
else if (result == MessageBoxResult.Yes)
|
||||
{
|
||||
string base64Image = jasonToString.BitmapToBase64String(
|
||||
BitmapConversions.BitmapImageToBitmap(bitmapImage));
|
||||
Muvie.addItem(item);
|
||||
muviesJS.Add(new locJason
|
||||
Muvie.clear();
|
||||
Serie.clear();
|
||||
Music.clear();
|
||||
Photo.clear();
|
||||
}
|
||||
|
||||
|
||||
log.Log("Scanning files...");
|
||||
|
||||
List<string> tmp = new List<string>();
|
||||
|
||||
switch (option)
|
||||
{
|
||||
case 0:
|
||||
foreach (var VARIABLE in dirs)
|
||||
{
|
||||
var scanResult = await fileScanner.ScanDriveParallel(VARIABLE);
|
||||
tmp.AddRange(scanResult);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
var scanResult1 = await fileScanner.ScanDriveParallel(dirs[specificOption]);
|
||||
tmp.AddRange(scanResult1);
|
||||
break;
|
||||
case 2:
|
||||
var scanResult2 = await fileScanner.ScanDriveParallel(rootPath);
|
||||
tmp.AddRange(scanResult2);
|
||||
break;
|
||||
}
|
||||
|
||||
log.Log($"Total scanned files: {tmp.Count}");
|
||||
|
||||
var classifier = new FileClassifier();
|
||||
var (musicFiles, videoFiles, photoFiles) = await classifier.ClassifyFilesAsync(tmp, suportedMusicFiles, suportedVidioFiles, suportedPhotoFiles);
|
||||
|
||||
var separator = new VideoSeparator();
|
||||
var (series, movies) = await separator.SeparateVideosAsync(videoFiles);
|
||||
|
||||
log.Log($"musicFiles count: {musicFiles.Count}");
|
||||
log.Log($"videoFiles count: {videoFiles.Count}");
|
||||
log.Log($"photoFiles count: {photoFiles.Count}");
|
||||
log.Log($"series count: {series.Count}");
|
||||
log.Log($"movies count: {movies.Count}");
|
||||
|
||||
Console.WriteLine($"Total scanned files: {tmp.Count}");
|
||||
Console.WriteLine($"Total video files: {videoFiles.Count}");
|
||||
|
||||
Console.WriteLine($"Total musicFiles count: {musicFiles.Count}");
|
||||
Console.WriteLine($"Total photo files: {photoFiles.Count}");
|
||||
Console.WriteLine($"Total series count: {series.Count}");
|
||||
Console.WriteLine($"Total muvies count: {movies.Count}");
|
||||
|
||||
if (result == MessageBoxResult.No)
|
||||
{
|
||||
var tmp2 = new List<string>();
|
||||
foreach (var VARIABLE in musicFiles)
|
||||
{
|
||||
path = item.getLink(),
|
||||
imageData = base64Image,
|
||||
type = item.getType()
|
||||
});
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Console.WriteLine($"Error processing movie item {item.getLink()}: {exception.Message}");
|
||||
log.Error($"Error processing movie item {item.getLink()}: {exception}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"Warning: Movie item {item.getLink()} has no image data.");
|
||||
log.Log($"Warning: Movie item {item.getLink()} has no image data.");
|
||||
}
|
||||
}
|
||||
|
||||
var seriesItems = await ItemCreater(series, "Serie", false);
|
||||
foreach (var item in seriesItems)
|
||||
{
|
||||
BitmapImage bitmapImage = item.getImage();
|
||||
if (bitmapImage != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
string base64Image = jasonToString.BitmapToBase64String(
|
||||
BitmapConversions.BitmapImageToBitmap(bitmapImage));
|
||||
Serie.addItem(item);
|
||||
seriesJS.Add(new locJason
|
||||
if (!Music.getLink().Contains(VARIABLE)) ;
|
||||
tmp2.Add(VARIABLE);
|
||||
}
|
||||
musicFiles.Clear();
|
||||
musicFiles.AddRange(tmp2);
|
||||
tmp2.Clear();
|
||||
foreach (var VARIABLE in series)
|
||||
{
|
||||
path = item.getLink(),
|
||||
imageData = base64Image,
|
||||
type = item.getType()
|
||||
});
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Console.WriteLine($"Error processing series item {item.getLink()}: {exception.Message}");
|
||||
log.Error($"Error processing series item {item.getLink()}: {exception}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"Warning: Series item {item.getLink()} has no image data.");
|
||||
log.Log($"Warning: Series item {item.getLink()} has no image data.");
|
||||
}
|
||||
}
|
||||
|
||||
var photoItems = await ItemCreater(photoFiles, "Photo", true);
|
||||
foreach (var item in photoItems)
|
||||
{
|
||||
BitmapImage bitmapImage = item.getImage();
|
||||
if (bitmapImage != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
string base64Image = jasonToString.BitmapToBase64String(
|
||||
BitmapConversions.BitmapImageToBitmap(bitmapImage));
|
||||
Photo.addItem(item);
|
||||
photosJS.Add(new locJason
|
||||
if (!Serie.getLink().Contains(VARIABLE)) ;
|
||||
tmp2.Add(VARIABLE);
|
||||
}
|
||||
series.Clear();
|
||||
series.AddRange(tmp2);
|
||||
tmp2.Clear();
|
||||
foreach (var VARIABLE in movies)
|
||||
{
|
||||
path = item.getLink(),
|
||||
imageData = base64Image,
|
||||
type = item.getType()
|
||||
});
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Console.WriteLine($"Error processing photo item {item.getLink()}: {exception.Message}");
|
||||
log.Error($"Error processing photo item {item.getLink()}: {exception}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"Warning: Photo item {item.getLink()} has no image data.");
|
||||
log.Log($"Warning: Photo item {item.getLink()} has no image data.");
|
||||
}
|
||||
}
|
||||
|
||||
var musicItems = await ItemCreater(musicFiles, "Music", false);
|
||||
foreach (var item in musicItems)
|
||||
{
|
||||
BitmapImage bitmapImage = item.getImage();
|
||||
if (bitmapImage != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
string base64Image = jasonToString.BitmapToBase64String(
|
||||
BitmapConversions.BitmapImageToBitmap(bitmapImage));
|
||||
Music.addItem(item);
|
||||
musicJS.Add(new locJason
|
||||
if(!Muvie.getLink().Contains(VARIABLE)) ;
|
||||
tmp2.Add(VARIABLE);
|
||||
}
|
||||
movies.Clear();
|
||||
movies.AddRange(tmp2);
|
||||
tmp2.Clear();
|
||||
foreach (var VARIABLE in photoFiles)
|
||||
{
|
||||
path = item.getLink(),
|
||||
imageData = base64Image,
|
||||
type = item.getType()
|
||||
});
|
||||
if(!Photo.getLink().Contains(VARIABLE))
|
||||
tmp2.Add(VARIABLE);
|
||||
}
|
||||
photoFiles.Clear();
|
||||
photoFiles.AddRange(tmp2);
|
||||
tmp2.Clear();
|
||||
}
|
||||
catch (Exception exception)
|
||||
|
||||
|
||||
progressScann = new ProgressBar("ImageGen", musicFiles.Count + videoFiles.Count + photoFiles.Count);
|
||||
progressScann.Show();
|
||||
videoFiles = null;
|
||||
|
||||
log.Log("files sorted");
|
||||
|
||||
List<locJason> muviesJS = new List<locJason>();
|
||||
List<locJason> seriesJS = new List<locJason>();
|
||||
List<locJason> photosJS = new List<locJason>();
|
||||
List<locJason> musicJS = new List<locJason>();
|
||||
|
||||
JasonToString jasonToString = new JasonToString();
|
||||
|
||||
var movieItems = await ItemCreater(movies, "Muvie", false);
|
||||
foreach (var item in movieItems)
|
||||
{
|
||||
Console.WriteLine($"Error processing music item {item.getLink()}: {exception.Message}");
|
||||
log.Error($"Error processing music item {item.getLink()}: {exception}");
|
||||
BitmapImage bitmapImage = item.getImage();
|
||||
if (bitmapImage != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
string base64Image = jasonToString.BitmapToBase64String(
|
||||
BitmapConversions.BitmapImageToBitmap(bitmapImage));
|
||||
Muvie.addItem(item);
|
||||
muviesJS.Add(new locJason
|
||||
{
|
||||
path = item.getLink(),
|
||||
imageData = base64Image,
|
||||
type = item.getType()
|
||||
});
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Console.WriteLine($"Error processing movie item {item.getLink()}: {exception.Message}");
|
||||
log.Error($"Error processing movie item {item.getLink()}: {exception}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"Warning: Movie item {item.getLink()} has no image data.");
|
||||
log.Log($"Warning: Movie item {item.getLink()} has no image data.");
|
||||
}
|
||||
}
|
||||
|
||||
var seriesItems = await ItemCreater(series, "Serie", false);
|
||||
foreach (var item in seriesItems)
|
||||
{
|
||||
BitmapImage bitmapImage = item.getImage();
|
||||
if (bitmapImage != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
string base64Image = jasonToString.BitmapToBase64String(
|
||||
BitmapConversions.BitmapImageToBitmap(bitmapImage));
|
||||
Serie.addItem(item);
|
||||
seriesJS.Add(new locJason
|
||||
{
|
||||
path = item.getLink(),
|
||||
imageData = base64Image,
|
||||
type = item.getType()
|
||||
});
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Console.WriteLine($"Error processing series item {item.getLink()}: {exception.Message}");
|
||||
log.Error($"Error processing series item {item.getLink()}: {exception}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"Warning: Series item {item.getLink()} has no image data.");
|
||||
log.Log($"Warning: Series item {item.getLink()} has no image data.");
|
||||
}
|
||||
}
|
||||
|
||||
var photoItems = await ItemCreater(photoFiles, "Photo", true);
|
||||
foreach (var item in photoItems)
|
||||
{
|
||||
BitmapImage bitmapImage = item.getImage();
|
||||
if (bitmapImage != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
string base64Image = jasonToString.BitmapToBase64String(
|
||||
BitmapConversions.BitmapImageToBitmap(bitmapImage));
|
||||
Photo.addItem(item);
|
||||
photosJS.Add(new locJason
|
||||
{
|
||||
path = item.getLink(),
|
||||
imageData = base64Image,
|
||||
type = item.getType()
|
||||
});
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Console.WriteLine($"Error processing photo item {item.getLink()}: {exception.Message}");
|
||||
log.Error($"Error processing photo item {item.getLink()}: {exception}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"Warning: Photo item {item.getLink()} has no image data.");
|
||||
log.Log($"Warning: Photo item {item.getLink()} has no image data.");
|
||||
}
|
||||
}
|
||||
|
||||
var musicItems = await ItemCreater(musicFiles, "Music", false);
|
||||
foreach (var item in musicItems)
|
||||
{
|
||||
BitmapImage bitmapImage = item.getImage();
|
||||
if (bitmapImage != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
string base64Image = jasonToString.BitmapToBase64String(
|
||||
BitmapConversions.BitmapImageToBitmap(bitmapImage));
|
||||
Music.addItem(item);
|
||||
musicJS.Add(new locJason
|
||||
{
|
||||
path = item.getLink(),
|
||||
imageData = base64Image,
|
||||
type = item.getType()
|
||||
});
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Console.WriteLine($"Error processing music item {item.getLink()}: {exception.Message}");
|
||||
log.Error($"Error processing music item {item.getLink()}: {exception}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"Info: Music item {item.getLink()} has no image data.");
|
||||
log.Log($"Info: Music item {item.getLink()} has no image data.");
|
||||
}
|
||||
}
|
||||
|
||||
log.Log("scan finished");
|
||||
|
||||
Jason_Writer jason_Writer = new Jason_Writer();
|
||||
List<Task> tasks = new List<Task>
|
||||
{
|
||||
jason_Writer.SaveList("Muvies", muviesJS),
|
||||
jason_Writer.SaveList("Series", seriesJS),
|
||||
jason_Writer.SaveList("Photos", photosJS),
|
||||
jason_Writer.SaveList("Music", musicJS)
|
||||
};
|
||||
|
||||
await Task.WhenAll(tasks);
|
||||
|
||||
musicJS = null;
|
||||
seriesJS = null;
|
||||
photosJS = null;
|
||||
|
||||
MenueItems();
|
||||
progressScann.Hide();
|
||||
MessageBox.Show("Scan finished");
|
||||
}
|
||||
else
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Info: Music item {item.getLink()} has no image data.");
|
||||
log.Log($"Info: Music item {item.getLink()} has no image data.");
|
||||
MessageBox.Show($"An error occurred during scanning:\n\n{ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
log.Error($"An error occurred during scanning:\n\n{ex}");
|
||||
}
|
||||
}
|
||||
|
||||
log.Log("scan finished");
|
||||
|
||||
Jason_Writer jason_Writer = new Jason_Writer();
|
||||
List<Task> tasks = new List<Task>
|
||||
{
|
||||
jason_Writer.SaveList("Muvies", muviesJS),
|
||||
jason_Writer.SaveList("Series", seriesJS),
|
||||
jason_Writer.SaveList("Photos", photosJS),
|
||||
jason_Writer.SaveList("Music", musicJS)
|
||||
};
|
||||
|
||||
await Task.WhenAll(tasks);
|
||||
|
||||
musicJS = null;
|
||||
seriesJS = null;
|
||||
photosJS = null;
|
||||
|
||||
MenueItems();
|
||||
progressScann.Hide();
|
||||
MessageBox.Show("Scan finished");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"An error occurred during scanning:\n\n{ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
log.Error($"An error occurred during scanning:\n\n{ex}");
|
||||
}
|
||||
}
|
||||
|
||||
private void PlayListButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ObservableCollection<Catagory> tmpBP= new ObservableCollection<Catagory>();
|
||||
|
Reference in New Issue
Block a user