Compare commits
1 Commits
2020-06-21
...
2019-02-20
Author | SHA1 | Date | |
---|---|---|---|
c730a5b169 |
48
audiotrim.sh
Normal file
48
audiotrim.sh
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
#!/usr/bin/bash
|
||||||
|
# Trim an audio file given a startpoint and an endpoint
|
||||||
|
# Dependencies: ffmpeg
|
||||||
|
|
||||||
|
printHelp() {
|
||||||
|
cat << EOF
|
||||||
|
Usage: audiotrim [input file] [start time] [stop time] [output file]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-h show this help page
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
case "${1}" in
|
||||||
|
'-h'|'--help')
|
||||||
|
printHelp
|
||||||
|
exit
|
||||||
|
;;
|
||||||
|
--)
|
||||||
|
shift
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
-*)
|
||||||
|
printf '%s\n' "Unknown option: ${1}"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ ! -x '/usr/bin/ffmpeg' ]]; then
|
||||||
|
printf '%s\n' 'ffmpeg program is not installed' >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
readonly infile="${1}"
|
||||||
|
readonly starttime="${2}"
|
||||||
|
readonly stoptime="${3}"
|
||||||
|
readonly outfile="${4}"
|
||||||
|
readonly format="${1%.*}"
|
||||||
|
|
||||||
|
[[ -z "${infile}" ]] && printf '%s\n' "No file entered." >&2 exit 2
|
||||||
|
[[ ! -f "${infile}" ]] && printf '%s\n' "Not a file: ${infile}" >&2 exit 3
|
||||||
|
|
||||||
|
ffmpeg -i "${infile}" -ss "${starttime}" -to "${stoptime}" -c copy "${outfile:-"${outfile%.*}-trimmed.${format}"}"
|
0
cptemplate.sh
Executable file → Normal file
0
cptemplate.sh
Executable file → Normal file
74
dlaudio.py
Normal file
74
dlaudio.py
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
"""Download audio using youtube-dl.
|
||||||
|
|
||||||
|
Dependencies:
|
||||||
|
=============
|
||||||
|
|
||||||
|
* youtube-dl
|
||||||
|
"""
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
from pathlib import Path
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
# =========== Constants ==========
|
||||||
|
YOUTUBE_DL_BIN = "/usr/bin/youtube-dl"
|
||||||
|
DEFAULT_FILENAME = f"{Path.home() / 'Music'}/%(title)s.%(ext)s"
|
||||||
|
DEFAULT_YOUTUBE_DL_OPTS = (
|
||||||
|
"--no-part",
|
||||||
|
"--audio-quality=0",
|
||||||
|
"--no-continue",
|
||||||
|
"--extract-audio",
|
||||||
|
)
|
||||||
|
|
||||||
|
# ----- Error Codes -----
|
||||||
|
E_NOURLS = 2
|
||||||
|
|
||||||
|
|
||||||
|
# ========== Functions ==========
|
||||||
|
def parse_cmdline_arguments(**kwargs):
|
||||||
|
"""Parse command line arguments passed to the script.
|
||||||
|
All kwargs are passed to ArgumentParser.parse_args().
|
||||||
|
|
||||||
|
:rtype: argparse.Namespace object
|
||||||
|
"""
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument("-b", "--batchfile", help="provide the links from a text file")
|
||||||
|
parser.add_argument(
|
||||||
|
"-f", "--format", type=str, default="opus", help="the format to use"
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"-n", "--filename", type=str, help="downloaded filename (without extension)"
|
||||||
|
)
|
||||||
|
parser.add_argument("urls", nargs="*", help="video URLs")
|
||||||
|
|
||||||
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
# ========== Main Script ==========
|
||||||
|
if __name__ == "__main__":
|
||||||
|
args = parse_cmdline_arguments()
|
||||||
|
|
||||||
|
dl_opts = [
|
||||||
|
YOUTUBE_DL_BIN,
|
||||||
|
*DEFAULT_YOUTUBE_DL_OPTS,
|
||||||
|
f"--audio-format={args.format}",
|
||||||
|
]
|
||||||
|
|
||||||
|
# filename handling
|
||||||
|
# if -b is used, DEFAULT_FILENAME must take precedence
|
||||||
|
if args.filename is not None and args.batchfile is None:
|
||||||
|
dl_opts.append(f"{Path.home() / 'Music' / args.filename}.%(ext)s")
|
||||||
|
else:
|
||||||
|
dl_opts.append(f"--output={DEFAULT_FILENAME}")
|
||||||
|
|
||||||
|
# URL handling
|
||||||
|
if args.batchfile is not None:
|
||||||
|
dl_opts.append(f"--batch-file={args.batchfile}")
|
||||||
|
elif args.urls is not None:
|
||||||
|
dl_opts.extend(args.urls)
|
||||||
|
else:
|
||||||
|
print("URLs are required")
|
||||||
|
exit(E_NOURLS)
|
||||||
|
|
||||||
|
subprocess.run(dl_opts)
|
5
drivetemp.py
Executable file → Normal file
5
drivetemp.py
Executable file → Normal file
@ -54,7 +54,10 @@ def convert_to_celsius(mkel_temp):
|
|||||||
# ========== Main Script ==========
|
# ========== Main Script ==========
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"device", help="device node to retrieve the temperature for", metavar="dev"
|
"device",
|
||||||
|
help="device node to retrieve\
|
||||||
|
the temperature for",
|
||||||
|
metavar="dev",
|
||||||
)
|
)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
27
fedit.py
Executable file → Normal file
27
fedit.py
Executable file → Normal file
@ -13,8 +13,6 @@ import os
|
|||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from sys import platform
|
|
||||||
|
|
||||||
# ========== Constants ==========
|
# ========== Constants ==========
|
||||||
# ----- Paths -----
|
# ----- Paths -----
|
||||||
BOOT_DIR = "/boot"
|
BOOT_DIR = "/boot"
|
||||||
@ -26,26 +24,15 @@ E_NOEDITORFOUND = 2
|
|||||||
E_NOFILESELECTED = 3
|
E_NOFILESELECTED = 3
|
||||||
|
|
||||||
# ----- Commands -----
|
# ----- Commands -----
|
||||||
|
FIND_CMD = "/usr/bin/fd"
|
||||||
# Options: show hidden files, null terminator, files only
|
|
||||||
# Optional arguments: show vcs files, show every file
|
|
||||||
FIND_CMD = shutil.which("fd")
|
|
||||||
FIND_OPTS = ["--hidden", "--print0", "--type", "f"]
|
FIND_OPTS = ["--hidden", "--print0", "--type", "f"]
|
||||||
EXTRA_FIND_OPTS = {"no_ignore_vcs": "--no-ignore", "no_ignore": "--no-ignore-vcs"}
|
EXTRA_FIND_OPTS = {"no_ignore_vcs": "--no-ignore", "no_ignore": "--no-ignore-vcs"}
|
||||||
|
|
||||||
# Options: null terminator, ignore case, print names matching all non-option arguments
|
LOCATE_CMD = "/usr/bin/locate"
|
||||||
LOCATE_CMD = shutil.which("locate")
|
|
||||||
|
|
||||||
# Options: read null terminator, auto-select if one option, exit if no options, print null terminator
|
|
||||||
FZF_CMD = shutil.which("fzf")
|
|
||||||
FZF_OPTS = ["--read0", "--select-1", "--exit-0", "--print0"]
|
|
||||||
|
|
||||||
# Platform-specific options
|
|
||||||
# macOS doesn't support GNU-style long options
|
|
||||||
if platform == "linux":
|
|
||||||
LOCATE_OPTS = ["--all", "--ignore-case", "--null"]
|
LOCATE_OPTS = ["--all", "--ignore-case", "--null"]
|
||||||
elif platform == "darwin":
|
|
||||||
LOCATE_OPTS = ["-0", "-i"]
|
FZF_CMD = "/usr/bin/fzf"
|
||||||
|
FZF_OPTS = ["--read0", "--select-1", "--exit-0", "--print0"]
|
||||||
|
|
||||||
# ----- Misc. -----
|
# ----- Misc. -----
|
||||||
LOCALE = "utf-8"
|
LOCALE = "utf-8"
|
||||||
@ -152,10 +139,6 @@ def locate_files(patterns):
|
|||||||
|
|
||||||
# ========== Main Script ==========
|
# ========== Main Script ==========
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# This script doesn't support Windows
|
|
||||||
if platform == "windows":
|
|
||||||
sys.exit(E_INTERRUPT)
|
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-b",
|
"-b",
|
||||||
|
0
getweather.py
Executable file → Normal file
0
getweather.py
Executable file → Normal file
0
lsgroups.sh
Executable file → Normal file
0
lsgroups.sh
Executable file → Normal file
0
lsusers.sh
Executable file → Normal file
0
lsusers.sh
Executable file → Normal file
0
misc/quickdel.sh
Executable file → Normal file
0
misc/quickdel.sh
Executable file → Normal file
0
quickdel.py
Executable file → Normal file
0
quickdel.py
Executable file → Normal file
14
zsh/completions/_dlaudio
Normal file
14
zsh/completions/_dlaudio
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#compdef dlaudio
|
||||||
|
|
||||||
|
# zsh completions for 'dlaudio'
|
||||||
|
local arguments
|
||||||
|
|
||||||
|
arguments=(
|
||||||
|
{-h,--help}'[show this help message and exit]'
|
||||||
|
{-b,--batch-dl}'[provide the links from a text file]'
|
||||||
|
{-f,--format}'[the format to use (default:flac)]'
|
||||||
|
{-n,--filename}'[the name of the downloaded file (without extension)]'
|
||||||
|
'*:filename:_files'
|
||||||
|
)
|
||||||
|
|
||||||
|
_arguments -s $arguments
|
@ -1,11 +1,11 @@
|
|||||||
# Fuzzy find a file and then edit it
|
# Fuzzy find a file and then edit it
|
||||||
|
|
||||||
_fedit() {
|
_fedit() {
|
||||||
fedit && zle reset-prompt
|
/usr/bin/fedit && zle reset-prompt
|
||||||
}
|
}
|
||||||
|
|
||||||
_etcedit() {
|
_etcedit() {
|
||||||
fedit --etc && zle reset-prompt
|
/usr/bin/fedit --etc && zle reset-prompt
|
||||||
}
|
}
|
||||||
|
|
||||||
zle -N _fedit
|
zle -N _fedit
|
||||||
|
Reference in New Issue
Block a user