vega-cli 0.1.2__tar.gz → 0.1.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {vega_cli-0.1.2 → vega_cli-0.1.4}/PKG-INFO +2 -1
- {vega_cli-0.1.2 → vega_cli-0.1.4}/pyproject.toml +2 -1
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/cli.py +21 -6
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/display.py +16 -2
- vega_cli-0.1.4/vega_cli/images.py +134 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli.egg-info/PKG-INFO +2 -1
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli.egg-info/SOURCES.txt +1 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli.egg-info/requires.txt +1 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/README.md +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/setup.cfg +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/__init__.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/__main__.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/config.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/downloader.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/history.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/html.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/interactive.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/player.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/__init__.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/ani_dream.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/anikoto.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/animesalt.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/animesub.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/animeworld.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/auto_embed.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/castle.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/cncverse.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/common/__init__.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/common/aes.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/common/aniskip.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/common/base_url.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/common/cinemeta.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/common/errors.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/common/extractors/__init__.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/common/extractors/abbasy.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/common/extractors/buzzheavier.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/common/extractors/cinejoy.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/common/extractors/gdflix.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/common/extractors/gofile.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/common/extractors/hubcloud.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/common/extractors/movy.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/common/extractors/st111477.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/common/extractors/transferit.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/common/extractors/vegadrive.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/common/extractors/vidstuck.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/common/extractors/zcloud.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/common/extractors/zypter.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/common/headers.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/common/http.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/common/net_mirror.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/common/theintrodb.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/common/unpack.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/disney_mirror.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/dramacool.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/drive.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/durbin_live.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/eon_movies.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/extraflix.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/four_khdhub.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/goku_hd.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/hdhub4u.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/internet_archive.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/kartoons.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/kartoons2.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/katmovies.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/kick_ass_anime.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/kiss_kh.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/live_tg_tv.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/lux_movies.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/mod.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/movie_box_web.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/movielinkdb.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/movies4u.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/moviezwap.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/mxplayer.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/netflix_mirror.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/one_cinevood.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/prime_mirror.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/rareanimes.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/registry.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/showbox.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/topmovies.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/torrentio.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/uhd.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/vega.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/youtube.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/providers/zeefliz.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/search_all.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/store.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli/utils.py +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli.egg-info/dependency_links.txt +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli.egg-info/entry_points.txt +0 -0
- {vega_cli-0.1.2 → vega_cli-0.1.4}/vega_cli.egg-info/top_level.txt +0 -0
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: vega-cli
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.4
|
|
4
4
|
Summary: Pure-Python CLI for Vega streaming and download providers
|
|
5
5
|
Requires-Python: >=3.11
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
7
7
|
Requires-Dist: click>=8.0
|
|
8
|
+
Requires-Dist: pillow>=10.0
|
|
8
9
|
Requires-Dist: requests>=2.31
|
|
9
10
|
Requires-Dist: rich>=13.0
|
|
10
11
|
|
|
@@ -4,12 +4,13 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "vega-cli"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.4"
|
|
8
8
|
description = "Pure-Python CLI for Vega streaming and download providers"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.11"
|
|
11
11
|
dependencies = [
|
|
12
12
|
"click>=8.0",
|
|
13
|
+
"pillow>=10.0",
|
|
13
14
|
"requests>=2.31",
|
|
14
15
|
"rich>=13.0",
|
|
15
16
|
]
|
|
@@ -102,30 +102,44 @@ def catalog(provider_name: str, as_json: bool) -> None:
|
|
|
102
102
|
@_provider_option
|
|
103
103
|
@click.option("--filter", "filter_path", default="", help="Category/genre filter path.")
|
|
104
104
|
@click.option("--page", default=1, show_default=True, type=int, help="Page number.")
|
|
105
|
+
@click.option("--images", "show_images", is_flag=True, help="Render post thumbnails in terminal.")
|
|
105
106
|
@click.option("--json", "as_json", is_flag=True, help="Output raw JSON.")
|
|
106
|
-
def posts(
|
|
107
|
+
def posts(
|
|
108
|
+
provider_name: str, filter_path: str, page: int, show_images: bool, as_json: bool
|
|
109
|
+
) -> None:
|
|
107
110
|
"""Fetch posts for a category or genre filter."""
|
|
108
111
|
client = get_provider(provider_name)
|
|
109
112
|
items = client.get_posts(filter_path=filter_path, page=page)
|
|
110
113
|
if as_json:
|
|
111
114
|
click.echo(json.dumps(items, indent=2))
|
|
112
115
|
return
|
|
113
|
-
print_posts(
|
|
116
|
+
print_posts(
|
|
117
|
+
items,
|
|
118
|
+
f"[{provider_name}] Posts (filter={filter_path or 'latest'}, page={page})",
|
|
119
|
+
show_images=show_images,
|
|
120
|
+
)
|
|
114
121
|
|
|
115
122
|
|
|
116
123
|
@cli.command()
|
|
117
124
|
@_provider_option
|
|
118
125
|
@click.argument("query")
|
|
119
126
|
@click.option("--page", default=1, show_default=True, type=int, help="Page number.")
|
|
127
|
+
@click.option("--images", "show_images", is_flag=True, help="Render post thumbnails in terminal.")
|
|
120
128
|
@click.option("--json", "as_json", is_flag=True, help="Output raw JSON.")
|
|
121
|
-
def search(
|
|
129
|
+
def search(
|
|
130
|
+
provider_name: str, query: str, page: int, show_images: bool, as_json: bool
|
|
131
|
+
) -> None:
|
|
122
132
|
"""Search posts on a provider."""
|
|
123
133
|
client = get_provider(provider_name)
|
|
124
134
|
items = client.get_search_posts(query=query, page=page)
|
|
125
135
|
if as_json:
|
|
126
136
|
click.echo(json.dumps(items, indent=2))
|
|
127
137
|
return
|
|
128
|
-
print_posts(
|
|
138
|
+
print_posts(
|
|
139
|
+
items,
|
|
140
|
+
f"[{provider_name}] Search: '{query}' (page={page})",
|
|
141
|
+
show_images=show_images,
|
|
142
|
+
)
|
|
129
143
|
|
|
130
144
|
|
|
131
145
|
@cli.command("search-all")
|
|
@@ -171,15 +185,16 @@ def search_all(
|
|
|
171
185
|
@cli.command()
|
|
172
186
|
@_provider_option
|
|
173
187
|
@click.argument("link")
|
|
188
|
+
@click.option("--images/--no-images", "show_image", default=True, help="Render poster in terminal.")
|
|
174
189
|
@click.option("--json", "as_json", is_flag=True, help="Output raw JSON.")
|
|
175
|
-
def meta(provider_name: str, link: str, as_json: bool) -> None:
|
|
190
|
+
def meta(provider_name: str, link: str, show_image: bool, as_json: bool) -> None:
|
|
176
191
|
"""Fetch metadata and download/episode links for a post."""
|
|
177
192
|
client = get_provider(provider_name)
|
|
178
193
|
info = client.get_meta(link)
|
|
179
194
|
if as_json:
|
|
180
195
|
click.echo(json.dumps(info, indent=2))
|
|
181
196
|
return
|
|
182
|
-
print_meta(info)
|
|
197
|
+
print_meta(info, show_image=show_image)
|
|
183
198
|
|
|
184
199
|
|
|
185
200
|
@cli.command()
|
|
@@ -9,6 +9,8 @@ from rich.console import Console
|
|
|
9
9
|
from rich.panel import Panel
|
|
10
10
|
from rich.table import Table
|
|
11
11
|
|
|
12
|
+
from .images import render_image_url
|
|
13
|
+
|
|
12
14
|
console = Console()
|
|
13
15
|
|
|
14
16
|
|
|
@@ -160,7 +162,9 @@ def print_bookmarks(items: list[dict[str, Any]], title: str = "Bookmarks") -> No
|
|
|
160
162
|
|
|
161
163
|
|
|
162
164
|
|
|
163
|
-
def print_posts(
|
|
165
|
+
def print_posts(
|
|
166
|
+
items: list[dict[str, str]], title: str, *, show_images: bool = False
|
|
167
|
+
) -> None:
|
|
164
168
|
"""Render a list of posts in a Rich table."""
|
|
165
169
|
table = Table(title=title)
|
|
166
170
|
table.add_column("#", justify="right", style="cyan")
|
|
@@ -169,6 +173,12 @@ def print_posts(items: list[dict[str, str]], title: str) -> None:
|
|
|
169
173
|
for idx, item in enumerate(items, start=1):
|
|
170
174
|
table.add_row(str(idx), item.get("title", ""), item.get("link", ""))
|
|
171
175
|
console.print(table)
|
|
176
|
+
if show_images:
|
|
177
|
+
for idx, item in enumerate(items[:10], start=1):
|
|
178
|
+
img_url = item.get("image") or ""
|
|
179
|
+
if img_url:
|
|
180
|
+
console.print(f"[cyan]{idx}.[/cyan] {item.get('title', '')}")
|
|
181
|
+
render_image_url(img_url, width=28, height=14)
|
|
172
182
|
|
|
173
183
|
|
|
174
184
|
def print_search_all(results: list[dict[str, Any]], query: str) -> None:
|
|
@@ -225,8 +235,12 @@ def print_bookmarks(items: list[dict[str, Any]], title: str = "Bookmarks") -> No
|
|
|
225
235
|
|
|
226
236
|
|
|
227
237
|
|
|
228
|
-
def print_meta(info: dict[str, Any]) -> None:
|
|
238
|
+
def print_meta(info: dict[str, Any], *, show_image: bool = True) -> None:
|
|
229
239
|
"""Render post metadata and available links."""
|
|
240
|
+
if show_image:
|
|
241
|
+
poster_url = info.get("poster") or info.get("image") or ""
|
|
242
|
+
if poster_url:
|
|
243
|
+
render_image_url(poster_url, width=64, height=32)
|
|
230
244
|
console.print(
|
|
231
245
|
Panel(
|
|
232
246
|
f"[bold]{info.get('title', '')}[/bold] ({info.get('type', '')})\n"
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"""Cross-platform terminal image renderer (Kitty, iTerm2/WezTerm/Warp, and 24-bit half-block fallback)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import base64
|
|
6
|
+
import io
|
|
7
|
+
import os
|
|
8
|
+
import shutil
|
|
9
|
+
import sys
|
|
10
|
+
from typing import Any
|
|
11
|
+
|
|
12
|
+
import requests
|
|
13
|
+
from PIL import Image, ImageEnhance
|
|
14
|
+
|
|
15
|
+
from .config import DEFAULT_HEADERS
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def _detect_protocol() -> str:
|
|
19
|
+
"""Detect the best supported image protocol for the current terminal."""
|
|
20
|
+
override = os.environ.get("VEGA_IMAGE_PROTOCOL", "").strip().lower()
|
|
21
|
+
if override in ("kitty", "iterm2", "halfblock"):
|
|
22
|
+
return override
|
|
23
|
+
|
|
24
|
+
term_program = os.environ.get("TERM_PROGRAM", "")
|
|
25
|
+
term = os.environ.get("TERM", "")
|
|
26
|
+
lc_terminal = os.environ.get("LC_TERMINAL", "")
|
|
27
|
+
|
|
28
|
+
if (
|
|
29
|
+
os.environ.get("KITTY_WINDOW_ID")
|
|
30
|
+
or "kitty" in term.lower()
|
|
31
|
+
or term_program.lower() == "ghostty"
|
|
32
|
+
):
|
|
33
|
+
return "kitty"
|
|
34
|
+
if (
|
|
35
|
+
term_program in ("iTerm.app", "WezTerm", "WarpTerminal", "mintty")
|
|
36
|
+
or lc_terminal == "iTerm2"
|
|
37
|
+
):
|
|
38
|
+
return "iterm2"
|
|
39
|
+
return "halfblock"
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def _emit_iterm2(raw_bytes: bytes, cols: int = 44) -> None:
|
|
43
|
+
b64 = base64.b64encode(raw_bytes).decode("ascii")
|
|
44
|
+
seq = f"\x1b]1337;File=inline=1;width={cols};preserveAspectRatio=1:{b64}\x07\n"
|
|
45
|
+
sys.stdout.write(seq)
|
|
46
|
+
sys.stdout.flush()
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def _emit_kitty(img: Image.Image, cols: int = 44) -> None:
|
|
50
|
+
buf = io.BytesIO()
|
|
51
|
+
img.convert("RGBA").save(buf, format="PNG")
|
|
52
|
+
b64 = base64.b64encode(buf.getvalue()).decode("ascii")
|
|
53
|
+
chunk_size = 4096
|
|
54
|
+
chunks = [b64[i : i + chunk_size] for i in range(0, len(b64), chunk_size)]
|
|
55
|
+
for idx, chunk in enumerate(chunks):
|
|
56
|
+
more = 1 if idx < len(chunks) - 1 else 0
|
|
57
|
+
if idx == 0:
|
|
58
|
+
sys.stdout.write(f"\x1b_Ga=T,f=100,c={cols},m={more};{chunk}\x1b\\")
|
|
59
|
+
else:
|
|
60
|
+
sys.stdout.write(f"\x1b_Gm={more};{chunk}\x1b\\")
|
|
61
|
+
sys.stdout.write("\n")
|
|
62
|
+
sys.stdout.flush()
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def render_halfblock(img: Image.Image, max_width: int = 64, max_height: int = 32) -> str:
|
|
66
|
+
"""Render a PIL Image as crisp 24-bit ANSI Unicode half-block art (cross-platform)."""
|
|
67
|
+
rgb = img.convert("RGB")
|
|
68
|
+
w, h = rgb.size
|
|
69
|
+
if w <= 0 or h <= 0:
|
|
70
|
+
return ""
|
|
71
|
+
|
|
72
|
+
term_cols = shutil.get_terminal_size((80, 24)).columns
|
|
73
|
+
capped_w = max(16, min(max_width, term_cols - 2, w))
|
|
74
|
+
target_w = capped_w
|
|
75
|
+
target_h = max(2, int(round((h / w) * target_w)))
|
|
76
|
+
if target_h > max_height * 2:
|
|
77
|
+
target_h = max_height * 2
|
|
78
|
+
target_w = max(1, int(round((w / h) * target_h)))
|
|
79
|
+
if target_h % 2 != 0:
|
|
80
|
+
target_h += 1
|
|
81
|
+
|
|
82
|
+
resized = rgb.resize((target_w, target_h), Image.Resampling.LANCZOS)
|
|
83
|
+
resized = ImageEnhance.Sharpness(resized).enhance(1.35)
|
|
84
|
+
pixels: Any = resized.load()
|
|
85
|
+
lines: list[str] = []
|
|
86
|
+
for y in range(0, target_h, 2):
|
|
87
|
+
row_chars: list[str] = []
|
|
88
|
+
for x in range(target_w):
|
|
89
|
+
r1, g1, b1 = pixels[x, y]
|
|
90
|
+
r2, g2, b2 = pixels[x, y + 1]
|
|
91
|
+
row_chars.append(f"\x1b[38;2;{r1};{g1};{b1};48;2;{r2};{g2};{b2}m▀")
|
|
92
|
+
row_chars.append("\x1b[0m")
|
|
93
|
+
lines.append("".join(row_chars))
|
|
94
|
+
return "\n".join(lines)
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def render_image_url(
|
|
98
|
+
url: str,
|
|
99
|
+
*,
|
|
100
|
+
width: int = 64,
|
|
101
|
+
height: int = 32,
|
|
102
|
+
timeout: float = 5.0,
|
|
103
|
+
) -> bool:
|
|
104
|
+
"""Fetch an image URL and render it in the terminal. Returns True on success."""
|
|
105
|
+
if not url or not url.startswith("http"):
|
|
106
|
+
return False
|
|
107
|
+
try:
|
|
108
|
+
resp = requests.get(url, headers=DEFAULT_HEADERS, timeout=timeout)
|
|
109
|
+
resp.raise_for_status()
|
|
110
|
+
raw = resp.content
|
|
111
|
+
if not raw:
|
|
112
|
+
return False
|
|
113
|
+
except Exception:
|
|
114
|
+
return False
|
|
115
|
+
|
|
116
|
+
try:
|
|
117
|
+
img = Image.open(io.BytesIO(raw))
|
|
118
|
+
except Exception:
|
|
119
|
+
return False
|
|
120
|
+
|
|
121
|
+
proto = _detect_protocol()
|
|
122
|
+
if proto == "iterm2":
|
|
123
|
+
_emit_iterm2(raw, cols=min(width, 44))
|
|
124
|
+
return True
|
|
125
|
+
if proto == "kitty":
|
|
126
|
+
_emit_kitty(img, cols=min(width, 44))
|
|
127
|
+
return True
|
|
128
|
+
|
|
129
|
+
art = render_halfblock(img, max_width=width, max_height=height)
|
|
130
|
+
if art:
|
|
131
|
+
sys.stdout.write(art + "\n")
|
|
132
|
+
sys.stdout.flush()
|
|
133
|
+
return True
|
|
134
|
+
return False
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: vega-cli
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.4
|
|
4
4
|
Summary: Pure-Python CLI for Vega streaming and download providers
|
|
5
5
|
Requires-Python: >=3.11
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
7
7
|
Requires-Dist: click>=8.0
|
|
8
|
+
Requires-Dist: pillow>=10.0
|
|
8
9
|
Requires-Dist: requests>=2.31
|
|
9
10
|
Requires-Dist: rich>=13.0
|
|
10
11
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|