Initial commit: Add ShadowStream media application with file scanning and classification

This commit is contained in:
unknown
2025-05-23 20:17:46 +02:00
commit 323fc9e120
955 changed files with 25791 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
using System.Collections.Generic;
using System.Threading.Tasks;
namespace file_finder__test.DataBaseModules{
//Alloufi Yazan
public class DataBase
{
}
}

View File

@@ -0,0 +1,51 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
namespace file_finder__test;
public class FileClassifier
{
public async Task<(List<string> musicFiles, List<string> videoFiles)> ClassifyFilesAsync(
List<string> allFiles,
List<string> musicExtensions,
List<string> videoExtensions)
{
int coreCount = Environment.ProcessorCount;
int totalFiles = allFiles.Count;
int chunkSize = (int)Math.Ceiling((double)totalFiles / coreCount);
var musicBag = new ConcurrentBag<string>();
var videoBag = new ConcurrentBag<string>();
var tasks = new List<Task>();
for (int i = 0; i < coreCount; i++)
{
int start = i * chunkSize;
int end = Math.Min(start + chunkSize, totalFiles);
tasks.Add(Task.Run(() =>
{
for (int j = start; j < end; j++)
{
string file = allFiles[j];
string ext = Path.GetExtension(file)?.ToLowerInvariant();
if (ext == null)
continue;
if (musicExtensions.Contains(ext))
musicBag.Add(file);
else if (videoExtensions.Contains(ext))
videoBag.Add(file);
}
}));
}
await Task.WhenAll(tasks);
return (new List<string>(musicBag), new List<string>(videoBag));
}
}

View File

@@ -0,0 +1,79 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
public class FileScanner
{
private readonly string[] _extensions;
private readonly ConcurrentBag<string> _foundFiles = new ConcurrentBag<string>();
public FileScanner(string[] extensions)
{
_extensions = extensions.Select(e => e.ToLower()).ToArray();
}
public async Task<List<string>> ScanAllDrivesAsync()
{
var drives = new List<string>();
foreach (var drive in DriveInfo.GetDrives())
{
if (!drive.IsReady) continue;
Console.WriteLine($"Scanning {drive.Name} ...");
string root = drive.RootDirectory.FullName;
drives.Add(root);
}
return drives.ToList();
}
public async Task<List<string>> ScanDriveParallel(string rootPath)
{
var folderQueue = new ConcurrentQueue<string>();
folderQueue.Enqueue(rootPath);
var folderWorkers = new List<Task>();
//add Preformance testing here later
int maxWorkers = Environment.ProcessorCount/2;
for (int i = 0; i < maxWorkers; i++)
{
folderWorkers.Add(Task.Run(() =>
{
while (folderQueue.TryDequeue(out string currentPath))
{
try
{
// Check files
foreach (var file in Directory.GetFiles(currentPath))
{
if (_extensions.Any(ext => file.EndsWith(ext, StringComparison.OrdinalIgnoreCase)))
{
//Console.WriteLine(file);
_foundFiles.Add(file);
}
}
// Enqueue subdirectories
foreach (var dir in Directory.GetDirectories(currentPath))
{
folderQueue.Enqueue(dir);
}
}
catch
{
// Skip inaccessible folders silently
}
}
}));
}
Task.WaitAll(folderWorkers.ToArray());
return _foundFiles.ToList();
}
}

View File

@@ -0,0 +1,49 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
public class VideoSeparator
{
private readonly Regex episodePattern = new Regex(@"E\d{1,3}", RegexOptions.IgnoreCase);
public async Task<(List<string> seriesFiles, List<string> movieFiles)> SeparateVideosAsync(List<string> videoFiles)
{
int coreCount = Environment.ProcessorCount;
int totalFiles = videoFiles.Count;
int chunkSize = (int)Math.Ceiling((double)totalFiles / coreCount);
var seriesBag = new ConcurrentBag<string>();
var movieBag = new ConcurrentBag<string>();
var tasks = new List<Task>();
for (int i = 0; i < coreCount; i++)
{
int start = i * chunkSize;
int end = Math.Min(start + chunkSize, totalFiles);
tasks.Add(Task.Run(() =>
{
for (int j = start; j < end; j++)
{
string path = videoFiles[j];
string filename = Path.GetFileNameWithoutExtension(path);
if (filename == null)
continue;
if (episodePattern.IsMatch(filename))
seriesBag.Add(path);
else
movieBag.Add(path);
}
}));
}
await Task.WhenAll(tasks);
return (new List<string>(seriesBag), new List<string>(movieBag));
}
}

View File

@@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace file_finder__test
{
class Program
{
static async Task Main(string[] args)
{
// Step 1: Scan for files
var scanner = new FileScanner(new[] { ".mp3", ".mp4", ".wav", ".mkv" });
List<string> drives = await scanner.ScanAllDrivesAsync();
Console.WriteLine($"Found {drives.Count} drives. press matchig key to continue.");
foreach (var file in drives)
Console.WriteLine($"{file}:");
List<string> allFiles = await scanner.ScanDriveParallel(Console.ReadLine().ToUpper()+":/");
// Step 2: Classify the files
var musicExtensions = new List<string> { ".mp3", ".wav" };
var videoExtensions = new List<string> { ".mp4", ".mkv" };
var classifier = new FileClassifier();
var (musicFiles, videoFiles) = await classifier.ClassifyFilesAsync(allFiles, musicExtensions, videoExtensions);
Console.Clear();
// Step 3: Use the results (e.g. print)
//foreach (var music in musicFiles) Console.WriteLine(music);
//foreach (var video in videoFiles) Console.WriteLine(video);
Console.Clear();
// Step 4: Separate Series and Muvies
var separator = new VideoSeparator();
var (series, movies) = await separator.SeparateVideosAsync(videoFiles);
Console.WriteLine("Series:");
foreach (var s in series)
Console.WriteLine(s);
Console.WriteLine("\nMovies:");
foreach (var m in movies)
Console.WriteLine(m);
Console.WriteLine("\nMusic:");
foreach (var m in musicFiles)
Console.WriteLine(m);
}
}
}

View File

@@ -0,0 +1,23 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v8.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v8.0": {
"file finder test/1.0.0": {
"runtime": {
"file finder test.dll": {}
}
}
}
},
"libraries": {
"file finder test/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,12 @@
{
"runtimeOptions": {
"tfm": "net8.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "8.0.0"
},
"configProperties": {
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
}
}
}

View File

@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>file_finder__test</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v8.0", FrameworkDisplayName = ".NET 8.0")]

Binary file not shown.

View File

@@ -0,0 +1,22 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("file finder test")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("file finder test")]
[assembly: System.Reflection.AssemblyTitleAttribute("file finder test")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// Generated by the MSBuild WriteCodeFragment class.

View File

@@ -0,0 +1 @@
a8fa7ed7d042e7fb4f5d2918fa385e6ff28ee1e0399b3163d1f0d08015c36a87

View File

@@ -0,0 +1,13 @@
is_global = true
build_property.TargetFramework = net8.0
build_property.TargetPlatformMinVersion =
build_property.UsingMicrosoftNETSdkWeb =
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = file_finder__test
build_property.ProjectDir = C:\Users\Elias\Downloads\VPR_ShadowStream\VPR_ShadowStream\file finder test\
build_property.EnableComHosting =
build_property.EnableGeneratedComInterfaceComImportInterop =

View File

@@ -0,0 +1,8 @@
// <auto-generated/>
global using global::System;
global using global::System.Collections.Generic;
global using global::System.IO;
global using global::System.Linq;
global using global::System.Net.Http;
global using global::System.Threading;
global using global::System.Threading.Tasks;

View File

@@ -0,0 +1 @@
e71f97072287a58a080261ece6535e6469312148f17d38055a2d675a700c75f1

View File

@@ -0,0 +1,14 @@
C:\Users\bib\Desktop\lea\c# code\file finder test\file finder test\bin\Debug\net8.0\file finder test.exe
C:\Users\bib\Desktop\lea\c# code\file finder test\file finder test\bin\Debug\net8.0\file finder test.deps.json
C:\Users\bib\Desktop\lea\c# code\file finder test\file finder test\bin\Debug\net8.0\file finder test.runtimeconfig.json
C:\Users\bib\Desktop\lea\c# code\file finder test\file finder test\bin\Debug\net8.0\file finder test.dll
C:\Users\bib\Desktop\lea\c# code\file finder test\file finder test\bin\Debug\net8.0\file finder test.pdb
C:\Users\bib\Desktop\lea\c# code\file finder test\file finder test\obj\Debug\net8.0\file finder test.GeneratedMSBuildEditorConfig.editorconfig
C:\Users\bib\Desktop\lea\c# code\file finder test\file finder test\obj\Debug\net8.0\file finder test.AssemblyInfoInputs.cache
C:\Users\bib\Desktop\lea\c# code\file finder test\file finder test\obj\Debug\net8.0\file finder test.AssemblyInfo.cs
C:\Users\bib\Desktop\lea\c# code\file finder test\file finder test\obj\Debug\net8.0\file finder test.csproj.CoreCompileInputs.cache
C:\Users\bib\Desktop\lea\c# code\file finder test\file finder test\obj\Debug\net8.0\file finder test.dll
C:\Users\bib\Desktop\lea\c# code\file finder test\file finder test\obj\Debug\net8.0\refint\file finder test.dll
C:\Users\bib\Desktop\lea\c# code\file finder test\file finder test\obj\Debug\net8.0\file finder test.pdb
C:\Users\bib\Desktop\lea\c# code\file finder test\file finder test\obj\Debug\net8.0\file finder test.genruntimeconfig.cache
C:\Users\bib\Desktop\lea\c# code\file finder test\file finder test\obj\Debug\net8.0\ref\file finder test.dll

Binary file not shown.

View File

@@ -0,0 +1 @@
6115aa85531941d9ae58608c9a9d5580805abc134e78bf45e30ba2c148dd972c

Binary file not shown.

View File

@@ -0,0 +1,78 @@
{
"format": 1,
"restore": {
"C:\\Users\\Elias\\Downloads\\VPR_ShadowStream\\VPR_ShadowStream\\file finder test\\file finder test.csproj": {}
},
"projects": {
"C:\\Users\\Elias\\Downloads\\VPR_ShadowStream\\VPR_ShadowStream\\file finder test\\file finder test.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "C:\\Users\\Elias\\Downloads\\VPR_ShadowStream\\VPR_ShadowStream\\file finder test\\file finder test.csproj",
"projectName": "file finder test",
"projectPath": "C:\\Users\\Elias\\Downloads\\VPR_ShadowStream\\VPR_ShadowStream\\file finder test\\file finder test.csproj",
"packagesPath": "C:\\Users\\Elias\\.nuget\\packages\\",
"outputPath": "C:\\Users\\Elias\\Downloads\\VPR_ShadowStream\\VPR_ShadowStream\\file finder test\\obj\\",
"projectStyle": "PackageReference",
"fallbackFolders": [
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"
],
"configFilePaths": [
"C:\\Users\\Elias\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
"net8.0"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net8.0": {
"targetAlias": "net8.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
},
"restoreAuditProperties": {
"enableAudit": "true",
"auditLevel": "low",
"auditMode": "direct"
}
},
"frameworks": {
"net8.0": {
"targetAlias": "net8.0",
"dependencies": {
"Newtonsoft.Json": {
"target": "Package",
"version": "[13.0.1, )"
}
},
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Users\\Elias\\.dotnet\\sdk\\8.0.406/PortableRuntimeIdentifierGraph.json"
}
}
}
}
}

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\Elias\.nuget\packages\;C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.12.2</NuGetToolVersion>
</PropertyGroup>
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<SourceRoot Include="C:\Users\Elias\.nuget\packages\" />
<SourceRoot Include="C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages\" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" />

View File

@@ -0,0 +1,128 @@
{
"version": 3,
"targets": {
"net8.0": {
"Newtonsoft.Json/13.0.1": {
"type": "package",
"compile": {
"lib/netstandard2.0/Newtonsoft.Json.dll": {
"related": ".xml"
}
},
"runtime": {
"lib/netstandard2.0/Newtonsoft.Json.dll": {
"related": ".xml"
}
}
}
}
},
"libraries": {
"Newtonsoft.Json/13.0.1": {
"sha512": "ppPFpBcvxdsfUonNcvITKqLl3bqxWbDCZIzDWHzjpdAHRFfZe0Dw9HmA0+za13IdyrgJwpkDTDA9fHaxOrt20A==",
"type": "package",
"path": "newtonsoft.json/13.0.1",
"files": [
".nupkg.metadata",
".signature.p7s",
"LICENSE.md",
"lib/net20/Newtonsoft.Json.dll",
"lib/net20/Newtonsoft.Json.xml",
"lib/net35/Newtonsoft.Json.dll",
"lib/net35/Newtonsoft.Json.xml",
"lib/net40/Newtonsoft.Json.dll",
"lib/net40/Newtonsoft.Json.xml",
"lib/net45/Newtonsoft.Json.dll",
"lib/net45/Newtonsoft.Json.xml",
"lib/netstandard1.0/Newtonsoft.Json.dll",
"lib/netstandard1.0/Newtonsoft.Json.xml",
"lib/netstandard1.3/Newtonsoft.Json.dll",
"lib/netstandard1.3/Newtonsoft.Json.xml",
"lib/netstandard2.0/Newtonsoft.Json.dll",
"lib/netstandard2.0/Newtonsoft.Json.xml",
"newtonsoft.json.13.0.1.nupkg.sha512",
"newtonsoft.json.nuspec",
"packageIcon.png"
]
}
},
"projectFileDependencyGroups": {
"net8.0": [
"Newtonsoft.Json >= 13.0.1"
]
},
"packageFolders": {
"C:\\Users\\Elias\\.nuget\\packages\\": {},
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages": {}
},
"project": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "C:\\Users\\Elias\\Downloads\\VPR_ShadowStream\\VPR_ShadowStream\\file finder test\\file finder test.csproj",
"projectName": "file finder test",
"projectPath": "C:\\Users\\Elias\\Downloads\\VPR_ShadowStream\\VPR_ShadowStream\\file finder test\\file finder test.csproj",
"packagesPath": "C:\\Users\\Elias\\.nuget\\packages\\",
"outputPath": "C:\\Users\\Elias\\Downloads\\VPR_ShadowStream\\VPR_ShadowStream\\file finder test\\obj\\",
"projectStyle": "PackageReference",
"fallbackFolders": [
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"
],
"configFilePaths": [
"C:\\Users\\Elias\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
"net8.0"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net8.0": {
"targetAlias": "net8.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
},
"restoreAuditProperties": {
"enableAudit": "true",
"auditLevel": "low",
"auditMode": "direct"
}
},
"frameworks": {
"net8.0": {
"targetAlias": "net8.0",
"dependencies": {
"Newtonsoft.Json": {
"target": "Package",
"version": "[13.0.1, )"
}
},
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Users\\Elias\\.dotnet\\sdk\\8.0.406/PortableRuntimeIdentifierGraph.json"
}
}
}
}

View File

@@ -0,0 +1,10 @@
{
"version": 2,
"dgSpecHash": "prz0X75KDMs=",
"success": true,
"projectFilePath": "C:\\Users\\Elias\\Downloads\\VPR_ShadowStream\\VPR_ShadowStream\\file finder test\\file finder test.csproj",
"expectedPackageFiles": [
"C:\\Users\\Elias\\.nuget\\packages\\newtonsoft.json\\13.0.1\\newtonsoft.json.13.0.1.nupkg.sha512"
],
"logs": []
}

View File

@@ -0,0 +1 @@
"restore":{"projectUniqueName":"C:\\Users\\Elias\\Downloads\\VPR_ShadowStream\\VPR_ShadowStream\\file finder test\\file finder test.csproj","projectName":"file finder test","projectPath":"C:\\Users\\Elias\\Downloads\\VPR_ShadowStream\\VPR_ShadowStream\\file finder test\\file finder test.csproj","outputPath":"C:\\Users\\Elias\\Downloads\\VPR_ShadowStream\\VPR_ShadowStream\\file finder test\\obj\\","projectStyle":"PackageReference","fallbackFolders":["C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"],"originalTargetFrameworks":["net8.0"],"sources":{"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\":{},"https://api.nuget.org/v3/index.json":{}},"frameworks":{"net8.0":{"targetAlias":"net8.0","projectReferences":{}}},"warningProperties":{"warnAsError":["NU1605"]},"restoreAuditProperties":{"enableAudit":"true","auditLevel":"low","auditMode":"direct"}}"frameworks":{"net8.0":{"targetAlias":"net8.0","dependencies":{"Newtonsoft.Json":{"target":"Package","version":"[13.0.1, )"}},"imports":["net461","net462","net47","net471","net472","net48","net481"],"assetTargetFallback":true,"warn":true,"frameworkReferences":{"Microsoft.NETCore.App":{"privateAssets":"all"}},"runtimeIdentifierGraphPath":"C:\\Users\\Elias\\.dotnet\\sdk\\8.0.406/PortableRuntimeIdentifierGraph.json"}}

View File

@@ -0,0 +1 @@
17480215477067295

View File

@@ -0,0 +1 @@
17480215477067295