-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathblacktoon_v3.hds
117 lines (94 loc) · 4.38 KB
/
blacktoon_v3.hds
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
"""
이 스크립트는 더 이상 기능하지 않습니다.
https://github.com/STR-HK/hdl-stubs/ 에서 최신 버전의 스크립트를 다운로드하세요.
This script is no longer functional.
Please download the latest version of the script from https://github.com/STR-HK/hdl-stubs/
このスクリプトはもう機能しません。
最新バージョンのスクリプトを https://github.com/STR-HK/hdl-stubs/ からダウンロードしてください。
此脚本已不再可用。
请从 https://github.com/STR-HK/hdl-stubs/ 下载最新版本的脚本。
Este script ya no funciona.
Por favor, descarga la última versión del script desde https://github.com/STR-HK/hdl-stubs/.
Ce script n'est plus fonctionnel.
Veuillez télécharger la dernière version du script depuis https://github.com/STR-HK/hdl-stubs/.
Этот скрипт больше не работает.
Пожалуйста, скачайте последнюю версию скрипта с https://github.com/STR-HK/hdl-stubs/.
"""
#coding: utf8
#title: Add Blacktoon.com
#author: STR.HK
#comment: Updated at 2021/06/12
import re
from utils import Soup, LazyUrl, Downloader, Session, clean_title
import clf2
import json
class Image(object):
def __init__(self, src, title, p):
ext = '.{}'.format(src.split('.')[-1])
if ext.lower()[1:] not in ['jpg', 'jpeg', 'bmp', 'png', 'gif', 'webm', 'webp']:
ext = '.jpg'
self.filename = '{}/{:04}{}'.format(title, p, ext)
self.url = LazyUrl(src, lambda _: src, self)
def logg(anything):
log(''.join(list(str(anything))))
@Downloader.register
class Downloader_Blacktoon(Downloader):
type = 'blacktoon'
URLS = [r'regex:blacktoon[0-9]*\.com']
icon = 'https://blacktoon.net/favicon-red.ico'
def read(self):
siteMainURL = 'https://{}'.format(self.url.split('//')[-1].split('/')[0])
toonNumber = self.url.split('/')[-1].split('.')[0]
self.title = '{} - Loading Webtoon List...'.format(self.url)
session = Session()
res = clf2.solve(self.url, session=session)
soup = Soup(res['html'], apply_css=True)
scriptURL = siteMainURL + soup.find_all('script')[21]['src']
self.title = '{} - Reading Webtoon List...'.format(self.url)
get = get_list(scriptURL, session)
ids = get['ids']
titles = get['titles']
for d in range(len(ids)):
self.title = '[{}] {} / {} ( {} / {} ) - Reading...'.format(get_artist(soup), get_title(soup), titles[d], d+1, len(ids))
for img in get_page_imgs(siteMainURL, toonNumber, d, ids, '[{}] {}'.format(get_artist(soup), titles[d])):
self.urls.append(img.url)
self.title = '[{}] {}'.format(get_artist(soup), get_title(soup))
self.artist = get_artist(soup)
# 이것으로 폴더 이름이 정해지기 떄문에 반드시 clean_title 해주어야 함
self.title = clean_title(self.title)
log('Blacktoon_Downloader: Successfully Downloaded {}'.format(self.title))
def get_list(scriptURL, session):
res = clf2.solve(scriptURL, session=session)
absolute = Soup(res['html']).get_text().replace('var clist = ','').replace(';','')
ids = json.loads(absolute)
for i, d in enumerate(ids):
ids[i] = d['id']
titles = json.loads(absolute)
for t, i in enumerate(titles):
titles[t] = i['t']
return {'ids':ids, 'titles':titles}
def get_title(soup):
content = soup.find('h3', class_='mt-2')
title = content.find('b').text.strip()
return(title)
def get_artist(soup):
content = soup.find('p', class_='mt-2')
artist = content.text.strip().split(':')[-1].replace(' ','')
return(artist)
@try_n(8)
def get_page_imgs(siteMainURL, toonNumber, number, ids, title):
page = clf2.solve('{}/webtoons/{}/{}.html'.format(siteMainURL, toonNumber, ids[number]))
page = Soup(page['html'])
src = page.find('div', {'id':'toon_content_imgs'}).find_all('img')
imgs = []
for s, r in enumerate(src):
try:
src[s] = r['src']
except:
src[s] = 'https://img.blacktoonimg.com/' + r['o_src']
title = clean_title(title)
for v, w in enumerate(src):
img = Image(w, title, v+1)
imgs.append(img)
return(imgs)
log(u'{}: blacktoon'.format(tr_(u'Site Added')))