media#
- mediautils.media.process_directory_files(in_dir: str | PathLike = 'in', out_dir: str | PathLike = 'out') list[Path][source]#
Process files organized in date-named subdirectories.
Each subdirectory of in_dir must have a name starting with
YYYYMMDD. Files inside each subdirectory are assigned timestamps near end of day (incrementing by one second per file), renamed toYYYYMMDD_HHMMSS_originalname, and written to out_dir with updated metadata.- Parameters:
in_dir (str | os.PathLike) – Directory containing date-named subdirectories.
out_dir (str | os.PathLike) – Directory where processed files are saved.
- Returns:
Paths to the output files.
- Return type:
list[Path]
- mediautils.media.process_standard_files(in_dir: str | PathLike = 'in', out_dir: str | PathLike = 'out') list[Path][source]#
Process files with standardized names: set timestamps from file names.
For each file in in_dir whose name starts with
YYYYMMDD_HHMMSS, writes a copy to out_dir with metadata matching the datetime encoded in the file name.- Parameters:
in_dir (str | os.PathLike) – Directory containing media files with standardized names.
out_dir (str | os.PathLike) – Directory where processed files are saved.
- Returns:
Paths to the output files.
- Return type:
list[Path]
- mediautils.media.process_wa_files(in_dir: str | PathLike = 'in', out_dir: str | PathLike = 'out') list[Path][source]#
Process WhatsApp media files: set timestamps and rename.
For each file in in_dir, extracts the date from the WhatsApp file name, assigns a time near end of day (incrementing by one second per file within the same date), renames to
YYYYMMDD_HHMMSS_originalname, and writes the result to out_dir with updated metadata.- Parameters:
in_dir (str | os.PathLike) – Directory containing WhatsApp media files.
out_dir (str | os.PathLike) – Directory where processed files are saved.
- Returns:
Paths to the output files.
- Return type:
list[Path]
- mediautils.media.set_time(path: str | PathLike, dt: datetime, out_dir: str | PathLike = 'out', out_name: str | None = None) Path[source]#
Write a copy of an image or video with its timestamps set to dt.
Dispatches to
set_time_image()orset_time_video()based on the file extension.- Parameters:
path (str | os.PathLike) – Path to the source file.
dt (datetime) – The datetime to write into the metadata.
out_dir (str | os.PathLike) – Directory where the modified copy is saved. Created if it does not exist.
out_name (str | None) – Output file name. If
None, the original file name is kept.
- Returns:
Path to the output file.
- Return type:
Path
- Raises:
ValueError – If the file extension is not supported.