Skip to content

Commit 7eb4319

Browse files
committed
add support for archive.org (pyload#4151)
1 parent 8660636 commit 7eb4319

File tree

3 files changed

+125
-0
lines changed

3 files changed

+125
-0
lines changed
+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# -*- coding: utf-8 -*-
2+
3+
import json
4+
5+
from pyload.core.network.http.exceptions import BadHeader
6+
7+
from ..base.account import BaseAccount
8+
9+
10+
class ArchiveOrg(BaseAccount):
11+
__name__ = "ArchiveOrg"
12+
__type__ = "account"
13+
__version__ = "0.01"
14+
__status__ = "testing"
15+
16+
__description__ = """Archive.org account plugin"""
17+
__license__ = "GPLv3"
18+
__authors__ = [("GammaC0de", "nitzo2001[AT]yahoo[DOT]com")]
19+
20+
LOGIN_URL = "https://archive.org/account/login"
21+
LOGIN_CHECK_URL = "https://archive.org/account/index.php"
22+
23+
def grab_info(self, user, password, data):
24+
return {'validuntil': None,
25+
'trafficleft': None,
26+
'premium': False}
27+
28+
def signin(self, user, password, data):
29+
html = self.load(self.LOGIN_CHECK_URL)
30+
if "<title>cannot find account</title>" not in html:
31+
self.skip_login()
32+
33+
else:
34+
self.load(self.LOGIN_URL)
35+
try:
36+
html = self.load(self.LOGIN_URL, post={
37+
"username": user,
38+
"password": password,
39+
"remember": "true",
40+
"referer": "https://archive.org/",
41+
"login": "true",
42+
"submit_by_js": "true"
43+
})
44+
except BadHeader as exc:
45+
self.fail_login(str(exc))
46+
47+
else:
48+
json_data = json.loads(html)
49+
if json_data["status"] != "ok":
50+
self.fail_login()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# -*- coding: utf-8 -*-
2+
3+
import re
4+
5+
from ..base.decrypter import BaseDecrypter
6+
7+
8+
class ArchiveOrgFolder(BaseDecrypter):
9+
__name__ = "ArchiveOrgFolder"
10+
__type__ = "decrypter"
11+
__version__ = "0.01"
12+
__status__ = "testing"
13+
14+
__pattern__ = r"https?://(?:www\.)?archive\.org/details/.+"
15+
__config__ = [
16+
("enabled", "bool", "Activated", True),
17+
("use_premium", "bool", "Use premium account if available", True),
18+
(
19+
"folder_per_package",
20+
"Default;Yes;No",
21+
"Create folder for each package",
22+
"Default",
23+
),
24+
]
25+
26+
__description__ = """Archive.org decrypter plugin"""
27+
__license__ = "GPLv3"
28+
__authors__ = [("GammaC0de", "nitzo2001[AT]yahoo[DOT]com")]
29+
30+
LINK_PATTERN = r'<div><a href="(https://archive\.org/download/.+?)"'
31+
32+
NAME_PATTERN = r'itemprop="name">(.+?)<'
33+
34+
OFFLINE_PATTERN = r"Item cannot be found."
35+
TEMP_OFFLINE_PATTERN = r"^unmatchable$"
36+
37+
def decrypt(self, pyfile):
38+
self.data = self.load(pyfile.url)
39+
40+
m = re.search(self.NAME_PATTERN, self.data)
41+
if m is not None:
42+
name = m.group(1)
43+
else:
44+
name = pyfile.package().name
45+
46+
links = re.findall(self.LINK_PATTERN, self.data)
47+
self.packages = [(name, links, name)]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# -*- coding: utf-8 -*-
2+
3+
from ..base.simple_downloader import SimpleDownloader
4+
5+
6+
class ArchiveOrg(SimpleDownloader):
7+
__name__ = "ArchiveOrg"
8+
__type__ = "downloader"
9+
__version__ = "0.01"
10+
__status__ = "testing"
11+
12+
__pattern__ = r"https?://(?:www\.)?archive\.org/download/.+"
13+
__config__ = [
14+
("enabled", "bool", "Activated", True),
15+
("use_premium", "bool", "Use premium account if available", True),
16+
("fallback", "bool", "Fallback to free download if premium fails", True),
17+
("chk_filesize", "bool", "Check file size", True),
18+
("max_wait", "int", "Reconnect if waiting time is greater than minutes", 10),
19+
]
20+
21+
__description__ = """Archive.org downloader plugin"""
22+
__license__ = "GPLv3"
23+
__authors__ = [("GammaC0de", "nitzo2001[AT]yahoo[DOT]com")]
24+
25+
def setup(self):
26+
self.multi_dl = True
27+
self.resume_download = True
28+
self.chunk_limit = -1

0 commit comments

Comments
 (0)