8000 v2.1.6 by SenZmaKi · Pull Request #32 · SenZmaKi/Senpwai · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

v2.1.6 #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in 10000 to your account

Merged
merged 6 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Bug fixes

- senpcli: Fix rejected downloads when start episode is specified but end episode isn't

# New features

- senpcli: Show release notes when about to update
11 changes: 9 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "senpwai"
version = "2.1.5"
version = "2.1.6"
description = "A desktop app for tracking and batch downloading anime"
authors = ["SenZmaKi <senzmaki@gmail.com>"]
license = "GPL v3"
Expand Down Expand Up @@ -65,7 +65,14 @@ build-backend = "poetry.core.masonry.api"
[tool.poe.tasks]
release = "python -m scripts.release"
bump_version = "python -m scripts.bump_version"
generate_release_test = [{ ref = "test" }, { ref = "generate_release" }]
announce = "python -m scripts.announce"
announce_discord = "python scripts/announce/discord.py"
announce_reddit = "python scripts/announce/reddit.py"
ruff = [{ ref = "lint_fix" }, { ref = "format" }]
lint = "python -m scripts.ruff"
lint_fix = "python -m scripts.ruff --lint_fix"
format = "python -m scripts.ruff --format"
generate_release_test = [{ref = "lint"}, { ref = "test" }, { ref = "generate_release" }]
generate_release_ddl = [{ ref = "test_ddl" }, { ref = "generate_release" }]
generate_release = [
{ ref = "build_exes" },
Expand Down
2 changes: 1 addition & 1 deletion scripts/announce/__main__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from announce.main import main
from scripts.announce.main import main
from scripts.utils import get_piped_input, ARGS

if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion scripts/announce/discord.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import re

from scripts.utils import ARGS, ROOT_DIR, get_piped_input
from .utils import FailedToAnnounce
from scripts.announce.utils import FailedToAnnounce

CHANNEL_URL = "https://discord.com/api/v10/channels/1142774130689720370/messages"
URL_REGEX = re.compile(r"https://\S+")
Expand Down
14 changes: 7 additions & 7 deletions scripts/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
ROOT_DIR,
overwrite,
)
from scripts import bump_version
from scripts import bump_version, ruff
from scripts import announce

BRANCH_NAME = get_current_branch_name()
Expand All @@ -33,19 +33,17 @@ def add_change_log_link(release_notes: str) -> str:


def get_release_notes() -> str:
if "--from_commits" in ARGS:
with open(ROOT_DIR.joinpath("RELEASE_NOTES.md"), "r+") as f:
if "--from_commits" not in ARGS:
return add_change_log_link(f.read())
new_commits_completed_process = subprocess.run(
f"git log --oneline master..{BRANCH_NAME}", capture_output=True, text=True
)
new_commits_completed_process.check_returncode()
release_notes = f"# Changes\n\n{new_commits_completed_process.stdout}"
overwrite(f, release_notes)
return add_change_log_link(release_notes)

with open(ROOT_DIR.joinpath("scripts/changelog.md"), "r+") as f:
full_release_notes = add_change_log_link(f.read())
overwrite(f, full_release_notes)
return full_release_notes


def publish_release(release_notes: str) -> None:
subprocess.run("glow", input=release_notes.encode()).check_returncode()
Expand All @@ -63,6 +61,8 @@ def main() -> None:
if "--skip_bump" not in ARGS:
log_info("Bumping version")
bump_version.main(True)
if "--skip_ruff" not in ARGS:
ruff.main(True, True)
if "--skip_build" not in ARGS:
log_info("Generating release")
subprocess.run("poe generate_release_ddl").check_returncode()
Expand Down
23 changes: 23 additions & 0 deletions scripts/ruff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import subprocess
from scripts.utils import ARGS, ROOT_DIR


def main(
lint_fix=False,
format=False,
) -> None:
if lint_fix or "--lint_fix" in ARGS:
subprocess.run(f"ruff {ROOT_DIR} --fix").check_returncode()
subprocess.run(
'git commit -am "Fix linting issues with ruff" '
)
return
if format or "--format" in ARGS:
subprocess.run(f"ruff format {ROOT_DIR}").check_returncode()
subprocess.run('git commit -am "Format with ruff" ')
return
subprocess.run(f"ruff {ROOT_DIR}").check_returncode()


if __name__ == "__main__":
main()
4 changes: 2 additions & 2 deletions scripts/setup.iss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "Senpwai"
#define MyAppVersion "2.1.5"
#define MyAppVersion "2.1.6"
#define MyAppPublisher "AkatsuKi Inc."
#define MyAppURL "https://github.com/SenZmaKi/Senpwai"
#define MyAppExeName "Senpwai.exe"
Expand All @@ -14,7 +14,7 @@
AppId={{B1AC746D-A6F0-44EF-B812.1.8-0DF4571B51}}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
VersionInfoVersion=2.1.5.0
VersionInfoVersion=2.1.6.0
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
Expand Down
4 changes: 2 additions & 2 deletions scripts/setup_senpcli.iss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "Senpcli"
#define MyAppVersion "2.1.5"
#define MyAppVersion "2.1.6"
#define MyAppPublisher "AkatsuKi Inc."
#define MyAppURL "https://github.com/SenZmaKi/Senpwai"
#define MyAppExeName "Senpcli.exe"
Expand All @@ -14,7 +14,7 @@
AppId={{7D4A0DD5-EACB-45-81FC-2.1.85FCFF05BB6}}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
VersionInfoVersion=2.1.5.0
VersionInfoVersion=2.1.6.0
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
Expand Down
32 changes: 16 additions & 16 deletions senpwai/scrapers/gogo/main.py
Original file line number Diff line F438 number Diff line change
Expand Up @@ -134,22 +134,22 @@ def calculate_total_download_size(
def get_anime_page_content(anime_page_link: str) -> bytes:
global FIRST_REQUEST
if FIRST_REQUEST:
exceptions_to_ignore = [DomainNameError]
FIRST_REQUEST = False
else:
exceptions_to_ignore = None
try:
response = CLIENT.get(
anime_page_link, exceptions_to_ignore=exceptions_to_ignore
)
return response.content
except DomainNameError:
global GOGO_HOME_URL
prev_home_url = GOGO_HOME_URL
GOGO_HOME_URL = get_new_home_url_from_readme(FULL_SITE_NAME)
return get_anime_page_content(
anime_page_link.replace(prev_home_url, GOGO_HOME_URL)
)
try:
FIRST_REQUEST = False
return CLIENT.get(
anime_page_link,
exceptions_to_raise=(DomainNameError, type(KeyboardInterrupt)),
).content
except DomainNameError:
global GOGO_HOME_URL
prev_home_url = GOGO_HOME_URL
GOGO_HOME_URL = get_new_home_url_from_readme(FULL_SITE_NAME)
return get_anime_page_content(
anime_page_link.replace(prev_home_url, GOGO_HOME_URL)
)
return CLIENT.get(
anime_page_link,
).content


def extract_anime_metadata(anime_page_content: bytes) -> AnimeMetadata:
Expand Down
11 changes: 6 additions & 5 deletions senpwai/scrapers/pahe/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,14 @@ def site_request(url: str) -> Response:
# This is to avoid raising DomainNameError when the something else broke instead
global FIRST_REQUEST
if FIRST_REQUEST:
exceptions_to_ignore = [DomainNameError]
FIRST_REQUEST = False
response = CLIENT.get(
url,
cookies=COOKIES,
exceptions_to_raise=(DomainNameError, type(KeyboardInterrupt)),
)
else:
exceptions_to_ignore = None
response = CLIENT.get(
url, cookies=COOKIES, exceptions_to_ignore=exceptions_to_ignore
)
response = CLIENT.get(url, cookies=COOKIES)
COOKIES.update(response.cookies)
except DomainNameError:
global PAHE_HOME_URL
Expand Down
40 changes: 19 additions & 21 deletions senpwai/senpcli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ def validate_start_and_end_episode(
) -> tuple[int, int]:
if end_episode == -1:
end_episode = total_episode_count
if start_episode == -1:
start_episode = total_episode_count
if end_episode > total_episode_count:
print(
f"Setting end episode to {total_episode_count} since the anime only has {total_episode_count} episodes"
Expand Down Expand Up @@ -571,11 +573,11 @@ def handle_gogo(parsed: Namespace, anime: Anime, anime_details: AnimeDetails):
)


def check_for_update_thread(queue: Queue) -> None:
is_available, download_url, file_name, _ = update_available(
def check_for_update_thread(queue: Queue[tuple[bool, str, str, str]]) -> None:
is_available, download_url, file_name, release_notes = update_available(
GITHUB_API_LATEST_RELEASE_ENDPOINT, APP_NAME, VERSION
)
queue.put((is_available, download_url, file_name))
queue.put((is_available, download_url, file_name, release_notes))


def download_and_install_update(
Expand All @@ -600,33 +602,29 @@ def download_and_install_update(


def handle_update_check_result(
is_available: bool, download_url, file_name: str
is_available: bool, download_url: str, file_name: str, release_notes: str
) -> None:
if not is_available:
return
print(f"\nUpdate available!!!\n\n{release_notes}\n")
if IS_PIP_INSTALL:
return print(
'Update available, install it by running "pip install senpwai --upgrade"'
)
print('Install it by running "pip install senpwai --upgrade"')
return
if SENPWAI_IS_INSTALLED:
return print("Update available, install it by updating Senpwai")
print("Install it by updating my big sister, Senpwai")
return
if OS.is_windows:
print("Update available, would you like to download and install it? (y/n)")
print("Would you like to download and install it? (y/n)")
if input("> ").lower() == "y":
try:
download_and_install_update(download_url, file_name)
except PermissionError:
print(
"Retry in an admin shell e.g., if you're using Command Prompt run it as an administrator"
)
download_and_install_update(download_url, file_name)
return
print(
f"A new version is available, but to install it you'll have to build from source\nThere is a guide at: {GITHUB_REPO_URL}"
)


def start_update_check_thread() -> tuple[Thread, Queue]:
update_check_result_queue = Queue()
def start_update_check_thread() -> tuple[Thread, Queue[tuple[bool, str, str, str]]]:
update_check_result_queue: Queue[tuple[bool, str, str, str]] = Queue()
update_check_thread = Thread(
target=check_for_update_thread, args=(update_check_result_queue,)
)
Expand Down Expand Up @@ -671,16 +669,16 @@ def initiate_download_pipeline(


def validate_args(parsed: Namespace) -> bool:
if parsed.end_episode < parsed.start_episode:
if parsed.end_episode < parsed.start_episode and parsed.end_episode != -1:
print("End episode cannot be less than start episode, hontoni baka ga")
return False
elif parsed.start_episode < 1 and parsed.start_episode != -1:
if parsed.start_episode < 1 and parsed.start_episode != -1:
print("Start episode cannot be less than 1, is that your IQ?")
return False
elif parsed.end_episode < 1 and parsed.end_episode != -1:
if parsed.end_episode < 1 and parsed.end_episode != -1:
print("End episode cannot be less than 1, is that your brain cell count?")
return False
elif parsed.site != GOGO and parsed.hls:
if parsed.site != GOGO and parsed.hls:
print("Setting site to Gogo since HLS mode is only available for Gogo")
parsed.site = GOGO

Expand Down
Loading
0