video_utils.plex package
Submodules
video_utils.plex.dvr_converter module
Converter for Plex DVR recordings
Defines a class for re-encoding Plex DVR recordings so that they are not as large as MPEG-TS files are not very efficient.
- class video_utils.plex.dvr_converter.DVRconverter(logdir: str | None = None, lang: str | list[str] | None = None, destructive: bool = False, no_remove: bool = False, no_srt: bool = False, **kwargs)
Bases:
VideoConverterCombines VideoConverter and ComRemove
Used for post-processing Plex DVR recordings
- convert(infile: str, section: str = 'TV Shows') tuple
Method to actually post process Plex DVR files.
- This method does a few things:
Renames file to match convenction set by video_utils package
Attempts to remove commercials using comskip
Transcodes to h264
- Parameters:
infile (str) – Path to file to process
- Keyword Arguments:
section (str) – Name of Plex Media Server Library file is part of
- Returns:
Returns success of transocde
- Return type:
int
video_utils.plex.plex_media_scanner module
Wrapper utils for calling Plex media scanner
- video_utils.plex.plex_media_scanner.plex_media_scanner(section_name: str, path: str | None = None) bool
A python function that scans library through API call
- Parameters:
section_name (str) – Name of the library section to scan
- Keyword Arguments:
path (str) – Path to scan for new files use to only scan part of section
- Returns:
True if success, False otherwise
- Return type:
bool
video_utils.plex.utils module
Utilties for interfacing with Plex
While this package does very minimal direct interfacing with Plex, these utilites support functionality in other parts of this package.
- class video_utils.plex.utils.DVRqueue(file)
Bases:
listSub-class of list that writes list to pickled file on changes
This class acts to backup a list to file on disc so that DVR can remember where it was in the event of a restart/power off. Whenever the list is modified via the append, remove, etc methods, data are written to disc.
- append(val)
Append object to the end of the list.
- pop(val)
Remove and return item at index (default last).
Raises IndexError if list is empty or index is out of range.
- remove(val)
Remove first occurrence of value.
Raises ValueError if the value is not present.
- video_utils.plex.utils.get_dvr_section_dir(path: str) str
Extract the section directory from DVR grab path
Given path to a DVR recorinding source file (i.e., the file created in the .grab directory), determine the name of the directory for the directory one level up from .grab. The name of this directory is assumed to match the name of the library section in plex.
- Parameters:
path (str) – Path to DVR file in .grab directory
- Returns:
Name directory one level above .grab in the DVR path.
- Return type:
str
- video_utils.plex.utils.get_token(login: bool = False) dict | None
Use plexapi to get token for server
- Keyword Arguments:
login (bool) – Authenticate to Plex and get token. If False (default), then just try to load existing token.
- Returns:
If login/load success, then dict, else is None
- video_utils.plex.utils.get_token_cli() None
Entry point for plexToken CLI
- video_utils.plex.utils.plex_dvr_rename(in_file: str, hardlink: bool = True) tuple
Function to rename Plex DVR files to match file nameing convetion.
- Parameters:
in_file (str) – Full path to the file to rename
- Keyword Arguments:
hardlink (bool) – if set to True, will rename input file, else creates hard link to file. Default is to hard link
- Returns:
Returns path to renamed file and tuple with parsed file information
- video_utils.plex.utils.plex_file_info(in_file: str) tuple
Extract info from file path
Extracts series, season/episode, and episode title information from a Plex DVR file path
- Parameters:
in_file (str) – Full path to the file to rename
- Keyword Arguments:
None. –
- Returns:
- series name, season/episode or date, episode title,
and file extension
- Return type:
tuple