auto_everything


Terminal

class auto_everything.terminal.Terminal(debug: bool = False)[source]

Terminal simulator for execute bash commands

exists(path: str) → bool[source]

cheack if a file or directory exists return true is it exists

Parameters:path (string) – the path you want to have a check
run(c: str, cwd: str = None, wait: bool = True)[source]

run shell commands without value returning

Parameters:
  • c (string) – shell command
  • cwd (string) – current working directory
  • wait (bool) – True, this command may keep running forever
run_command(c: str, timeout: int = 15, cwd: str = None) → str[source]

run shell commands with return value

Parameters:
  • c (string) – shell command
  • timeout (int, seconds) – how long this command will take, beyound it, an exception will raise
  • cwd (string) – current working directory
run_program(name: str, cwd: str = None)[source]

run shell commands, especially programs which can be started from terminal. This function will not wait program to be finished.

Parameters:
  • name (string) –
    for example:
    firefox or /opt/v2ray/v2ray
  • cwd (string) – current working directory
run_py(file_path_with_command: str, cwd: str = None, wait: bool = False)[source]

run py_file

Parameters:
  • file_path_with_command (string) –
    for example:
    hi.py –name yingshaoxo
  • cwd (string) – current working directory
  • wait (bool) – if true, it will wait until the python program quit
run_sh(file_path_with_command: str, cwd: str = None, wait: bool = False)[source]

run sh_file

Parameters:
  • file_path_with_command (string) –
    for example:
    hi.sh –name yingshaoxo
  • cwd (string) – current working directory
  • wait (bool) – if true, it will wait until the bash program quit
is_running(name: str) → bool[source]

cheack if a program is running

Parameters:name (string) – the program name, for example, firefox
kill(name: str, force: bool = True, wait: bool = False, timeout: int = 30)[source]

kill a program by its name, depends on kill pid

Parameters:
  • name (string) – what’s the name of that program you want to kill
  • force (bool) – kill it directlly or softly. some program like ffmpeg, should set force=False
  • wait (bool) – true, wait until program totolly quit

Disk

class auto_everything.disk.Disk[source]

Some useful functions to handle your disk

exists(path: str) → bool[source]

Check if a file or folder exist.

Parameters:path (string) – the file path
get_files(folder: str, recursive: bool = True, type_limiter: List[str] = None) → List[str][source]

Get files recursively under a folder.

Parameters:
  • folder (string) –
  • recursive (bool) –
  • type_limiter (List[str]) – a list used to do a type filter, like [“.mp3”, “.epub”]
get_hash_of_a_file(path: str) → str[source]

calculate the blake2s hash string based on the bytes of a file.

Parameters:path (string) – the file path
get_hash_of_a_path(path: str) → str[source]

calculate the blake2s hash string based on path name.

Parameters:path (string) – actually it can be any string
get_safe_name(filename: str, replace_chars=' ') → str[source]

get a valid file name by doing a replacement. (English only)

Parameters:
  • filename (string) – the unsafe filename
  • replace_chars (string) – chars in replace_chars will be replaced by ‘_’.
get_file_size(path: str, level: str = 'B') → int[source]

Get file size in the unit of B, KB, MB.

Parameters:
  • path (string) – the file path
  • level (string) – B, KB, or MB
uncompress(path: str, folder: str = None) → bool[source]

uncompress a file.

Parameters:
  • path (string) – the compressed file path
  • folder (string) – where you want to put the uncompressed files into
compress(paths: List[str], target: str)[source]

compress a files to a target.

Parameters:
  • paths (string of list) –
  • target (string) – the compressed output file path

Store

class auto_everything.disk.Store(store_name: str, save_to_folder: str = None)[source]

A key-value store.

get_items()[source]

get all key and value tuple in the store

has_key(key) → bool[source]

check if a key exist in the store

Parameters:key (string) –
get(key, default_value)[source]

get a value by using a key

Parameters:
  • key (string) –
  • default_value (string or an object that jsonable) –
set(key, value)[source]

set a value by using a key

Parameters:
  • key (string) –
  • value (string or an object that jsonable) –
reset()[source]

empty the store

Network

class auto_everything.network.Network[source]

I use this module to handle network stuff.

download(url: str, target: str, size: str = '0B') → bool[source]

Download a file from internet.

Parameters:
  • url (string) – the download link of a file
  • target (string) – the local disk file path where the file would be saved to
  • size (string) – do a simple check for the file. like ‘12KB’ or ‘20MB’
Returns:

return false if the specified size less than the file we downloaded

Return type:

bool

GUI

class auto_everything.gui.GUI(project_name='', time_takes_for_one_click=0.2, grayscale=False)[source]

A wrapper for pyautogui.

exists(element_name, confidence=0.9)[source]

Check if an image exists at the screen

Parameters:element_name (string) – image name (those pictures you put into data folder)
click(element_name=None, game=False)[source]

click an image at the screen

Parameters:
  • element_name (string) – image name (those pictures you put into data folder)
  • game (bool) – for games, we click it in a different way

AndroidGUI

class auto_everything.gui.AndroidGUI(scrcpy_window_name, project_name='')[source]

To interact with scrcpy by x11 and OpenCV.

capture_screen()[source]

Get opencv image.

find_all(element_name, from_image=None, threshold=0.8, visual=False)[source]

find all images at the screen

Parameters:
  • element_name (string) – name for the sub image
  • from_image (opencv image) –
click(point, landscape=True)[source]

do a click at android screen by using adb

Parameters:point ({"x": 1920, "y": 1080}) – it’s actually the result you get from function find_all().

Video

class auto_everything.video.Video[source]

This is a powerful video module

It’s based on: 1. ubuntu core 2. librosa 3. ffmpeg 4. moviepy

concatenate videos one by one

Parameters:
  • source_video_path_list (list of video path) – those videos you want to concatenate
  • target_video_path (string) – where to save the concatenated video
  • method (int) – 1 to use ffmpeg(low quality), 2 to use moviepy(high quality)
combine_all_mp4_in_a_folder(source_folder, target_video_path, sort_by_time=True, method=1)[source]

concatenate all videos in a folder

Parameters:
  • sort_by_time (bool) – when true, we sort by time when false, we sort by name(1, 2, 3)
  • method (int) – 1 to use ffmpeg(low quality), 2 to use moviepy(high quality)
remove_noise_from_video(source_video_path, target_video_path, degree=0.21, noise_capture_length=None)[source]

Just as said, remove noise from video

remove_silence_parts_from_video(source_video_path, target_video_path, db_for_split_silence_and_voice, minimum_interval_time_in_seconds=None, voice_only=False, skip_sharp_noise=False)[source]
Parameters:
  • source_video_path (string) –
  • target_video_path (string) –
  • db_for_split_silence_and_voice (int) – normoly, it’s 20 or 25, but for some case if the volume is too small, 30 would be fine
  • minimum_interval_time_in_seconds (float) – longer than this value, we will take it as silence and remove it
  • voice_only (bool) – if true, it only returns the path of silence removed mp3 file
humanly_remove_silence_parts_from_video(source_video_path, target_video_path, db_for_split_silence_and_voice, minimum_interval=1)[source]

No difference with the last one, but in this function, you can check how many silence you can get rid of. Then you make the decision wheather you want to do this or not

Parameters:
  • source_video_path (string) –
  • target_video_path (string) –
  • db_for_split_silence_and_voice (int) – normoly, it’s 20 or 25
  • minimum_interval_time_in_seconds (float) – longer than this value, we will take it as silence and remove it
speedup_video(source_video_path, target_video_path, speed=1.5)[source]
Parameters:
  • source_video_path (string) –
  • target_video_path (string) –
  • speed (float) – how quick you want the video to be
speedup_silence_parts_in_video(source_video_path, target_video_path, db_for_split_silence_and_voice, speed=4)[source]

Instead remove silence, we can speed up the silence parts in a video

Parameters:
  • source_video_path (string) –
  • target_video_path (string) –
  • db_for_split_silence_and_voice (int) – normoly, it’s 20 or 25
  • speed (float) – how quick you want the silence parts to be
replace_video_with_a_picture(source_video_path, target_video_path, picture)[source]
Parameters:
  • source_video_path (string) –
  • target_video_path (string) –
  • picture (string) – the path of that picture
increase_audio_volume_in_video(source_video_path, target_video_path, times)[source]
Parameters:
  • source_video_path (string) –
  • target_video_path (string) –
  • times (float) – 2 times the source_video volume or 3 times the source_video volume

DeepVideo

class auto_everything.video.DeepVideo[source]

For this one, I’ll use deep learning.

It’s based on: 1. ubuntu core 2. vosk 3. ffmpeg 4. moviepy 5. librosa 6. pornstar

remove_silence_parts_from_videos_in_a_folder(source_folder: str, target_video_path: str, minimum_interval_time_in_seconds: float = 1.0, fps: int = None, resolution: Tuple[int, int] = None, preset: str = 'placebo')[source]

We will first concatenate the files under the source_folder into a video by created_time, then we remove those silence parts in that videoig

Parameters:
  • source_folder (string) –
  • target_video_path (string) –
  • minimum_interval_time_in_seconds (float) – longer than this value, we will take it as silence and remove it
  • fps (int) –
  • target_resolution (Tuple(int, int)) – Set to (desired_width, desired_height) to have ffmpeg resize the frames. Choices are: (1920, 1080), (1280, 720), (640, 480) and so on.
  • preset (string) – Sets the time that FFMPEG will spend optimizing the compression. Choices are: ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow, placebo. Note that this does not impact the quality of the video, only the size of the video file.
speed_up_silence_parts_from_videos_in_a_folder(source_folder: str, target_video_path: str, speed: int = 4, minimum_interval_time_in_seconds: float = 1.0, fps: int = None, resolution: Tuple[int, int] = None, preset: str = 'placebo')[source]

We will first concatenate the files under the source_folder into a video by created_time, then we speed up those silence parts in that videoig

Parameters:
  • source_folder (string) –
  • target_video_path (string) –
  • speed (float) – how quick you want the silence parts to be
  • minimum_interval_time_in_seconds (float) – longer than this value, we will take it as silence and remove it
  • fps (int) –
  • target_resolution (Tuple(int, int)) – Set to (desired_width, desired_height) to have ffmpeg resize the frames. Choices are: (1920, 1080), (1280, 720), (640, 480) and so on.
  • preset (string) – Sets the time that FFMPEG will spend optimizing the compression. Choices are: ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow, placebo. Note that this does not impact the quality of the video, only the size of the video file.
remove_silence_parts_from_video(source_video_path: str, target_video_path: str, minimum_interval_time_in_seconds: float = 1.0)[source]
Parameters:
  • source_video_path (string) –
  • target_video_path (string) –
  • minimum_interval_time_in_seconds (float) – longer than this value, we will take it as silence and remove it
speedup_silence_parts_in_video(source_video_path: str, target_video_path: str, speed: int = 4, minimum_interval_time_in_seconds: float = 1.0, fps: int = None, resolution: Tuple[int, int] = None, preset: str = 'placebo')[source]

Instead remove silence, we can speed up the silence parts in a video

Parameters:
  • source_video_path (string) –
  • target_video_path (string) –
  • speed (float) – how quick you want the silence parts to be

FakeCamera

class auto_everything.camera.FakeCamera(device: str = None, width: int = 640, height: int = 480)[source]

This module based on pyfakewebcam.

next(frame, rgb=False)[source]

Pipe new frame to the fake camera

Parameters:
  • frame (numpy representation of an image) – np.zeros((480,640,3), dtype=np.uint8)
  • rgb (bool) – if you want to give me an rgb frame, you’ll have to set this.
show()[source]

Show the fake camera by using ffplay

Selenium