-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfanboy.py
310 lines (284 loc) · 13.7 KB
/
fanboy.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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
# Fanboy Clubbed
# v2.11.0 20/05/2018
#
# fanboy Copyright (C) 2016 Tejaskumar Maru
#
# fanboy 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 3 of the License, or
# any later version.
#
import urllib.request
import bs4
import re
import time
import argparse
import os
import threading, queue
## Functions
# Albums
def getsite(url):
return url[:url.rfind('/')+1]
def whsite(url):
return re.findall('https?://w{0,3}\.{0,1}(.+?\.[a-z]+?)/',url.lower().strip())[0]
def mksoup(url):
print('#',url)
try:
html = urllib.request.urlopen(url).read()
return bs4.BeautifulSoup(html,'lxml')
except:
print(url)
return None
# Categories
def no_page(soup):
try:return int(soup.find(style="white-space: nowrap").text.split()[-2])
except:
if soup.find(style="white-space: nowrap") is None:return 1
else:return int(soup.find(style="white-space: nowrap").text.split()[-3])
def gather_links(soup):
for each in soup.find_all('span','catlink'):
cat=sites[site][1] + each.a.get('href')
if cat not in cats:cats.append(cat)
for each in soup.find_all('span','alblink'):
alb = sites[site][1] + each.a.get('href')
if alb not in albs:albs.append(alb)
def page(url):
global cats,albs,site
soup = mksoup(url)
if soup is None:print(url)
else:
site = whsite(url)
try:pages = no_page(soup)
except:pages = 1
gather_links(soup)
#print("!!",len(albs),url)
if pages > 1:
for i in range(2,pages + 1):
gather_links(mksoup(url+"&page="+str(i)))
#print("**",len(albs),url+"&page="+str(i))
# Main Flow Switches
def thread_fansite():
global images
while not qq.empty():
tmp = fansite(qq.get())
images = images + len(tmp.store)
def many_fansite():
global qq,cats,albs
while len(cats) > 0:
for each in cats:
page(each)
cats.remove(each)
albums = len(sorted(set(albs)))
qq = queue.Queue()
for each in sorted(albs):qq.put(each.strip())
for i in range(args.threads):
t = threading.Thread(target=thread_fansite)
threads.append(t)
t.start()
for t in threads:t.join()
return albums
def scrap(url):
global site,start_time,cats,albs
cats.clear()
albs.clear()
site = whsite(url)
if site not in sites.keys():
print("Fansite not supported.")
else:
if url.find("thumbnails.php?album") == -1:
page(url)
fans = many_fansite()
elapsed_time = time.strftime("%M:%S",time.gmtime(time.time()-start_time))
print("Found {} Albums and {} Images in {}".format(fans,images,elapsed_time))
else:
fan = fansite(url)
elapsed_time = time.strftime("%M:%S",time.gmtime(time.time()-start_time))
print("Album : {} ; {} links recovered in {} ".format(fan.title,len(fan.store),elapsed_time))
def file():
global fname
start_time = time.time()
for each in open(args.file,'r'):
if each.startswith('#'):continue
elif not each.startswith("http"):print("Invalid URL :",each)
elif whsite(each) not in sites.keys():print("Unsupported Site :",each)
else:
if each.find("thumbnails.php?album=") != -1:albs.append(each.strip())
else:cats.append(each.strip())
print(" {} Categories and {} Albums found. Getting Image Links ... ".format(len(cats),len(albs)))
fans = many_fansite()
elapsed_time = time.strftime("%M:%S",time.gmtime(time.time()-start_time))
print("Found {} Albums and {} Images in {}".format(fans,images,elapsed_time))
## Class Fansite
class fansite():
def __init__(self, url):
self.url = url
self.store = []
self.get_url()
self.soup = mksoup(self.album)
self.getinfo()
self.page(self.soup)
if self.no_page > 1:
for i in range(2,self.no_page+1):
self.page(mksoup(self.album+"&page="+str(i)))
self.write()
def page(self,soup):
if soup is not None:
for each in soup.find_all('img','image'):
thumb = re.findall('(.+/)thumb.+',each.get('src'))[0]
self.store.append(self.site_url + thumb + each.get('alt') )
def getinfo(self):
try: self.title = self.soup.find("span","statlink").text.strip()
except: self.title = self.soup.find("td","statlink").text.strip()
try:self.info = self.soup.find(style="white-space: nowrap").text
except:self.info = "0 Images"
self.no_page = int(self.info.split()[-2])
def get_url(self):
self.album = re.findall('(.+album=[0-9]+)',self.url)[0]
self.fname, self.site_url = sites[whsite(self.url)]
def write(self):
cref = []
if args.cross_ref is not None:fhand = open(args.cross_ref,'r')
# else:fhand = open(self.fname,'r')
# for each in fhand:
# if each.startswith('#'):continue
# cref.append(each.strip())
fhand = open(self.fname,'a')
fhand.write("### {} \n#!!! {} \n### {} \n".format(self.title,self.url,self.info))
for each in self.store:
if each not in cref:fhand.write(each+"\n")
fhand.close()
## Supported Sites and Info
sites = {
'goddessadriana.com':["AdrianaL", "http://goddessadriana.com/gallery/"],
'alexandra-daddario.org':["AlexandraD", "http://alexandra-daddario.org/photos/"],
'alexandradaddario.us':["AlexandraD", "http://alexandradaddario.us/photos/"],
'daddariofan.net':["AlexandraD", "http://daddariofan.net/gallery/"],
'anne-hathaway.net':["AnneH", "http://anne-hathaway.net/photos/"],
'anne-hathaway.org':["AnneH", "http://anne-hathaway.org/gallery/"],
'aheardfan.com':["AmberH", "http://www.aheardfan.com/photos/"],
'amberheardweb.org':["AmberH", "http://amberheardweb.org/gallery"],
'ashley-greene.nl':["AshleyG", "http://ashley-greene.nl/gallery"],
'ashleygreene.org':["AshleyG", "http://ashleygreene.org/images/"],
'ashleygreenefans.org':["AshleyG", "http://ashleygreenefans.org/gallery/"],
'barrefaelionline.com':["BarR", "http://gallery.barrefaelionline.com/"],
'b-palvin.net':["BarbaraP", "http://b-palvin.net/gallery/"],
'barbara-palvin.sosugary.org':["BarbaraP", "http://barbara-palvin.sosugary.org/"],
'behati-prinsloo.us':["BehatiP", "http://behati-prinsloo.us/gallery/"],
'bella-hadid.fans.bz':["BellaH", "http://bella-hadid.fans.bz/gallery/"],
'bellahadid.org':["BellaH", "http://bellahadid.org/gallery/"],
'bellahadid.sosugary.org':["BellaH", "http://bellahadid.sosugary.org/"],
'bella-images.org':["BellaT", "http://bella-images.org/"],
'bella-thorne.com':["BellaT", "http://bella-thorne.com/gallery/"],
'bellathornefrance.net':["BellaT", "http://bellathornefrance.net/Photos/"],
'bella-thorne.org':["BellaT", "http://bella-thorne.org/gallery/"],
'bellathorne.net':["BellaT", "http://www.bellathorne.net/photos/"],
'beyonceonline.org':["Beyonce", "http://beyonceonline.org/gallery/"],
'divinecandice.com':["CandiceS", "http://divinecandice.com/photos/"],
'candiceswanepoel.com.br':["CandiceS", "http://candiceswanepoel.com.br/galeria/"],
'swanepoel-candice.com':["CandiceS", "http://swanepoel-candice.com/pictures/"],
'cara-delevingne.org':["CaraD", "http://cara-delevingne.org/gallery/"],
'cara-delevingne.com':["CaraD", "http://www.cara-delevingne.com/photos/"],
'charlizecentral.com':["CharlizeT", "http://charlizecentral.com/gallery/"],
'deborahannwoll.org':["DeborahAW", "http://deborahannwoll.org/photos/"],
'doutzenkfanpage.com':["DoutzenK", "http://www.doutzenkfanpage.com/gallery/"],
'emilydidonatosource.com':["EmilyD", "https://emilydidonatosource.com/gallery/"],
'iheartwatson.net':["EmmaW", "http://iheartwatson.net/gallery/"],
'emmaw.net':["EmmaW", "http://emmaw.net/gallery/"],
'emma-watson-fan.org':["EmmaW", "http://emma-watson-fan.org/gallery/"],
'emmawatson.us':["EmmaW", "http://emmawatson.us/gallery/"],
'emilia-clarke.com':["EmiliaC", "http://emilia-clarke.com/gallery/"],
'emilia-clarke.net':["EmiliaC", "http://emilia-clarke.net/gallery/"],
'emiliaclarkefan.net':["EmiliaC", "http://emiliaclarkefan.net/gallery/"],
'emily-blunt.net':["EmilyB", "http://www.emily-blunt.net/gallery/"],
'emilyblunt.net':["EmilyB", "http://emilyblunt.net/gallery/"],
'eblunt.org':["EmilyB", "http://eblunt.org/photos/"],
'elizabeth-gillies.net':["ElizabethG", "http://www.elizabeth-gillies.net/gallery/"],
'hoskelsa.com':["ElsaH", "http://hoskelsa.com/photos/"],
'evagreenweb.com':["EvaG", "http://evagreenweb.com/gallery/"],
'evangeline-l.us':["Evangeline", "http://evangeline-l.us/gallery/"],
'evangelinelilly.org':["Evangeline", "http://evangelinelilly.org/gallery/"],
'gal-gadot.com':["GalG", "http://gal-gadot.com/gallery/"],
'gal-gadot.net':["GalG", "http://gal-gadot.net/photos/"],
'gadot-gal.com':["GalG", "http://gadot-gal.com/photos/"],
'g-gadot.com':["GalG", "http://g-gadot.com/gallery/"],
'gemma-arterton.net':["GemmaA", "http://gemma-arterton.net/media/"],
'g-arterton.net':["GemmaA", "http://g-arterton.net/galeria/"],
'gigi-hadid.org':["GigiH", "http://gigi-hadid.org/gallery/"],
'gigi-hadid.net':["GigiH", "http://gigi-hadid.net/photos/"],
'irinashaykphotos.com':["IrinaS", "http://irinashaykphotos.com/"],
'teamisabelifontana.com':["IsabeliF", "http://teamisabelifontana.com/gallery/"],
'jessica-biel.com':["JessicaB", "http://jessica-biel.com/gallery/"],
'jessica-chastain.com':["JessicaC", "http://jessica-chastain.com/gallery/"],
'jenniferlawrencedaily.com':["JenniferL", "http://jenniferlawrencedaily.com/gallery/"],
'juliannemooreweb.net':["JulianneM", "http://juliannemooreweb.net/gallery/"],
'julianne-moore.org':["JulianneM", "http://julianne-moore.org/photos/"],
'k-winnick.com':["KatherynW", "http://k-winnick.com/photos/"],
'kaya-scodelario.com':["KayaS", "http://kaya-scodelario.com/gallery/"],
'katheryn-winnick.net':["KatherunW", "http://katheryn-winnick.net/gallery/"],
'katheryn-winnick.org':["KatherynW", "http://katheryn-winnick.org/photos/"],
'kristenphotos.org':["KristenS", "http://www.kristenphotos.org/"],
'kristensdaily.net':["KristenS", "http://kristensdaily.net/gallery/"],
'kristenstewartdaily.com':["KristenS", "http://kristenstewartdaily.com/gallery/"],
'lili-simmons.net':["LiliS", "http://lili-simmons.net/photos/"],
'livtylerfan.org':["LivT", "http://www.livtylerfan.org/vault/"],
'margotsource.net':["MargotR", "http://margotsource.net/gallery/"],
'margoteliserobbie.com':["MargotR", "http://margoteliserobbie.com/gallery/"],
'margot-robbie.us':["MargotR", "http://margot-robbie.us/photos/"],
'margot-robbie.org':["MargotR", "http://margot-robbie.org/gallery/"],
'margotrobbieonline.com':["MargotR", "http://margotrobbieonline.com/gallery/"],
'm-robbie.org':["MargotR", "http://m-robbie.org/gallery/"],
'simplystreepmedia.com':["MerylS", "http://www.simplystreepmedia.com/gallery/"],
'megan-fox.com':["MeganF", "http://www.megan-fox.com/gallery/"],
'megan-fox.us':["MeganF", "http://megan-fox.us/pix/"],
'morena-baccarin.net':["MorenaB", "http://gallery.morena-baccarin.net/"],
'natalie-dormer.org':["NatalieD", "http://natalie-dormer.org/gallery/"],
'nataliedormer.org':["NatalieD", "http://nataliedormer.org/gallery/"],
'natalie-dormer.com':["NatalieD", "http://natalie-dormer.com/gallery/"],
'noomi-rapace.com':["NoomiR", "http://www.noomi-rapace.com/gallery/"],
'peyton-list.net':["PeytonL", "http://peyton-list.net/photos/"],
'rachelweiszonline.net':["RachelW", "http://gallery.rachelweiszonline.net/"],
'pictures.rosie-huntington-whiteley.com':["RosieHW", "http://pictures.rosie-huntington-whiteley.com/"],
'sampaiopictures.com':["SaraS", "http://sampaiopictures.com/"],
'scarlett-photos.org':["ScarlettJ", "http://scarlett-photos.org/"],
'scarlett-johansson.net':["ScarlettJ", "http://scarlett-johansson.net/gallery/"],
'selenapictures.org':["SelenaG", "http://selenapictures.org/"],
'shailene-woodley.org':["ShaileneW", "http://shailene-woodley.org/gallery/"],
'sophieturner.org':["SophieT", "http://sophieturner.org/gallery/"],
'sophie-turner.us':["SophieT", "http://sophie-turner.us/gallery/"],
'taylorpictures.net':["TaylorS", "http://www.taylorpictures.net/"],
'tonicollette.org':["ToniC", "http://www.tonicollette.org/gallery/"],
'w-holland.org':["WillaH", "http://w-holland.org/photos/"],
'hq-pictures.com':["HQPICS", "http://hq-pictures.com/"],
'hqcelebrity.org':["HQCELEB", "http://hqcelebrity.org/"],
'chris-evans.org':["ChrisE", "http://chris-evans.org/photos/"],
'chrisevansweb.net':["ChrisE", "http://chrisevansweb.net/gallery/"],
'chris-hemsworth.net':["ChrisH", "http://chris-hemsworth.net/gallery/"],
'chrishemsworth.us':["ChrisH", "http://www.chrishemsworth.us/gallery/"],
'hugh-fan.com':["HughJ", "http://hugh-fan.com/photos/"],
'liam-hemsworth.org':["LiamH", "http://liam-hemsworth.org/gallery/"],
'liamhemsworth.org':["LiamH", "http://liamhemsworth.org/gallery/"]}
## Variables
cats = []
albs = []
threads = []
images = 0
DEBUG = False
## Argument Parser
parser = argparse.ArgumentParser(description='FANBOY')
parser.add_argument('--file', dest='file', type = str, default = None, required = False,
help='The file containing list of album links')
parser.add_argument('--cross', dest='cross_ref', type = str, default = None, required = False,
help='The file to cross reference with')
parser.add_argument('--threads', dest='threads', type = int, default = 5, required = False,
help='No of threads to use')
args = parser.parse_args()
## Main Path
if args.file is None:
while True:
iurl = input("Enter the Album Url : ")
start_time = time.time()
if iurl.startswith('#'):break
elif iurl.startswith("http"):scrap(iurl)
else:print("Is this a URL?\n Enter # to exit.")
else:file()
# END