-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathigg_games.py
282 lines (251 loc) · 10.1 KB
/
igg_games.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
from io import TextIOWrapper
import multiprocessing
from urllib.parse import urlparse
from urllib.request import Request, urlopen
from bs4 import BeautifulSoup
import logging
# input: pe6NwpaZybKMxVIWuII7/GhwYiMtz8Ygcsb2toFWAKBYzvifFbWbp2gXV9m3MxqhHLJyX8uNlfLtAfIc9JdT9pgf4AGLMwOwqja2v8eodkEmttgDgiuSzPukxMs9L/kGzMbT5ilDBdiubggdmWjeVJi0NjyWrj35VoZZKJLeDeYARU3hPlLyPAFLqiVg+5dGiipi9TzZT2wF/lqoKSh45kWSaQ4U==
# output: https://bluemediafiles.com/get-url.php?url=EdevaqOMG4g9d9IALluXJHqMmVgpWFizBAFtbcYzMYh/IuIxKyaw6pSPkM9/GMTiDdugdWeJ0jWj5oZJeeAUhlyALig5GiiTZ2FloS4kSQU=
def bluemediafiles_decodeKey(encoded: str):
key = ''
i = int(len(encoded) / 2 - 5)
# i = i - 2
while i >= 0:
key += encoded[i]
i = i - 2
i = int(len(encoded) / 2 + 4)
# i = i - 2
while i < len(encoded):
key += encoded[i]
i = i + 2
return key
def remove_values_from_list(the_list, val):
return [value for value in the_list if value != val]
# https://repack-games.com/page/2/
def repack_games(log_file: TextIOWrapper, conn, pageNum: int):
r = Request("https://repack-games.com/page/{0}/".format(
pageNum), headers={'User-Agent': 'Mozilla/5.0'})
html = urlopen(r).read()
bs = BeautifulSoup(html, "html.parser")
articles = bs.findAll("ul", class_="modern-articles")
for article in articles:
result = str(article).find("https://repack-games.com/")
if result != -1:
print(str(article)[result:])
# Scrape Meta data, and Games from IGG-Games,
# Then upload the result to database.
def scrape_igg(pageNum: int):
page = [dict, list]
r = Request(
'https://igg-games.com/page/{0}'.format(pageNum), headers={'User-Agent': 'Mozilla/5.0'})
html = urlopen(r).read()
bs = BeautifulSoup(html, "html.parser")
nameList = bs.findAll('article')
# <article
# <meta Name
# <meta Uploader
# <meta Timestamp
# <meta Publisher
# <div Image
# <h2 Download Link
# <p Genre
for name in nameList:
logging.debug(name.get_text())
ls = []
for a in name:
# .replace("\\", "").replace(",","").replace("'", "").replace('"',"").replace("<","").replace(">","")
ls.append(str(a))
game_links = igg_games_scrape_game(str(ls[11]))
ls[1] = ls[1].replace('<meta content="', "").replace(
' Free Download" property="name"/>', "")
# ALl are posted by admin lol.
name = ls[1]
page.append((game_links, ls))
logging.debug('__________________________________________________')
continue
conn.execute("INSERT INTO game_entry VALUES(?,?,?,?,?,?,?,?)",
(name, ls[3], ls[5].replace('<meta content="', "").replace('" property="dateModified"/>', ""), ls[7], ls[9], ls[11], ls[13], ls[15]))
conn.execute("INSERT OR REPLACE INTO game_links(name,megaup_net,mega_nz,fichier1_com,gofile_io,anonFiles_com,rapidgator_net,uptobox_com,clicknupload_to,pixeldrain_com,torrent) VALUES(?,?,?,?,?,?,?,?,?,?,?)", (
name,
'|'.join(game_links["megaup_net"], ),
'|'.join(game_links["mega_nz"]),
'|'.join(game_links["fichier1_com"]),
'|'.join(game_links["gofile_io"]),
'|'.join(game_links["anonFiles_com"]),
'|'.join(game_links["rapidgator_net"]),
'|'.join(game_links["uptobox_com"]),
'|'.join(game_links["clicknupload_to"]),
'|'.join(game_links["pixeldrain_com"]),
'|'.join(game_links["torrent"])))
conn.commit()
log_file.write('__________________________________________________')
return page
def insert_page_into_db(conn, page):
for item in page[2:]:
game_links = item[0]
ls = item[1]
conn.execute("INSERT INTO game_entry VALUES(?,?,?,?,?,?,?,?)",
(ls[1], ls[3], ls[5].replace('<meta content="', "").replace('" property="dateModified"/>', ""), ls[7], ls[9], ls[11], ls[13], ls[15]))
conn.execute("INSERT OR REPLACE INTO game_links(name,megaup_net,mega_nz,fichier1_com,gofile_io,anonFiles_com,rapidgator_net,uptobox_com,clicknupload_to,pixeldrain_com,torrent) VALUES(?,?,?,?,?,?,?,?,?,?,?)", (
ls[1],
'|'.join(game_links["megaup_net"], ),
'|'.join(game_links["mega_nz"]),
'|'.join(game_links["fichier1_com"]),
'|'.join(game_links["gofile_io"]),
'|'.join(game_links["anonFiles_com"]),
'|'.join(game_links["rapidgator_net"]),
'|'.join(game_links["uptobox_com"]),
'|'.join(game_links["clicknupload_to"]),
'|'.join(game_links["pixeldrain_com"]),
'|'.join(game_links["torrent"])))
conn.commit()
# Download links
# Translate web address to programmatically string
# megaup_net
# mega_nz
# fichier1_com
# gofile_io
# anonFiles_com
# rapidgator_net
# uptobox_com
# clicknupload_to
# pixeldrain_com
# torrent
def website_translate(link: str):
if link.find("megaup.net") != -1:
return "megaup_net"
if link.find("mega.nz") != -1:
return "mega_nz"
if link.find("1fichier.com") != -1:
return "fichier1_com"
if link.find("gofile.io") != -1:
return "gofile_io"
if link.find("anonfiles.com") != -1:
return "anonFiles_com"
if link.find("rapidgator.net") != -1:
return "rapidgator_net"
if link.find("uptobox.com") != -1:
return "uptobox_com"
if link.find("clicknupload.to") != -1:
return "clicknupload_to"
if link.find("pixeldrain.com") != -1:
return "pixeldrain_com"
if link.find("magnet:?xt") != -1:
return "torrent"
raise Exception("link does not have a supported source: {0}".format(link))
# Link TusFiles
# link Openload.co
DownloadLinksList = [
"megaup_net",
"mega_nz",
"fichier1_com",
"gofile_io",
"anonFiles_com",
"rapidgator_net",
"uptobox_com",
"clicknupload_to",
"pixeldrain_com",
"torrent"
]
def all_equal(iterator):
iterator = iter(iterator)
try:
first = next(iterator)
except StopIteration:
return True
return all(first == x for x in iterator)
def igg_games_scrape_game(game: str):
DownloadLinks = dict.fromkeys(DownloadLinksList, [])
# Need to read label to get source because it's different.
start = game.find("https://igg-games")
end = game.find('">', start)
d = game[start:end]
r = Request(d, headers={'User-Agent': 'Mozilla/5.0'})
html = urlopen(r).read()
bs = BeautifulSoup(html, "html.parser")
links = []
index = 0
part_int = 1
# normal links, bluemedia files only
for link in bs.find_all("a", href=lambda href: href and "https://bluemediafiles.homes/url-generator.php?url=" in href):
lk = str(link)
start = lk.find(
"https://bluemediafiles.homes/url-generator.php?url=")
end = lk.find('"', start)
htt = lk[start:end]
# <a href="https://bluemediafiles.homes/url-generator.php?url=KH1TK0eBXmDmljELeo4C+Bzvk/di79ViuP78lQFtN7JFlyd8S5KXVbQo1OqNmvQpUwXoGXWsOLLwAUGYifbWDA==" rel="noopener" target="_blank">Download HERE</a>
links.append(htt)
logging.debug(htt)
argslist = ((link, DownloadLinks) for link in links)
with multiprocessing.Pool(len(links)) as pool:
results = pool.map(scrape_bluemedia, links)
for l in results:
if l is None:
# Web Request Error 404 most likely, just continue.
continue
finalLink = str(l)
ls = DownloadLinks[website_translate(finalLink)]
if len(ls) == 0:
DownloadLinks[website_translate(finalLink)] = [finalLink]
else:
DownloadLinks[website_translate(finalLink)].append(finalLink)
# with concurrent.futures.ProcessPoolExecutor() as executor:
# DownloadLinks = executor.map(scrape_bluemedia_thunk, argslist)
# torrent link
for link in bs.find_all("a", href=lambda href: href and ("pcgamestorrents.com" or "pcgamestorrents.org") in href):
# https://pcgamestorrents.com
# http://dl.pcgamestorrents.org
# Always seems to have "Torrent Link" in text with property.
# get url from string
lk = str(link)
start = lk.find("https")
temp = lk[start:]
ends = []
ends.append(temp.find('" target='))
ends.append(temp.find('" rel'))
ends.sort()
ends = remove_values_from_list(ends, -1)
# check path of url
url = urlparse(temp[:ends[0]])
if url.path == ("/" or ""):
continue
logging.debug("Torrent: " + url.geturl())
DownloadLinks["torrent"] = [url.geturl()]
return DownloadLinks
# Returns the link from blue media
def scrape_bluemedia_thunk(link: str, DownloadLinks):
finalLink = str(scrape_bluemedia(link))
ls = DownloadLinks[website_translate(finalLink)]
if len(ls) == 0:
DownloadLinks[website_translate(finalLink)] = [finalLink]
else:
DownloadLinks[website_translate(finalLink)].append(finalLink)
return DownloadLinks
def scrape_bluemedia(link):
r = Request(link, headers={'User-Agent': 'Mozilla/5.0'})
url = None
try:
html = urlopen(r).read()
bs = BeautifulSoup(html, "html.parser")
for lin in bs.find_all("script"):
s = str(lin)
start = s.find('Goroi_n_Create_Button("')
if start != -1: # Found it
end = s.find(")", start)
if end > start:
encode = s[start + len('Goroi_n_Create_Button("'):end - 1]
lin = "https://bluemediafiles.com/get-url.php?url=" + \
bluemediafiles_decodeKey(encode)
req = Request(lin, headers={'User-Agent': 'Mozilla/5.0'})
try:
url = urlopen(req).geturl()
except:
return None
finally:
return url
else:
raise Exception("Error parsing Goroi_n_Create_Button")
except:
return None
finally:
return url