Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ I applied some magic to summon the ingestion of `chapter markers` to the video t

1. Download and install zsh zim framework: `curl -fsSL https://raw.githubusercontent.com/zimfw/install/master/install.zsh | zsh`
2. Remove `compinit` from your .zshrc if needed
3. Install asciinema `apt install asciinema python3-docopt`
3. Install asciinema and Python dependencies:
```bash
apt install asciinema
pip install -r requirements.txt # installs docopt + prompt_toolkit
```
4. Edit .zimrc and add `zmodule cmprmsd/cinelog`
5. Run `zimfw install` to download the plugin from GitHub
6. Start a new terminal
Expand Down
11 changes: 7 additions & 4 deletions cinelog.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
# Author: Sebastian Haas - https://h8.to
####################################################

# Resolve plugin directory dynamically — works with zim, oh-my-zsh, antigen, manual installs, etc.
CINELOG_DIR="${${0:A:h}}"

# Color definitions using 24-bit true color (RGB)
RESET='\e[0m' # Resets all attributes
BOLD='\e[1m'
Expand All @@ -13,7 +16,7 @@ BOLD='\e[1m'
BASIC_RED='\e[31m'
BASIC_GREEN='\e[32m'
BASIC_BLUE='\e[34m'
BAISC_MAGENTA='\e[35m'
BASIC_MAGENTA='\e[35m'
BASIC_CYAN='\e[36m'
# Pastel Colors
PASTEL_RED='\e[38;2;255;105;97m'
Expand Down Expand Up @@ -69,8 +72,8 @@ here() {
alias cs="clear; load_motd"

# Interactive history search with graphical Asciinema UI
alias hist="$HOME/.zim/modules/cinelog/hist"
alias histo="$HOME/.zim/modules/cinelog/histo"
alias hist="$CINELOG_DIR/hist"
alias histo="$CINELOG_DIR/histo"

# MOTD functionality
load_motd() {
Expand Down Expand Up @@ -151,7 +154,7 @@ else
# Check for webserver and spawn if not running
if ! ss -tln | grep -q ":${CINELOG_VIEWER_PORT}"; then
{
nohup python3 "$HOME/.zim/modules/cinelog/http_server.py" & #>/dev/null 2>&1 &
nohup python3 "$CINELOG_DIR/http_server.py" & #>/dev/null 2>&1 &
} &>/dev/null
fi
export LOGFILE="$LOGDIR/terminal_$(date +%F_%T:%3N).cast"
Expand Down
15 changes: 13 additions & 2 deletions http_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,26 @@ def do_GET(self):

def run_server(port, directory, auth_token):
handler = partial(AuthHandler, auth_token=auth_token, directory=directory)
ip = subprocess.check_output("ip route get 1 | awk '{print $7}'", shell=True).decode().strip()
try:
ip = subprocess.check_output("ip route get 1 | awk '{print $7}'", shell=True).decode().strip()
except Exception:
import socket
# Fallback for non-Linux systems (macOS, BSD)
with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as s:
s.connect(("8.8.8.8", 80))
ip = s.getsockname()[0]
with socketserver.TCPServer((ip, port), handler) as httpd:
print(f"Serving at port {port} with authentication")
httpd.serve_forever()

if __name__ == "__main__":
port = int(os.environ.get('CINELOG_VIEWER_PORT', 10000))
auth_token = os.environ.get('CINELOG_AUTH_UUID')
directory = os.path.expanduser("~/.zim/modules/cinelog/asciinema-player")
# Use CINELOG_DIR env var if set (exported by the zsh plugin), otherwise fall back to
# a path relative to this script's location — works regardless of plugin manager.
script_dir = os.path.dirname(os.path.realpath(__file__))
directory = os.environ.get('CINELOG_DIR', script_dir)
directory = os.path.join(directory, 'asciinema-player')

if not auth_token:
print("Error: CINELOG_AUTH_UUID environment variable not set")
Expand Down
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
docopt==0.6.2
prompt_toolkit>=3.0.0