Skip to content

Commit

Permalink
Merge pull request #287 from Dineshkarthik/fix/v2-minor-fixes
Browse files Browse the repository at this point in the history
Fixes for Bugs introduced in V2.0.0
  • Loading branch information
Dineshkarthik authored Jul 20, 2022
2 parents 07cd9ae + 90ac5bd commit f2ffe14
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 17 deletions.
6 changes: 2 additions & 4 deletions media_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import asyncio
import logging
import os
from datetime import datetime as dt
from typing import List, Optional, Tuple, Union

import pyrogram
Expand Down Expand Up @@ -123,7 +122,7 @@ async def _get_media_meta(
_type,
"{}_{}.{}".format(
_type,
dt.utcfromtimestamp(media_obj.date).isoformat(), # type: ignore
media_obj.date.isoformat(), # type: ignore
file_format,
),
)
Expand Down Expand Up @@ -311,8 +310,7 @@ async def begin_import(config: dict, pagination_limit: int) -> dict:
await client.start()
last_read_message_id: int = config["last_read_message_id"]
messages_iter = client.get_chat_history(
config["chat_id"],
offset_id=last_read_message_id,
config["chat_id"], offset_id=last_read_message_id, reverse=True
)
messages_list: list = []
pagination_count: int = 0
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Pyrogram==2.0.33
https://github.com/Dineshkarthik/pyrogram/archive/refs/heads/master.zip
PyYAML==6.0
rich==12.5.1
TgCrypto==1.2.3
15 changes: 7 additions & 8 deletions tests/test_media_downloader.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
"""Unittest module for media downloader."""
import asyncio
import copy
import logging
import os
import platform
import unittest
from datetime import datetime

import mock
import pyrogram
import pytest

from media_downloader import (
_can_download,
Expand Down Expand Up @@ -158,7 +157,7 @@ async def get_chat_history(self, *args, **kwargs):
media=True,
voice=MockVoice(
mime_type="audio/ogg",
date=1564066430,
date=datetime(2019, 7, 25, 14, 53, 50),
),
),
MockMessage(
Expand Down Expand Up @@ -239,7 +238,7 @@ def test_get_media_meta(self):
media=True,
voice=MockVoice(
mime_type="audio/ogg",
date=1564066430,
date=datetime(2019, 7, 25, 14, 53, 50),
),
)
result = self.loop.run_until_complete(
Expand All @@ -260,7 +259,7 @@ def test_get_media_meta(self):
message = MockMessage(
id=2,
media=True,
photo=MockPhoto(date=1565015712),
photo=MockPhoto(date=datetime(2019, 8, 5, 14, 35, 12)),
)
result = self.loop.run_until_complete(
async_get_media_meta(message.photo, "photo")
Expand Down Expand Up @@ -338,7 +337,7 @@ def test_get_media_meta(self):
media=True,
video_note=MockVideoNote(
mime_type="video/mp4",
date=1564066430,
date=datetime(2019, 7, 25, 14, 53, 50),
),
)
result = self.loop.run_until_complete(
Expand Down Expand Up @@ -513,7 +512,7 @@ def test_process_message(self):
media=True,
voice=MockVoice(
mime_type="audio/ogg",
date=1564066340,
date=datetime(2019, 7, 25, 14, 53, 50),
),
),
MockMessage(
Expand Down Expand Up @@ -554,7 +553,7 @@ def test_process_message_when_file_exists(self, mock_is_exist):
media=True,
voice=MockVoice(
mime_type="audio/ogg",
date=1564066340,
date=datetime(2019, 7, 25, 14, 53, 50),
),
),
MockMessage(
Expand Down
4 changes: 2 additions & 2 deletions tests/utils/test_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ def __init__(self, **kwargs):

class MetaTestCase(unittest.TestCase):
def test_log_filter(self):
result = LogFilter().filter(MockLog(funcName="send"))
result = LogFilter().filter(MockLog(funcName="invoke"))
self.assertEqual(result, False)

result1 = LogFilter().filter(MockLog(funcName="get_file"))
self.assertEqual(result1, False)
self.assertEqual(result1, True)

result2 = LogFilter().filter(MockLog(funcName="Synced"))
self.assertEqual(result2, True)
2 changes: 1 addition & 1 deletion utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Init namespace"""

__version__ = "2.0.0"
__version__ = "2.0.1"
__license__ = "MIT License"
__copyright__ = "Copyright (C) 2019 Dineshkarthik <https://github.com/Dineshkarthik>"
2 changes: 1 addition & 1 deletion utils/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ class LogFilter(logging.Filter):

# pylint: disable = W0221
def filter(self, record):
if record.funcName in ("send", "get_file"):
if record.funcName in ("invoke"):
return False
return True

0 comments on commit f2ffe14

Please sign in to comment.