Skip to content

Commit

Permalink
feat: support btf cli tool
Browse files Browse the repository at this point in the history
  • Loading branch information
Tohrusky committed Dec 22, 2024
1 parent 5bbe47a commit ecc8940
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 14 deletions.
29 changes: 28 additions & 1 deletion animepipeline/cli/btf/__main__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,40 @@
import argparse
from pathlib import Path

from animepipeline.template import PostTemplate

parser = argparse.ArgumentParser(description="Generate all post info files for the anime.")

# Input Path
parser.add_argument("-p", "--PATH", help="Path to the video file", required=True)
# Bangumi URL
parser.add_argument("-b", "--BANGUMI", help="Bangumi URL", required=True)
# Chinese Name
parser.add_argument("-n", "--NAME", help="Chinese name", required=False)
# Uploader Name
parser.add_argument("-u", "--UPLOADER", help="Uploader name", required=False)

args = parser.parse_args()


def main() -> None:
pass
if args.UPLOADER is None:
args.UPLOADER = "TensoRaws"

path = Path(args.PATH)

post_template = PostTemplate(
video_path=path,
bangumi_url=args.BANGUMI,
chinese_name=args.NAME,
uploader=args.UPLOADER,
)

post_template.save(
html_path=path.parent / (path.name + ".html"),
markdown_path=path.parent / (path.name + ".md"),
bbcode_path=path.parent / (path.name + ".txt"),
)


if __name__ == "__main__":
Expand Down
1 change: 1 addition & 0 deletions animepipeline/cli/rename/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def main() -> None:

if args.UPLOADER is None:
args.UPLOADER = "TensoRaws"

path = Path(args.PATH)

if args.TYPE is None:
Expand Down
27 changes: 14 additions & 13 deletions animepipeline/loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,19 @@ async def pipeline_post(self, task_info: TaskInfo) -> None:

self.qbittorrent_manager.add_torrent(torrent_hash=torrent_file_hash, torrent_file_path=torrent_file_save_path)

logger.info(f"Post to Telegram Channel for {task_info.name} EP {task_info.episode} ...")

if self.tg_channel_sender is None:
logger.info("Telegram Channel Sender is not enabled. Skip upload.")
else:
tg_text = get_telegram_text(
chinese_name=task_info.translation,
episode=task_info.episode,
file_name=finalrip_downloaded_path.name,
torrent_file_hash=torrent_file_hash,
)
await self.tg_channel_sender.send_text(text=tg_text)

logger.info(f"Generate all post info files for {task_info.name} EP {task_info.episode} ...")

post_template = PostTemplate(
Expand All @@ -279,18 +292,6 @@ async def pipeline_post(self, task_info: TaskInfo) -> None:
bbcode_path=Path(task_info.download_path) / (finalrip_downloaded_path.name + ".txt"),
)

logger.info(f"Post to Telegram Channel for {task_info.name} EP {task_info.episode} ...")

if self.tg_channel_sender is None:
logger.info("Telegram Channel Sender is not enabled. Skip upload.")
else:
tg_text = get_telegram_text(
chinese_name=task_info.translation,
episode=task_info.episode,
file_name=finalrip_downloaded_path.name,
torrent_file_hash=torrent_file_hash,
)
await self.tg_channel_sender.send_text(text=tg_text)

# update task status
task_status.posted = True
await self.json_store.update_task(task_info.hash, task_status)

0 comments on commit ecc8940

Please sign in to comment.