-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathimge.py
More file actions
127 lines (124 loc) · 3.31 KB
/
imge.py
File metadata and controls
127 lines (124 loc) · 3.31 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
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
#!/usr/bin/env python3
import requests,re,threading
from bs4 import BeautifulSoup
from queue import Queue
from optparse import OptionParser
from os import chdir,path
from core import *
q = Queue()
__author__ = 'Khaled Nassar'
__link__ = 'https://github.com/knassar702/imge'
print(r'''
{red}
(_)_ _ ___ ____
/ / ' \/ _ `/ -_)
/_/_/_/_/\_, /\__/
/___/
{yellow}
[Credits : Khaled Nassar @knassar702]
{end}'''.format(red=red,yellow=yellow,end=end))
lefunny = lefunny()
imgflip = imgflip()
q = Queue()
w = Queue()
# options
optp = OptionParser(add_help_option=False)
optp.add_option("-t","--threads",dest="thr",type='int')
optp.add_option("-f","--file",dest="file")
optp.add_option("-h","--help",dest="help",action='store_true')
optp.add_option("-p","--page",dest="page",type='int')
optp.add_option("-l","--list",dest="the_list",action='store_true')
optp.add_option("-n","--number",dest="_number",type='int')
optp.add_option("-d","--dump",dest="_dump",action='store_true')
optp.add_option("-D","--Dump",dest="_Dump",action='store_true')
opts, args = optp.parse_args()
if opts.help:
print('''
-h,--help | Show help message and exit
-t,--threads | Max number of concurrent requests (default: 10)
-f,--file | Saving in Custom Path (--file='image_file')
-p,--page | number of website pages
-d,--dump | Dump Links Without Download
-l,--list | Dump all lists
-D,--Dump | Dump Links With Download it
-n,--number | Number of item (-n=21)
''')
exit()
if opts._dump:
_dump = True
else:
_dump = None
if opts._Dump:
_Dump = True
else:
_Dump = None
if _Dump == True and _dump == True:
print(f'{yellow}[{red}ERROR{yellow}]{end} You Can"t User --Dump option and --dump in the same time ..!')
exit()
if opts.page:
page = opts.page
else:
page = 100
if opts.file:
file = opts.file
if path.exists(file):
chdir(file)
else:
print(f'{yellow}[{red}ERROR{yellow}]{end} File Not Found')
exit()
else:
file = None
if opts._number:
lefunny.dump_list()
_number = opts._number
if _number > 41:
print(f'{yellow}[{red}ERROR{yellow}]{end} Number out of Range')
exit()
the_link = lefunny.dump_list()[_number][1]
if opts.the_list:
for n,w in lefunny.dump_list().items():
print(f'[{n}] {w[0]}')
exit()
if opts.thr:
thr = opts.thr
else:
thr = 10
if opts._number == None:
print('''
-h,--help | Show help message and exit
-t,--threads | Max number of concurrent requests (default: 10)
-f,--file | Saving in Custom Path (--file='image_file')
-p,--page | number of website pages
-d,--dump | Dump Links Without Download
-l,--list | Dump all lists
-D,--Dump | Dump Links With Download it
-n,--number | Number of item (-n=21)
''')
exit()
def threader_lefunny():
while True:
item = q.get()
lefunny.get(item,the_link,dump=_dump,Dump=_Dump)
q.task_done()
def threader_imgflip():
while True:
item2 = w.get()
imgflip.get_memes(item2,dump=_dump,Dump=_Dump)
w.task_done()
if __name__ == '__main__':
for i in range(thr):
p1 = threading.Thread(target=threader_lefunny)
p1.daemon = True
p1.start()
if opts._number == 12:
p2 = threading.Thread(target=threader_imgflip)
p2.daemon = True
p2.start()
for i in range(page):
q.put(i)
if opts._number == 12: w.put(i)
try:
q.join()
if opts._number == 12: w.join()
except KeyboardInterrupt:
print(f'\n{info} Good Bye\n')