-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from SenZmaKi/v2.1.11
v2.1.11
- Loading branch information
Showing
34 changed files
with
899 additions
and
473 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
# New features | ||
|
||
- Add tips in about section | ||
- senpcli: Stylize output 💅✨ | ||
# New features and Changes | ||
- Shorten long anime titles in progress bars | ||
- Hover on folder button shows folder location | ||
- senpcli: Always show units/time instead of time/units in progress bars | ||
- senpcli: Add anime tracking functionality | ||
- senpcli: Add option to print direct download links instead of downloading | ||
|
||
# Bug fixes | ||
|
||
- Maybe fix randomly skipped downloads, if it still happens report it | ||
- pahe: Fix infinite loading for some anime. Issue #43 | ||
- senpcli: Sort of fix Ctrl+C not terminating program, it still bugs out sometimes though | ||
- Fix some linux port issues | ||
- Fix some gogo downloads randomly failing, if you still experience it be sure to report it | ||
- Fix failed to fetch direct download links notification on cancelling direct download links retrieval | ||
- Fix anime randomizer | ||
- Fix opening chosen anime window for other anime failing if previous attempt failed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "senpwai" | ||
version = "2.1.10" | ||
version = "2.1.11" | ||
description = "A desktop app for tracking and batch downloading anime" | ||
authors = ["SenZmaKi <[email protected]>"] | ||
license = "GPL v3" | ||
|
@@ -68,13 +68,12 @@ bump_version = "python -m scripts.bump_version" | |
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 = [ | ||
lint_fix = "python -m scripts.ruff --lint_fix" | ||
lint = "python -m scripts.ruff --lint" | ||
build_release_test = [{ref = "lint"}, { ref = "test" }, { ref = "build_release" }] | ||
build_release_ddl = [{ ref = "test_ddl" }, { ref = "build_release" }] | ||
build_release = [ | ||
{ ref = "build_exes" }, | ||
{ ref = "compile_installers" }, | ||
{ ref = "install" }, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,16 @@ | ||
from argparse import ArgumentParser | ||
from scripts.announce.main import main | ||
from scripts.common import get_piped_input, ARGS | ||
from scripts.common import get_piped_input | ||
|
||
if __name__ == "__main__": | ||
main(ARGS[0], get_piped_input()) | ||
parser = ArgumentParser("Announce a new release on Discord and Reddit") | ||
parser.add_argument("-t", "--title", type=str, help="Title of the release") | ||
parser.add_argument( | ||
"-r", | ||
"--release_notes", | ||
type=str, | ||
help="Release notes, will use stdin if not provided", | ||
) | ||
parsed = parser.parse_args() | ||
release_notes = parsed.release_notes or get_piped_input() | ||
main(parsed.title, release_notes) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,141 @@ | ||
from argparse import ArgumentParser | ||
from enum import Enum | ||
import json | ||
from typing import Any | ||
import requests | ||
import re | ||
|
||
from scripts.common import ARGS, ROOT_DIR, get_piped_input | ||
from scripts.common import ROOT_DIR, get_piped_input | ||
from scripts.announce.common import FailedToAnnounce | ||
|
||
CHANNEL_URL = "https://discord.com/api/v10/channels/1142774130689720370/messages" | ||
CHANNEL_URL = "https://discord.com/api/v10/channels/{}/messages" | ||
URL_REGEX = re.compile(r"https://\S+") | ||
|
||
|
||
class ChannelID(Enum): | ||
general = "1131981620975517787" | ||
help = "1190075801815748648" | ||
bug_reports = "1134645830163378246" | ||
suggestions = "1134645775905861673" | ||
github_logs = "1205730845953097779" | ||
misc = "1211137093955362837" | ||
announcements = "1142774130689720370" | ||
|
||
def __str__(self) -> str: | ||
return self.name | ||
|
||
|
||
def remove_embed_url(string: str) -> str: | ||
return URL_REGEX.sub(lambda x: f"<{x.group(0)}>", string) | ||
|
||
|
||
def main(title: str, release_notes: str) -> None: | ||
with open(ROOT_DIR.joinpath(".credentials/discord.json")) as f: | ||
def send_message(message: str, channel_id: str, message_reference_id: str) -> None: | ||
with open(ROOT_DIR.joinpath(".credentials", "discord.json")) as f: | ||
token = json.load(f)["token"] | ||
headers = { | ||
"Authorization": f"Bot {token}", | ||
"Content-Type": "application/json", | ||
} | ||
nonembed_notes = remove_embed_url(release_notes) | ||
smaller_titles = "\n".join( | ||
[ | ||
line.replace("# ", "## ", 1) if line.strip().startswith("# ") else line | ||
for line in nonembed_notes.splitlines() | ||
] | ||
) | ||
|
||
everyone = "@everyone\n" if "--ping_everyone" in ARGS else "" | ||
message = f"{everyone}# {title}\n\n" + smaller_titles | ||
payload = { | ||
payload: dict[str, Any] = { | ||
"content": message, | ||
} | ||
response = requests.post(url=CHANNEL_URL, headers=headers, json=payload) | ||
if message_reference_id: | ||
payload["message_reference"] = {"message_id": message_reference_id} | ||
url = CHANNEL_URL.format(channel_id) | ||
response = requests.post(url, headers=headers, json=payload) | ||
if not response.ok: | ||
raise FailedToAnnounce("discord", response.json()) | ||
|
||
|
||
def main( | ||
title: str, | ||
message: str, | ||
is_release_notes=True, | ||
pinged_user_id="", | ||
message_reference_id="", | ||
channel_id=ChannelID.announcements.value, | ||
) -> None: | ||
if is_release_notes: | ||
non_embed_notes = remove_embed_url(message) | ||
message = "\n".join( | ||
[ | ||
line.replace("# ", "## ", 1) if line.strip().startswith("# ") else line | ||
for line in non_embed_notes.splitlines() | ||
] | ||
) | ||
if pinged_user_id: | ||
ping_str = ( | ||
"@everyone" if pinged_user_id == "everyone" else f"<@{pinged_user_id}>" | ||
) | ||
message = ( | ||
f"{ping_str}\n{message}" | ||
if pinged_user_id == "everyone" and is_release_notes | ||
else f"{ping_str} {message}" | ||
) | ||
if title: | ||
message = f"# {title}\n{message}" | ||
send_message(message, channel_id, message_reference_id) | ||
|
||
|
||
if __name__ == "__main__": | ||
main(ARGS[0], get_piped_input()) | ||
parser = ArgumentParser(description="Message on Discord") | ||
parser.add_argument("-t", "--title", help="Title of the message", default="") | ||
parser.add_argument( | ||
"-m", | ||
"--message", | ||
help="Body of the message, will use stdin if not provided", | ||
default="", | ||
) | ||
parser.add_argument( | ||
"-irn", | ||
"--is_release_notes", | ||
action="store_true", | ||
help="Whether the message is release notes", | ||
) | ||
parser.add_argument( | ||
"-pui", | ||
"--pinged_user_id", | ||
type=str, | ||
help="ID of the user to ping", | ||
default="", | ||
) | ||
parser.add_argument( | ||
"-pe", | ||
"--ping_everyone", | ||
action="store_true", | ||
help="Ping everyone", | ||
) | ||
parser.add_argument( | ||
"-mri", | ||
"--message_reference_id", | ||
type=str, | ||
help="ID of the message to reply to", | ||
default="", | ||
) | ||
parser.add_argument( | ||
"-cid", | ||
"--channel_id", | ||
type=str, | ||
help="ID of the channel to send the message to", | ||
default="", | ||
) | ||
parser.add_argument( | ||
"-c", | ||
"--channel", | ||
type=lambda channel: ChannelID[channel], | ||
choices=list(ChannelID), | ||
help="Channel to send the message to", | ||
default=ChannelID.announcements, | ||
) | ||
parsed = parser.parse_args() | ||
message = parsed.message or get_piped_input() | ||
channel_id = parsed.channel_id or parsed.channel.value | ||
pinged_user_id = "everyone" if parsed.ping_everyone else parsed.pinged_user_id | ||
main( | ||
parsed.title, | ||
message, | ||
parsed.is_release_notes, | ||
pinged_user_id, | ||
parsed.message_reference_id, | ||
channel_id, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.