-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·113 lines (94 loc) · 3.31 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·113 lines (94 loc) · 3.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/usr/bin/env bash
set -euo pipefail
project_root="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
config_dir="${HOME}/.config/tubefold"
config_file="${config_dir}/config.env"
bin_dir="${HOME}/.local/bin"
link_path="${bin_dir}/tubefold"
server_link_path="${bin_dir}/tubefold-server"
project_root_quoted="$(printf "%q" "$project_root")"
missing=0
if ! command -v python3 >/dev/null 2>&1; then
echo "[ERROR] Missing dependency: python3" >&2
missing=1
fi
# A provider CLI is needed at runtime. Either Codex or Claude Code works; both use
# the user's own subscription (no API key). Require at least one.
have_codex=0
have_claude=0
command -v codex >/dev/null 2>&1 && have_codex=1
command -v claude >/dev/null 2>&1 && have_claude=1
if [[ "$have_codex" -eq 0 && "$have_claude" -eq 0 ]]; then
echo "[ERROR] Missing provider CLI: install 'codex' or 'claude' (Claude Code)." >&2
missing=1
else
[[ "$have_codex" -eq 0 ]] && echo "[WARN] codex not found; provider=codex will be unavailable." >&2
[[ "$have_claude" -eq 0 ]] && echo "[WARN] claude not found; provider=claude will be unavailable." >&2
fi
if ! python3 -c 'import youtube_transcript_api' >/dev/null 2>&1; then
echo "[ERROR] Missing Python dependency: youtube-transcript-api" >&2
echo " Install it with: python3 -m pip install youtube-transcript-api" >&2
missing=1
fi
if ! command -v yt-dlp >/dev/null 2>&1; then
echo "[WARN] yt-dlp not found; metadata will fall back to the video ID." >&2
fi
if [[ "$missing" -ne 0 ]]; then
echo "Install missing dependencies, then run install.sh again." >&2
exit 127
fi
mkdir -p "$config_dir" "$bin_dir"
if [[ ! -e "$config_file" ]]; then
cp "$project_root/config/config.example.env" "$config_file"
echo "Created config: $config_file"
else
echo "Config already exists, left unchanged: $config_file"
fi
chmod +x \
"$project_root/bin/tubefold" \
"$project_root/bin/tubefold-server" \
"$project_root/providers/"*.sh \
"$project_root/scripts/"*.sh \
"$project_root/scripts/"*.py
install_launcher() {
local target_path="$1"
local script_path="$2"
if [[ -L "$target_path" ]]; then
rm "$target_path"
elif [[ -e "$target_path" ]]; then
if ! grep -q "Generated by tubefold install.sh" "$target_path" 2>/dev/null; then
echo "[ERROR] Refusing to overwrite non-tubefold file: $target_path" >&2
exit 1
fi
fi
cat > "$target_path" <<EOF
#!/usr/bin/env bash
# Generated by tubefold install.sh
set -euo pipefail
project_root=$project_root_quoted
if [[ -x "\$project_root/.venv/bin/python" ]]; then
export PATH="\$project_root/.venv/bin:\$PATH"
exec "\$project_root/.venv/bin/python" "\$project_root/$script_path" "\$@"
fi
exec python3 "\$project_root/$script_path" "\$@"
EOF
chmod +x "$target_path"
}
install_launcher "$link_path" "bin/tubefold"
install_launcher "$server_link_path" "bin/tubefold-server"
cat <<EOF
Installed tubefold:
$link_path
$server_link_path
Next steps:
1. Ensure $bin_dir is in PATH.
2. Edit $config_file if needed.
3. Run:
tubefold "https://youtu.be/dQw4w9WgXcQ" --verbose
Chrome Extension:
1. Start the local API:
tubefold-server --provider codex
2. Install the Chrome extension from the Chrome Web Store:
https://chromewebstore.google.com/detail/tubefold-mac-app-companio/hjfcdpioihmgoccmfkcicofjgbkjidbh
(source: https://github.com/TubeFold/extension)
EOF