Repository navigation
Expand file tree
/
Copy pathSafelinkingNet.py
More file actions
81 lines (61 loc) · 2.8 KB
/
Copy pathSafelinkingNet.py
File metadata and controls
81 lines (61 loc) · 2.8 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
# -*- coding: utf-8 -*-
import re
import BeautifulSoup
from pyload.utils import json_loads
from pyload.plugin.Crypter import Crypter
from pyload.plugin.captcha.SolveMedia import SolveMedia
class SafelinkingNet(Crypter):
__name = "SafelinkingNet"
__type = "crypter"
__version = "0.14"
__pattern = r'https?://(?:www\.)?safelinking\.net/([pd])/\w+'
__config = [("use_subfolder" , "bool", "Save package to subfolder" , True),
("subfolder_per_pack", "bool", "Create a subfolder for each package", True)]
__description = """Safelinking.net decrypter plugin"""
__license = "GPLv3"
__authors = [("quareevo", "quareevo@arcor.de")]
SOLVEMEDIA_PATTERN = "solvemediaApiKey = '([\w.-]+)';"
def decrypt(self, pyfile):
url = pyfile.url
if re.match(self.__pattern, url).group(1) == "d":
header = self.load(url, just_header=True)
if 'location' in header:
self.urls = [header['location']]
else:
self.error(_("Couldn't find forwarded Link"))
else:
postData = {"post-protect": "1"}
self.html = self.load(url)
if "link-password" in self.html:
postData['link-password'] = self.getPassword()
if "altcaptcha" in self.html:
for _i in xrange(5):
m = re.search(self.SOLVEMEDIA_PATTERN, self.html)
if m:
captchaKey = m.group(1)
captcha = SolveMedia(self)
captchaProvider = "Solvemedia"
else:
self.fail(_("Error parsing captcha"))
response, challenge = captcha.challenge(captchaKey)
postData['adcopy_challenge'] = challenge
postData['adcopy_response'] = response
self.html = self.load(url, post=postData)
if "The password you entered was incorrect" in self.html:
self.fail(_("Incorrect Password"))
if not "The CAPTCHA code you entered was wrong" in self.html:
break
pyfile.package().password = ""
soup = BeautifulSoup.BeautifulSoup(self.html)
scripts = soup.findAll("script")
for s in scripts:
if "d_links" in s.text:
break
m = re.search('d_links":(\[.*?\])', s.text)
if m:
linkDict = json_loads(m.group(1))
for link in linkDict:
if not "http://" in link['full']:
self.urls.append("https://safelinking.net/d/" + link['full'])
else:
self.urls.append(link['full'])