mirror of
https://github.com/nwithan8/plex-prerolls
synced 2024-08-30 16:52:17 +00:00
5bf153e92f
- Advanced options: Use glob patterns to match local files, translate to remote paths - Add optional file path to Unraid template
33 lines
1014 B
Python
33 lines
1014 B
Python
import glob
|
|
import os
|
|
from typing import List
|
|
|
|
|
|
def get_all_files_matching_glob_pattern(directory: str, pattern: str) -> List[str]:
|
|
"""
|
|
Get all files matching a glob pattern in a directory.
|
|
|
|
Args:
|
|
directory (str): The directory to search in.
|
|
pattern (str): The glob pattern to search for.
|
|
|
|
Returns:
|
|
List[str]: A list of file paths that match the glob pattern.
|
|
"""
|
|
return [file for file in glob.glob(os.path.join(directory, pattern)) if os.path.isfile(file)]
|
|
|
|
|
|
def translate_local_path_to_remote_path(local_path: str, local_root_folder: str, remote_root_folder: str) -> str:
|
|
"""
|
|
Translate a local path to a remote path.
|
|
|
|
Args:
|
|
local_path (str): The local path to translate.
|
|
local_root_folder (str): The root folder of the local path.
|
|
remote_root_folder (str): The root folder of the remote path.
|
|
|
|
Returns:
|
|
str: The translated remote path.
|
|
"""
|
|
return local_path.replace(local_root_folder, remote_root_folder, 1)
|