Skip to content

Commit

Permalink
fix: change torrent complete condition
Browse files Browse the repository at this point in the history
  • Loading branch information
verdel committed Apr 24, 2024
1 parent 286c140 commit 6ee0268
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "torrent-telegram-bot"
version = "0.1.3"
version = "0.1.4"
description = ""
authors = ["Vadim Aleksandrov <[email protected]>"]
readme = "README.md"
Expand Down
2 changes: 1 addition & 1 deletion torrent_telegram_bot/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.1.3"
__version__ = "0.1.4"
11 changes: 7 additions & 4 deletions torrent_telegram_bot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from pathlib import Path
from textwrap import dedent
from typing import Coroutine
from zoneinfo import ZoneInfo

import sentry_sdk
from emoji import emojize
Expand Down Expand Up @@ -297,7 +298,9 @@ async def list_torrent_action(update, context, **kwargs):
if len(torrents) > 0:
try:
for torrent in torrents:
if torrent.done_date is None or torrent.done_date == datetime.fromtimestamp(0):
if torrent.done_date is None or torrent.done_date == datetime.fromtimestamp(0, ZoneInfo("UTC")).replace(
tzinfo=None
):
try:
eta = str(torrent.eta)
except ValueError:
Expand All @@ -319,7 +322,7 @@ async def list_torrent_action(update, context, **kwargs):
Status: {torrent.status}
Speed: {tools.humanize_bytes(torrent.upload_speed)}/s
Peers: {torrent.num_seeds_upload}
Ratio: {torrent.ratio}
Ratio: {round(torrent.ratio, 2)}
"""
)
await context.bot.send_message(
Expand Down Expand Up @@ -429,7 +432,7 @@ async def check_torrent_download_status(context): # noqa: C901
if (
task is not None
and task.done_date is not None
and task.done_date != datetime.fromtimestamp(0)
and task.done_date != datetime.fromtimestamp(0, ZoneInfo("UTC")).replace(tzinfo=None)
):
await db.complete_torrent(torrent[1])
except Exception as exc:
Expand All @@ -438,7 +441,7 @@ async def check_torrent_download_status(context): # noqa: C901
if (
task is not None
and task.done_date is not None
and task.done_date != datetime.fromtimestamp(0)
and task.done_date != datetime.fromtimestamp(0, ZoneInfo("UTC")).replace(tzinfo=None)
):
response = f'Torrent "*{task.name}*" was successfully downloaded'
try:
Expand Down

0 comments on commit 6ee0268

Please sign in to comment.