Guardian Package API
This section contains the complete API reference for the Guardian package.
Core Module
Core functionality for the Guardian media censoring system.
- class guardian.core.SegmentDiagnostic(segment_id, start_time, end_time, duration, target_rms_db, actual_rms_db, meets_threshold, strategy_used, strategy_name, filter_applied)[source]
Bases:
objectDiagnostic information for a single censored segment.
- __init__(segment_id, start_time, end_time, duration, target_rms_db, actual_rms_db, meets_threshold, strategy_used, strategy_name, filter_applied)
- class guardian.core.CensoringDiagnostic(timestamp, input_video, output_video, total_segments, total_censored_duration, successful_segments, failed_segments, final_strategy_used, fallback_attempts, overall_success, segments, error_messages, recommendations)[source]
Bases:
objectComplete diagnostic report for a censoring operation.
- segments: List[SegmentDiagnostic]
- __init__(timestamp, input_video, output_video, total_segments, total_censored_duration, successful_segments, failed_segments, final_strategy_used, fallback_attempts, overall_success, segments, error_messages, recommendations)
- class guardian.core.GuardianProcessor(matching_words=None, ffmpeg_cmd=None, ffprobe_cmd=None)[source]
Bases:
objectMain processor class for censoring profane content in video files.
- DEFAULT_MATCHING_WORDS = ['fucking', 'fuck', 'shit', 'damn', 'hell', 'ass', 'bitch', 'bastard', 'bullshit', 'fucker', 'fucked', 'asshole', 'piss', 'jesus christ', 'jesus', 'sex', 'pussy', 'son of a bitch', 'sonofabitch', 'jackass', 'smartass', 'tits', 'whore', 'cunt', 'slut', 'boobs', 'orgasm', 'penis', 'blowjob', 'handjob', 'hard on', 'cocksucker', 'dipshit', 'horseshit', 'jack off', 'nympho', 'rape', 'fuckface', 'skank', 'shitspray', 'bitches', 'nigga', 'nigger', 'dickhead', 'prick', 'arsehole', 'motherfucker', 'goddamn', 'shithead', 'douchebag', 'fag', 'faggot']
- __init__(matching_words=None, ffmpeg_cmd=None, ffprobe_cmd=None)[source]
Initialize the GuardianProcessor. :type matching_words:
Optional[List[str]] :param matching_words: Custom list of words to censor. Uses default if None. :type ffmpeg_cmd:Optional[str] :param ffmpeg_cmd: Path to ffmpeg executable. :param Defaults to checking local ‘bin’ dir.: :type ffprobe_cmd:Optional[str] :param ffprobe_cmd: Path to ffprobe executable. :param Defaults to checking local ‘bin’ dir.:
- extract_embedded_srt(video_path, output_srt_path)[source]
Extracts the first embedded SRT subtitle track from a video file, prioritizing default tracks.
- censor_audio_with_ffmpeg(video_path, output_path=None, full=False)[source]
Censors profane audio segments in a video file using FFmpeg. :type video_path:
str:param video_path: Path to the input video file. :type output_path:Optional[str] :param output_path: Optional custom output path. If None, generates :param default name.:
CLI Module
Command-line interface for the Guardian media censoring system.
- guardian.cli.setup_logging(log_file=None, verbose=False)[source]
Configure logging for the application.
- guardian.cli.expand_input_paths(input_paths)[source]
Expand input paths to include video files from directories.
If an input path is a directory, discover all video files in that directory. If an input path is a file, include it as-is.
Package Module
Dialogue Guardian: Universal Media Censor
A Python package for automatically detecting and censoring profane language in video files by processing SRT subtitle files.
- class guardian.GuardianProcessor(matching_words=None, ffmpeg_cmd=None, ffprobe_cmd=None)[source]
Bases:
objectMain processor class for censoring profane content in video files.
- DEFAULT_MATCHING_WORDS = ['fucking', 'fuck', 'shit', 'damn', 'hell', 'ass', 'bitch', 'bastard', 'bullshit', 'fucker', 'fucked', 'asshole', 'piss', 'jesus christ', 'jesus', 'sex', 'pussy', 'son of a bitch', 'sonofabitch', 'jackass', 'smartass', 'tits', 'whore', 'cunt', 'slut', 'boobs', 'orgasm', 'penis', 'blowjob', 'handjob', 'hard on', 'cocksucker', 'dipshit', 'horseshit', 'jack off', 'nympho', 'rape', 'fuckface', 'skank', 'shitspray', 'bitches', 'nigga', 'nigger', 'dickhead', 'prick', 'arsehole', 'motherfucker', 'goddamn', 'shithead', 'douchebag', 'fag', 'faggot']
- __init__(matching_words=None, ffmpeg_cmd=None, ffprobe_cmd=None)[source]
Initialize the GuardianProcessor. :type matching_words:
Optional[List[str]] :param matching_words: Custom list of words to censor. Uses default if None. :type ffmpeg_cmd:Optional[str] :param ffmpeg_cmd: Path to ffmpeg executable. :param Defaults to checking local ‘bin’ dir.: :type ffprobe_cmd:Optional[str] :param ffprobe_cmd: Path to ffprobe executable. :param Defaults to checking local ‘bin’ dir.:
- extract_embedded_srt(video_path, output_srt_path)[source]
Extracts the first embedded SRT subtitle track from a video file, prioritizing default tracks.
- censor_audio_with_ffmpeg(video_path, output_path=None, full=False)[source]
Censors profane audio segments in a video file using FFmpeg. :type video_path:
str:param video_path: Path to the input video file. :type output_path:Optional[str] :param output_path: Optional custom output path. If None, generates :param default name.: