|
12 | 12 | from typing import ClassVar, List, Union |
13 | 13 | from async_lru import alru_cache |
14 | 14 | from os import getenv |
| 15 | +from io import BytesIO |
15 | 16 |
|
16 | 17 | from fuzzywuzzy import fuzz |
17 | 18 | from platformdirs import user_config_path, user_log_path |
|
20 | 21 | from textual import events, on, work |
21 | 22 | from textual.app import App, ComposeResult |
22 | 23 | from textual.binding import Binding, BindingType |
23 | | -from textual.containers import Center, Container, Horizontal, ScrollableContainer |
| 24 | +from textual.containers import Center, Container, Horizontal, ScrollableContainer, Vertical |
24 | 25 | from textual.reactive import reactive |
25 | 26 | from textual.screen import ModalScreen |
26 | 27 | from textual.widgets import ( |
|
40 | 41 | TabPane, |
41 | 42 | ) |
42 | 43 | from textual.worker import get_current_worker |
| 44 | +from textual_image.widget import Image |
43 | 45 | from rich_argparse import RichHelpFormatter |
44 | 46 | from .aniskip import ( |
45 | 47 | generate_chapters_file, |
46 | 48 | get_timings_from_search |
47 | 49 | ) |
| 50 | + |
48 | 51 | from .custom_widgets import SortableTable |
49 | 52 | from .hoster._hosters import hoster |
50 | 53 | from .hoster.common import DirectLink, Hoster |
|
57 | 60 | from .settings import gucken_settings_manager |
58 | 61 | from .update import check |
59 | 62 | from .utils import detect_player, is_android, set_default_vlc_interface_cfg, get_vlc_intf_user_path |
| 63 | +from .networking import AsyncClient |
60 | 64 | from . import __version__ |
61 | 65 |
|
| 66 | + |
62 | 67 | def sort_favorite_lang( |
63 | 68 | language_list: List[Language], pio_list: List[str] |
64 | 69 | ) -> List[Language]: |
@@ -275,13 +280,23 @@ def compose(self) -> ComposeResult: |
275 | 280 | yield ListView(id="results") |
276 | 281 | with TabPane("Info", id="info", disabled=True): # Info "ℹ" |
277 | 282 | with ScrollableContainer(id="res_con"): |
278 | | - yield Markdown(id="markdown") |
| 283 | + yield Horizontal( |
| 284 | + Image(id="image"), |
| 285 | + Markdown(id="markdown"), |
| 286 | + id="res_con_2" |
| 287 | + ) |
| 288 | + |
279 | 289 | yield ClickableDataTable(id="season_list") |
280 | 290 | with TabPane("Settings", id="setting"): # Settings "⚙" |
281 | 291 | # TODO: dont show unneeded on android |
282 | 292 | with ScrollableContainer(id="settings_container"): |
283 | 293 | yield SortableTable(id="lang") |
284 | 294 | yield SortableTable(id="host") |
| 295 | + yield RadioButton( |
| 296 | + "Image display", |
| 297 | + id="image_display", |
| 298 | + value=settings["image_display"], |
| 299 | + ) |
285 | 300 | yield RadioButton( |
286 | 301 | "Update checker", |
287 | 302 | id="update_checker", |
@@ -390,6 +405,10 @@ async def radio_button_changed(self, event: RadioButton.Changed): |
390 | 405 | settings["pip"] = event.value |
391 | 406 | return |
392 | 407 |
|
| 408 | + if id == "image_display" and event.value == False: |
| 409 | + img: Image = self.query_one("#image", Image) |
| 410 | + img.image = None |
| 411 | + |
393 | 412 | settings[id] = event.value |
394 | 413 |
|
395 | 414 | if id == "discord_presence": |
@@ -616,6 +635,12 @@ async def open_info(self) -> None: |
616 | 635 | self.current_info = series |
617 | 636 | await md.update(series.to_markdown()) |
618 | 637 |
|
| 638 | + if gucken_settings_manager.settings["settings"]["image_display"]: |
| 639 | + img: Image = self.query_one("#image", Image) |
| 640 | + async with AsyncClient(verify=False) as client: |
| 641 | + response = await client.get(series.cover) |
| 642 | + img.image = BytesIO(response.content) |
| 643 | + |
619 | 644 | # make sure to reset colum spacing |
620 | 645 | table.clear(columns=True) |
621 | 646 | table.add_columns("FT", "S", "F", "Title", "Hoster", "Sprache") |
|
0 commit comments