-
Notifications
You must be signed in to change notification settings - Fork 432
Expand file tree
/
Copy pathsub_thread.py
More file actions
55 lines (44 loc) · 1.52 KB
/
sub_thread.py
File metadata and controls
55 lines (44 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import threading
import time
import asyncio
from module.conf import settings
from module.downloader import DownloadClient
from module.manager import Renamer, eps_complete
from module.notification import PostNotification
from module.rss import RSSAnalyser, RSSEngine
from .status import ProgramStatus
class RSSThread(ProgramStatus):
def __init__(self):
super().__init__()
self._rss_loop = asyncio.new_event_loop()
self.analyser = RSSAnalyser()
async def rss_loop(self):
pass
class RenameThread(ProgramStatus):
def __init__(self):
super().__init__()
self._rename_thread = threading.Thread(
target=self.rename_loop,
)
def rename_loop(self):
while not self.stop_event.is_set():
with Renamer() as renamer:
renamed_info = renamer.rename()
if settings.notification.enable:
with PostNotification() as notifier:
for info in renamed_info:
notifier.send_msg(info)
time.sleep(2)
self.stop_event.wait(settings.program.rename_time)
def rename_start(self):
self.rename_thread.start()
def rename_stop(self):
if self._rename_thread.is_alive():
self._rename_thread.join()
@property
def rename_thread(self):
if not self._rename_thread.is_alive():
self._rename_thread = threading.Thread(
target=self.rename_loop,
)
return self._rename_thread