### GET /services/logger/records Source: https://context7.com/binsabry/mediahelper/llms.txt Retrieves all historical log entries to support resume functionality. ```APIDOC ## GET /services/logger/records ### Description Reads all log entries from previous sessions to support resume functionality. ### Method GET ### Endpoint /services/logger/records ### Response #### Success Response (200) - **records** (LogRecord[]) - List of historical log entries containing DateTime, Operation, Source, and Destination. ``` -------------------------------- ### GET /utils/date/extract Source: https://context7.com/binsabry/mediahelper/llms.txt Extracts potential date and time values from strings, typically used for parsing filenames. ```APIDOC ## GET /utils/date/extract ### Description Extracts date/time values from strings using multiple regex patterns. Commonly used to parse dates embedded in filenames. ### Method GET ### Endpoint /utils/date/extract ### Parameters #### Query Parameters - **input** (string) - Required - The string to parse for date patterns. ### Response #### Success Response (200) - **dates** (DateTime[]) - A list of parsed DateTime objects. ``` -------------------------------- ### Run Media Helper Core Service Source: https://context7.com/binsabry/mediahelper/llms.txt This C# code snippet demonstrates the main entry point for the Media Helper application. It utilizes dependency injection to set up services and then calls the 'RunAsync' method on the 'CoreService' to initiate the media organization process. ```csharp using Application.Services; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; // Bootstrap the application with dependency injection using (var service = GetService()) await service.RunAsync(); static T GetService() => Host.CreateDefaultBuilder() .ConfigureAppConfiguration(config => config.Sources.Clear()) .ConfigureServices(services => { services.AddSettings() .AddApplication() .AddInfrastructure() .AddPresentation(); }) .Build() .Services .GetRequiredService(); ``` -------------------------------- ### Configure AppSettings.json for Media Helper Source: https://context7.com/binsabry/mediahelper/llms.txt This JSON configuration file defines the runtime behavior of the Media Helper tool. It specifies the number of parallel tasks, logging and resume options, target directory for organized files, source locations to scan, and patterns to ignore during processing. ```json { "TasksCount": 2, "EnableLogAndResume": true, "AttemptToFixIncorrectOffsets": true, "ClearBackupFilesOnComplete": true, "DeleteEmptyDirectoriesOnComplete": true, "AutoFixArabicNumbersInFileName": true, "Target": "\\SynologyNAS\home\Photos\PhotoLibrary", "Sources": [ "\\SynologyNAS\home\Google-Takeout.zip", "\\SynologyNAS\home\Photos\MobileBackup", "D:\\Data\\Media\\Photos\\Personal\\Family", "\\SynologyNAS\home\GraduationPhoto.jpg", "\\SynologyNAS\home\GraduationVideo.mp4" ], "Ignores": [ "PersonalVideos", ".avi", ".m4a" ] } ``` -------------------------------- ### Define Source Directories for Media Helper Source: https://context7.com/binsabry/mediahelper/llms.txt This JSON configuration defines the 'Sources' array, which lists all the locations to scan for media files. It supports various inputs including local directories, network paths, individual files, and ZIP archives. ```json { "Sources": [ "C:\\Users\\Photos", "\\NAS\backup\takeout.zip", "D:\\Media\\vacation.jpg" ] } ``` -------------------------------- ### Enable Logging and Resume in Media Helper Source: https://context7.com/binsabry/mediahelper/llms.txt This JSON configuration enables the 'EnableLogAndResume' feature, which creates CSV log files in the '.temp/logs' directory. This allows the application to resume processing from where it was interrupted. ```json { "EnableLogAndResume": true } ``` -------------------------------- ### Set Target Directory for Media Helper Source: https://context7.com/binsabry/mediahelper/llms.txt This JSON configuration specifies the 'Target' directory where organized media files will be copied. The files will be automatically placed into subdirectories based on their year and month of creation. ```json { "Target": "\\NASServer\Photos\Library" } ``` -------------------------------- ### Read and Write EXIF Metadata with IExifService Source: https://context7.com/binsabry/mediahelper/llms.txt Provides methods to read metadata from files or JSON companions and write metadata tags back to media files using ExifTool. ```csharp using Application.Infrastructure.Services; IExifService exifService = GetService(); Dictionary metadata = exifService.ReadMetadata(@"D:\Photos\vacation.jpg"); Dictionary jsonMeta = exifService.ReadJsonMetadata(@"D:\Photos\vacation.jpg.json"); var tags = new Dictionary { { "DateTimeOriginal", "2023:06:15 14:25:30" } }; bool success = exifService.TryWriteMetadata(@"D:\Photos\vacation.jpg", tags); ``` -------------------------------- ### Manage Local Media Files with MediaFile Source: https://context7.com/binsabry/mediahelper/llms.txt Represents a media file on the local filesystem. It provides access to the file itself and any associated Google Takeout JSON metadata files. ```csharp using Domain.Models; var fileInfo = new FileInfo(@"D:\Photos\IMG_20230615_142530.jpg"); var mediaFile = new MediaFile(fileInfo); string sourcePath = mediaFile.OriginalSource; FileInfo file = mediaFile.GetFile(); FileInfo jsonFile = mediaFile.GetJsonFile(); mediaFile.Dispose(); ``` -------------------------------- ### Accessing ISettings Properties in C# Source: https://context7.com/binsabry/mediahelper/llms.txt Demonstrates how to access various configuration and computed path settings from the ISettings interface in C#. These settings control core processing, define source and destination paths, and provide read-only access to application-specific directories. ```csharp using Domain.Interfaces; ISettings settings = GetService(); // Core processing settings int threads = settings.TasksCount; // Number of parallel tasks bool resume = settings.EnableLogAndResume; // Enable resume from logs bool fixOffsets = settings.AttemptToFixIncorrectOffsets; // Fix metadata issues bool clearBackups = settings.ClearBackupFilesOnComplete; // Remove temp files bool deleteEmpty = settings.DeleteEmptyDirectoriesOnComplete; // Clean empty dirs bool fixArabic = settings.AutoFixArabicNumbersInFileName; // Convert Arabic numerals // Path settings string target = settings.Target; // Destination library path string[] sources = settings.Sources; // Source paths to scan string[] ignores = settings.Ignores; // Keywords to ignore // Computed paths (read-only) string root = settings.RootDirectory; // Application root string tools = settings.ToolsDirectory; // ExifTool location string tempRoot = settings.ParentTempDirectory; // .temp directory string logPath = settings.TempLogPath; // .temp/logs string exifTemp = settings.TempExifPath; // .temp/.exif string zipTemp = settings.TempZipPath; // .temp/.zip ``` -------------------------------- ### Configure Offset Fixing in Media Helper Source: https://context7.com/binsabry/mediahelper/llms.txt This JSON snippet demonstrates how to enable 'AttemptToFixIncorrectOffsets'. When true, the tool automatically corrects media files that have incorrect metadata offsets or duplicate EXIF entries. ```json { "AttemptToFixIncorrectOffsets": true } ``` -------------------------------- ### Configure TasksCount for Media Helper Source: https://context7.com/binsabry/mediahelper/llms.txt This JSON snippet shows how to configure the 'TasksCount' setting, which determines the number of parallel threads used for media processing. It's recommended to set this to 2, or match your CPU core count for optimal performance. ```json { "TasksCount": 4 } ``` -------------------------------- ### Update EXIF Creation Date Tags Source: https://context7.com/binsabry/mediahelper/llms.txt Analyzes various date sources including EXIF tags and filename patterns to identify the earliest valid creation date. Updates the provided dictionary with this minimum value to ensure data integrity. ```csharp using Application.Infrastructure.Services; IExifCoreService exifCoreService = GetService(); var tags = new Dictionary { { "DateTimeOriginal", "2023:06:20 10:00:00" }, { "CreateDate", "2023:06:15 14:25:30" } }; DateTime[] filenameDates = new[] { new DateTime(2023, 6, 10, 12, 0, 0) }; bool updated = exifCoreService.TryUpdateCreationDateTagsWithMinAcceptableValue( ref tags, filenameDates, out DateTime minDate ); ``` -------------------------------- ### POST /services/exif/update-creation-date Source: https://context7.com/binsabry/mediahelper/llms.txt Analyzes multiple date sources including EXIF tags and filenames to identify and update the earliest valid creation date. ```APIDOC ## POST /services/exif/update-creation-date ### Description Analyzes all date sources (EXIF tags, JSON metadata, filename patterns) and updates tags with the earliest valid date. This ensures the oldest/original creation date is preserved. ### Method POST ### Endpoint /services/exif/update-creation-date ### Parameters #### Request Body - **tags** (Dictionary) - Required - A dictionary of existing EXIF tags. - **filenameDates** (DateTime[]) - Required - Array of dates extracted from the file name. ### Response #### Success Response (200) - **updated** (bool) - Indicates if the tags were modified. - **minDate** (DateTime) - The earliest date identified. ``` -------------------------------- ### Validate Media File Types with MediaHelper Source: https://context7.com/binsabry/mediahelper/llms.txt Checks if a file is a supported media type based on its extension. It supports various image, audio, and video formats by providing either a FileInfo object or a filename string. ```csharp using Application.Helpers; var file = new FileInfo(@"C:\Photos\vacation.jpg"); bool isSupported = MediaHelper.IsSupportedMediaFile(file); bool isVideo = MediaHelper.IsSupportedMediaFile("birthday_party.mp4"); bool isDocument = MediaHelper.IsSupportedMediaFile("document.pdf"); ``` -------------------------------- ### Configure Ignore Patterns for Media Helper Source: https://context7.com/binsabry/mediahelper/llms.txt This JSON snippet shows the 'Ignores' array, used to specify patterns for files or directories that should be excluded from processing. This can include keywords, file extensions, or path segments. ```json { "Ignores": [ "Thumbnails", ".tmp", "Screenshots", ".gif" ] } ``` -------------------------------- ### Convert Unix and Java Timestamps Source: https://context7.com/binsabry/mediahelper/llms.txt Utility methods to convert Unix (seconds) or Java/JavaScript (milliseconds) epoch timestamps into standard DateTime objects. Includes safe parsing alternatives. ```csharp using Shared.Helpers; double unixTimestamp = 1686840330; DateTime dateTime = DateHelper.ParseDateTimeFromUnixTimeStamp(unixTimestamp); double javaTimestamp = 1686840330000; DateTime javaDateTime = DateHelper.ParseDateTimeFromJavaTimeStamp(javaTimestamp); ``` -------------------------------- ### POST /services/logger/log Source: https://context7.com/binsabry/mediahelper/llms.txt Logs file operations to persistent storage for audit tracking and resume capability. ```APIDOC ## POST /services/logger/log ### Description Logs file operations to CSV files for resume capability and audit tracking. ### Method POST ### Endpoint /services/logger/log ### Parameters #### Request Body - **operation** (LogOperation) - Required - The type of operation (Copy, Duplicate, Update, Fail, NoDate). - **source** (string) - Required - The source file path. - **destination** (string) - Optional - The destination file path. ``` -------------------------------- ### Log File Operations Source: https://context7.com/binsabry/mediahelper/llms.txt Provides methods to log file operations like copies, duplicates, and metadata updates to CSV files. Supports colored console output for status updates. ```csharp using Application.Infrastructure.Services; using Domain.Enums; ILoggerService logger = GetService(); logger.Log(LogOperation.Copy, @"D:\Source\photo.jpg", @"E:\Library\2023\06\photo.jpg"); logger.LogInformation("Processing files..."); logger.LogSuccess("File copied successfully"); ``` -------------------------------- ### Process Archived Media Files with ArchivedMediaFile Source: https://context7.com/binsabry/mediahelper/llms.txt Handles media files stored within ZIP archives. It automatically extracts files to a temporary directory for processing and ensures cleanup upon disposal. ```csharp using Domain.Models; using Domain.Interfaces; using System.IO.Compression; var archive = new FileInfo(@"D:\Backups\takeout.zip"); ISettings settings = GetSettings(); using (var zip = ZipFile.OpenRead(archive.FullName)) { var entry = zip.GetEntry("Photos/2023/06/IMG_20230615.jpg"); using (var archivedMedia = new ArchivedMediaFile(entry, archive, settings)) { string source = archivedMedia.OriginalSource; FileInfo extractedFile = archivedMedia.GetFile(); FileInfo jsonFile = archivedMedia.GetJsonFile(); } } ``` -------------------------------- ### Extract DateTimes from Filenames Source: https://context7.com/binsabry/mediahelper/llms.txt Uses regex patterns to extract potential date/time information from string inputs, such as filenames. Supports multiple common date formats including those with timezones. ```csharp using Shared.Helpers; DateTime[] dates1 = DateHelper.ExtractPossibleDateTimes("IMG_20230615_142530.jpg"); DateTime[] dates2 = DateHelper.ExtractPossibleDateTimes("20230615142530.jpg"); DateTime[] dates3 = DateHelper.ExtractPossibleDateTimes("vacation_20230615.jpg"); ``` -------------------------------- ### Read and Filter Log Records Source: https://context7.com/binsabry/mediahelper/llms.txt Retrieves all historical log entries to support resume functionality. Useful for filtering previously processed files to avoid redundant operations. ```csharp using Application.Infrastructure.Services; using Domain.DTO; ILoggerService logger = GetService(); LogRecord[] records = logger.ReadAllLogs(); var processedFiles = records .Where(r => r.Operation == LogOperation.Copy || r.Operation == LogOperation.Duplicate) .Select(r => r.Source.ToLower()) .ToHashSet(); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.