This repository was archived by the owner on Dec 16, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
53 lines (39 loc) · 1.6 KB
/
main.py
File metadata and controls
53 lines (39 loc) · 1.6 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
from __future__ import absolute_import, print_function, unicode_literals
import sys
from ItemCollection import IsoHuntSearch, KickassSearch
from colorama import Fore, Style
from operator import attrgetter
def main():
if len(sys.argv) > 1:
query = ' '.join(sys.argv[1:])
search = search_results(query)
display_results(search)
else:
print ('Incorrect usage. Please use the format: hunt <search term>')
return
def search_results(query_string):
final_results = []
final_results.extend(IsoHuntSearch(query_string).results)
final_results.extend(KickassSearch(query_string).results)
sorted_results = sorted(final_results,
key=attrgetter('seeders'),
reverse=True)
return sorted_results[0:9]
def display_results(search_results):
for item in search_results:
print (Fore.RED + '---' + Fore.RESET)
stat_string = (Fore.MAGENTA + 'Size: '
+ Fore.RESET + item.filesize
+ Fore.BLUE + Style.DIM + ' - ' + Style.NORMAL
+ Fore.MAGENTA + 'Files: ' + Fore.RESET + item.files
+ Fore.BLUE + Style.DIM + ' - ' + Style.NORMAL
+ Fore.MAGENTA + 'S/L: '
+ Fore.RESET + str(item.seeders)
+ Fore.YELLOW + '/'
+ Fore.RESET + str(item.leechers))
print (Fore.GREEN + item.title)
print (stat_string)
print (Fore.BLUE + item.link)
print (Fore.RED + '---' + Fore.RESET)
if __name__ == '__main__':
main()