""" 이 스크립트는 더 이상 기능하지 않습니다. https://github.com/hyriph/hdl-stubs/ 에서 최신 버전의 스크립트를 다운로드하세요. This script is no longer functional. Please download the latest version of the script from https://github.com/hyriph/hdl-stubs/ このスクリプトはもう機能しません。 最新バージョンのスクリプトを https://github.com/hyriph/hdl-stubs/ からダウンロードしてください。 此脚本已不再可用。 请从 https://github.com/hyriph/hdl-stubs/ 下载最新版本的脚本。 Este script ya no funciona. Por favor, descarga la última versión del script desde https://github.com/hyriph/hdl-stubs/. Ce script n'est plus fonctionnel. Veuillez télécharger la dernière version du script depuis https://github.com/hyriph/hdl-stubs/. Этот скрипт больше не работает. Пожалуйста, скачайте последнюю версию скрипта с https://github.com/hyriph/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')))