Skip to content

Commit

Permalink
dodano zapisywanie historii oglądania
Browse files Browse the repository at this point in the history
  • Loading branch information
TowarzyszFatCat committed Jun 23, 2024
1 parent f8f695a commit 2c3d67b
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 13 deletions.
2 changes: 1 addition & 1 deletion DISCLAIMER.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ This project uses client-side content access mechanisms. Hence, the copyright in
<b>Do not harass the developer. Any personal information about the developer is intentionally not made public. Exploiting such information without consent in regards to this topic will lead to legal actions by the developer themselves.</b>


<h2>
<h3>
Contacting the developer
</h3>
<br>
Expand Down
11 changes: 6 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 ]
[ UPDATE v2.7.1 ]

Dodano wsparcie doccli na systemie Windows!
Dodano zapisywanie historii oglądania!
</h2>

---
Expand All @@ -26,6 +26,7 @@ https://github.com/TowarzyszFatCat/doccli/assets/68988781/5264bff1-4746-4581-814
<td>

- Lista anime do obejrzenia
- Historia oglądania
- Funkcja następny/poprzedni odcinek
- Szybka wyszukiwarka z całą listą dostępnych anime
- Wznawianie oglądania
Expand All @@ -34,7 +35,7 @@ https://github.com/TowarzyszFatCat/doccli/assets/68988781/5264bff1-4746-4581-814
</td>
<td>

- Inne integracje
- Wsparcie większej ilości źródeł

</td>
</tr>
Expand All @@ -43,7 +44,7 @@ https://github.com/TowarzyszFatCat/doccli/assets/68988781/5264bff1-4746-4581-814
---

<h1 align="center">
Instalacja na systemie Windows:
Instalacja na systemie Windows [Najnowsza: v2.7]:

</h1>

Expand All @@ -67,7 +68,7 @@ https://github.com/TowarzyszFatCat/doccli/assets/68988781/5264bff1-4746-4581-814

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

</h1>

Expand Down
2 changes: 2 additions & 0 deletions docchi_api_connector.py → api_connector.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from requests import get


### DOCCHI

# Get list of players for episode
def get_players_list(SLUG, NUMBER):
request = get(f"https://api.docchi.pl/v1/episodes/find/{SLUG}/{NUMBER}")
Expand Down
2 changes: 1 addition & 1 deletion doccli
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash

~/.doccli_src/.venv/bin/python ~/.doccli_src/main.py
~/.doccli_src/.venv/bin/python ~/.doccli_src/run.py
46 changes: 42 additions & 4 deletions menu_module.py → main_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
from InquirerPy import inquirer, prompt
import os
from os import system
from docchi_api_connector import get_series_list, get_episodes_count_for_serie, get_players_list, get_details_for_serie
from api_connector import get_series_list, get_episodes_count_for_serie, get_players_list, get_details_for_serie
from subprocess import Popen, DEVNULL
from termcolor import colored
import webbrowser
from discord_integration import update_rpc, set_running
import platform
from zipfile import ZipFile
from datetime import datetime


def clear():
Expand Down Expand Up @@ -58,6 +59,7 @@ def m_welcome():
choices.append(f"Wznów {continue_data[0]['title']} / {continue_data[0]['title_en']}, Odc: {continue_data[1]}")

choices.append("Moja lista")
choices.append("Historia oglądania")
choices.append("Ustawienia")
choices.append("Dołącz do discorda")
choices.append("Zamknij")
Expand All @@ -76,10 +78,12 @@ def m_welcome():
elif ans == choices[2]:
m_mylist()
elif ans == choices[3]:
m_settings()
m_history()
elif ans == choices[4]:
m_discord()
m_settings()
elif ans == choices[5]:
m_discord()
elif ans == choices[6]:
set_running(False)
sys.exit()

Expand Down Expand Up @@ -135,6 +139,23 @@ def m_mylist():
index = choices.index(ans)
m_details(mylist[index - 1])

def m_history():
choices = ['Cofnij']

message = ''
if not history:
message = ("Nic tu nie ma!")

for element in history:
choices.append(element)

prompt = 'Wyszukaj: '
ans = open_menu(choices=choices, prompt=prompt, qmark=message)
if ans == choices[0]:
m_welcome()
else:
m_history()

def m_find():
choices = [
"Po tytule",
Expand Down Expand Up @@ -334,6 +355,12 @@ def w_default(SLUG, NUMBER, process):
else:
update_rpc(f"Ogląda anime", settings[1])

# Save to history
now = datetime.now()
dt_string = now.strftime("%d/%m/%Y %H:%M")
history.insert(0, f"[{dt_string}] {details['title']} / {details['title_en']} [Odc: {NUMBER}]")
save()

choices = [
"Następny odcinek",
"Poprzedni odcinek",
Expand Down Expand Up @@ -374,6 +401,7 @@ def w_default(SLUG, NUMBER, process):
PATH_mylist = os.path.join(PATH_config, "mylist.json")
PATH_continue = os.path.join(PATH_config, "continue.json")
PATH_settings = os.path.join(PATH_config, "settings.json")
PATH_history = os.path.join(PATH_config, "history.json")

# Windows MPV location
WIN_home = os.path.expanduser('~')
Expand All @@ -397,6 +425,9 @@ def load():
global settings
settings = [True, "Używa doccli!"]
json.dump(settings, file, indent=4)
if not os.path.exists(PATH_history):
with open(PATH_history, 'w') as file:
file.write('[]')

# Win install
if platform.system() == "Windows":
Expand Down Expand Up @@ -429,11 +460,18 @@ def load():
loaded_data = json.load(json_file)
settings = loaded_data

with open(PATH_history, 'r') as json_file:
loaded_data = json.load(json_file)
global history
history = loaded_data


def save():
with open(PATH_mylist, 'w') as json_file:
json.dump(mylist, json_file, indent=4)
with open(PATH_continue, 'w') as json_file:
json.dump(continue_data, json_file, indent=4)
with open(PATH_settings, 'w') as json_file:
json.dump(settings, json_file, indent=4)
json.dump(settings, json_file, indent=4)
with open(PATH_history, 'w') as json_file:
json.dump(history, json_file, indent=4)
4 changes: 2 additions & 2 deletions main.py → run.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from menu_module import m_welcome
from main_module import m_welcome
from requests import get
from termcolor import colored
import webbrowser
Expand All @@ -7,7 +7,7 @@
import platform
import os

VERSION = "v2.7"
VERSION = "v2.7.1"

def check_update() -> None:

Expand Down

0 comments on commit 2c3d67b

Please sign in to comment.