-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcerberus.py
executable file
·155 lines (135 loc) · 6.03 KB
/
cerberus.py
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#!/usr/bin/env python
# Cerberus, Torrent Aggregator
# Copyright (C) 2022 th3r00t
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
import asyncio
import argparse
import locale
import time
import curses
from lib.Torrent import Client
from lib.Display import Display
from lib.Config import Config
from lib.Search import Search
locale.setlocale(locale.LC_ALL, '')
icode = locale.getpreferredencoding()
state = 0
keypress = None
config = Config()
magnets = []
run = True
Cerberus = {
'Config': config,
'TorrentManager': Client(config.storagemaps),
'Display': Display(),
'Search': Search(config.endpoints)
}
Cerberus["Config"].getconfig()
logo = """
: .:: ^ ~~!7777??????????777!!~^: . .: :
. ^J~ .J?~^!!~^^::............::^~~!!^!J! .77 .
::^.^!7^~J~??^ :!J!7J.7~? ^::.
.~7J?~^.!.:^77: 7!?~. ..::. :!77~ ~J^~ !^.~7J?!^.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Y?^~!?Y55PY^!J~~:7~::.^~7!7!:. .:^^~^^^!?55Y7?!!
.7?~!??!!~: :.~7JJ!^::^.:.!?!. 7Y77555G5Y7^7YY~~?YPGY5J7?Y~ ^7J::::^::~?Y?!::. .~~!7?7~!J^.
.:!^?P^ :::7?JYY?7~: :Y7 ^:??~~~^!~^^?Y7~~?YJ7~!JY!^^!~~^!!J!:: .J7 .^!7JYJJ7!.^ ?P~~~..
:: :J7?77?J!. ^Y?. .:77!7~ :!557!JYY7!JP?~. :!7!?~. ^Y?. :?J77???7 :.
:^:~7!: .JY^ .~??~ ?J5GY?7??7J5GYY^ 7?7.. 75! ^!!^:^.
!57. .J?.?Y57~!777!!^5YY^^J! :YY:
:JY^ :7?^~7J77~~~!7?J!^!?~: .75!
~Y?: :7!.~7!~:..^!7!::?! ~YJ:
.7Y7. ~7^~^~777!^^~~7: ^JY~
:?Y7. .^!~^~!~^^7~:. ^JY!
:?Y7. ^^~7!^^: ^JY!.
:7Y7: ~JJ~.
.!YJ~ .!JJ^
~?J7:^?Y7:
:!J?~.
"""
def header_text():
return Text("=== Welcome To Cerberus ===",
justify="center",
style="bold magenta")
async def keybinds():
global state, run
key = Cerberus['Display'].stdscr.getch()
if key != -1:
if key == ord('q'):
Cerberus['Display'].kill()
run = False
elif key == ord('/'):
search = await Cerberus['Display'].search_prompt(Cerberus['Config'], Cerberus['TorrentManager'])
await asyncio.sleep(.2)
return False
async def application_loop():
global state
Cerberus['Display'].mkheader(),
Cerberus['Display'].mkfooter()
while run:
if state == 0:
Cerberus['Display'].mkheader(),
Cerberus['Display'].mkbody(Cerberus['TorrentManager'].Manage()),
Cerberus['Display'].mkfooter()
Cerberus['Display'].stdscr.refresh()
await keybinds()
await asyncio.sleep(.2)
if state == 1:
Cerberus['Display'].mkheader(),
Cerberus['Display'].mkbody(Cerberus['TorrentManager'].Manage()),
Cerberus['Display'].mkfooter()
Cerberus['Display'].stdscr.refresh()
await keybinds()
await asyncio.sleep(.2)
if state == 2:
Cerberus['Display'].mkheader(),
Cerberus['Display'].mkbody(Cerberus['TorrentManager'].Manage()),
Cerberus['Display'].mkfooter()
Cerberus['Display'].stdscr.refresh()
await keybinds()
await asyncio.sleep(.2)
return "Finished"
async def main():
"""Enter The Realm Of Cerberus."""
global Cerberus
parser = argparse.ArgumentParser()
parser.add_argument("-c", "--config")
parser.add_argument("-s", "--search")
args = parser.parse_args()
if args.config:
print(f"Config {args.config}.")
elif args.search:
_response = Cerberus['Search'].search(args.search)
for _r in _response:
print(_r.text)
else:
await application_loop()
await asyncio.sleep(.2)
print()
return False
if __name__ == "__main__":
asyncio.run(main())
# Cerberus['Display'].kill()