Skip to content

Commit

Permalink
- Aktualizacja 2.8
Browse files Browse the repository at this point in the history
  • Loading branch information
TowarzyszFatCat committed Aug 8, 2024
1 parent 5125122 commit 574fd11
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 11 deletions.
24 changes: 19 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ CLI do oglądania anime z <a href="https://docchi.pl/">docchi.pl</a>
</h1>

<h2 align="center">
[ UPDATE v2.7.4 ]
[ UPDATE v2.8 ]

Dodano statystyki doccli!
Dodano wyświelanie okładek!
</h2>

---
Expand All @@ -32,6 +32,7 @@ https://github.com/TowarzyszFatCat/doccli/assets/68988781/5264bff1-4746-4581-814
- Wznawianie oglądania
- Możliwość ustawienia własnego statusu na discordzie
- Statystyki
- Podgląd okładki

</td>
<td>
Expand Down Expand Up @@ -69,7 +70,7 @@ https://github.com/TowarzyszFatCat/doccli/assets/68988781/5264bff1-4746-4581-814

---
<h1 align="center">
Instalacja na systemie Linux [Najnowsza: v2.7.4]:
Instalacja na systemie Linux [Najnowsza: v2.8]:

</h1>

Expand All @@ -78,14 +79,23 @@ Aby korzystać z doccli na systemie linux musisz zainstalować `mpv` i `yt-dlp`!

Instalacja `mpv` i `yt-dlp` na Arch:
```bash
sudo pacman -S mpv yt-dlp python3-venv
sudo pacman -S mpv yt-dlp
```

Instalacja `mpv` i `yt-dlp` na Debian/Ubuntu/Pop:
```bash
sudo apt install mpv yt-dlp python3-venv
sudo apt install mpv yt-dlp
```


> [!WARNING]
> Na niektórych dystrybucjach wymagana jest także instalacja `python3-venv` przed instalacją doccli!

### Opcjonalne paczki:
Aby wyświetlać okładki wymagana jest instalacja `timg`


### Instalacja w jednej komendzie:
```bash
cd ~ && git clone https://github.com/TowarzyszFatCat/doccli.git && bash doccli/install.sh
Expand All @@ -101,6 +111,10 @@ sudo rm /usr/local/bin/doccli && sudo rm -rf ~/.doccli_src
sudo rm /usr/local/bin/doccli && sudo rm -rf ~/.doccli_src && cd ~ && git clone https://github.com/TowarzyszFatCat/doccli.git && bash doccli/install.sh
```

> [!IMPORTANT]
> Jeżeli aktualizujesz doccli z wersji v2.7.X do v2.8 zwróć uwagę na opcjonalne paczki!

### Jak usunąć `moją listę` oraz `config` (niezalecane, chyba że wymaga tego aktualizacja):
```bash
sudo rm ~/.config/doccli/*
Expand Down
34 changes: 29 additions & 5 deletions main_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import platform
from zipfile import ZipFile
from datetime import datetime, date
import requests
import shutil


def clear():
Expand All @@ -21,10 +23,25 @@ def clear():
elif platform.system() == "Windows":
system("cls")

def get_terminal_size():
columns, rows = os.get_terminal_size()
return columns, rows

def open_menu(choices, prompt='Prompt', border=True, qmark='', message='', pointer='>', cycle=True, height=10):

def open_menu(choices, prompt='Prompt', border=True, qmark='', message='', pointer='>', cycle=True, height=10, image=None):
clear()

if image:
if shutil.which('timg') is None:
print(colored("[UWAGA]", "yellow"), colored("Aby wyświetlać okładki wymagana jest instalacja", "white"), colored("timg", "green"), '\n')
else:
response = requests.get(image)
image_path = "/tmp/cover.jpg"
with open(image_path, 'wb') as file:
file.write(response.content)
os.system(f"timg -C -g {get_terminal_size()[0]}x{get_terminal_size()[1] - height - 4} {image_path}")


action = inquirer.fuzzy(
message=message, # Message above border
choices=choices,
Expand Down Expand Up @@ -68,7 +85,7 @@ def m_welcome():

prompt = 'Wybierz co chcesz zrobić: '

ans = open_menu(choices=choices, prompt=prompt)
ans = open_menu(choices=choices, prompt=prompt, height=8)

if ans == choices[0]:
m_find()
Expand Down Expand Up @@ -170,7 +187,7 @@ def m_find():

prompt = 'Wybierz jak chcesz wyszukać: '

ans = open_menu(choices=choices, prompt=prompt)
ans = open_menu(choices=choices, prompt=prompt, height=4)

if ans == choices[0]:
f_title()
Expand Down Expand Up @@ -291,7 +308,7 @@ def m_details(details):

episode_count = get_episodes_count_for_serie(details['slug'])

ans = open_menu(choices=choices, prompt=prompt, qmark=f'{details["title"]} / {details["title_en"]} [{episode_count}]', message=genres)
ans = open_menu(choices=choices, prompt=prompt, qmark=f'{details["title"]} / {details["title_en"]} [{episode_count}]', message=genres, height=5, image=details['cover'])

if ans == choices[0]:
continue_data[0] = details
Expand Down Expand Up @@ -394,6 +411,13 @@ def w_players(SLUG, NUMBER, err=''):


def mpv_play(URL):
if shutil.which('mpv') is None:
print(colored("[BŁĄD]", "red"), colored("Aby program działał wymagana jest instalacja", "white"), colored("mpv", "green"), '\n')
sys.exit()
if shutil.which('yt-dlp') is None:
print(colored("[BŁĄD]", "red"), colored("Aby program działał wymagana jest instalacja", "white"), colored("yt-dlp", "green"), '\n')
sys.exit()

process = Popen(args=['mpv' if platform.system() == "Linux" else WIN_mpv, "--save-position-on-quit", URL], shell=False, stdout=DEVNULL, stderr=DEVNULL)
return process

Expand Down Expand Up @@ -424,7 +448,7 @@ def w_default(SLUG, NUMBER, process):

prompt = 'Co chcesz zrobić? '

ans = open_menu(choices=choices, prompt=prompt, qmark=f'Odcinek: {NUMBER}/{how_many_episodes}')
ans = open_menu(choices=choices, prompt=prompt, qmark=f'Odcinek: {NUMBER}/{how_many_episodes}', height=5)

if ans == choices[0]:
process.terminate()
Expand Down
2 changes: 1 addition & 1 deletion run.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import platform
import os

VERSION = "v2.7.4"
VERSION = "v2.8"

def check_update() -> None:

Expand Down

0 comments on commit 574fd11

Please sign in to comment.