Skip to content

Commit 6f37e5e

Browse files
committed
^q^
1 parent 8d84fcb commit 6f37e5e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+559
-315
lines changed

src/extractor/afreeca_downloader.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import downloader
2-
from utils import Soup, Downloader, get_outdir, Session, LazyUrl, try_n, format_filename, cut_pair, File
2+
from utils import Soup, Downloader, Session, try_n, format_filename, cut_pair, File, get_print
33
import ree as re
4-
from timee import sleep, time
5-
import os
64
from io import BytesIO
7-
import shutil
85
from m3u8_tools import playlist2stream, M3u8_stream
96
import errors
107
import json
@@ -57,6 +54,7 @@ class Video(File):
5754
type = 'afreeca'
5855

5956
def get(self):
57+
print_ = get_print(self.cw)
6058
url, session = self['referer'], self.session
6159

6260
html = downloader.read_html(url, session=session)
@@ -71,7 +69,7 @@ def get(self):
7169
url_thumb = soup.find('meta', {'property': 'og:image'}).attrs['content']
7270
print_('url_thumb: {}'.format(url_thumb))
7371

74-
vid = re.find(f'/player/([0-9]+)', url, err='no vid')
72+
vid = re.find('/player/([0-9]+)', url, err='no vid')
7573
if f'{vid}/catch' in url: #6215
7674
url_api = 'https://api.m.afreecatv.com/station/video/a/catchview'
7775
r = session.post(url_api, data={'nPageNo': '1', 'nLimit': '10', 'nTitleNo': vid}, headers={'Referer': url})
@@ -105,7 +103,7 @@ def get(self):
105103
else:
106104
file = file['file']
107105
urls_m3u8.append(file)
108-
self.cw.print_(f'urls_m3u8: {len(urls_m3u8)}')
106+
print_(f'urls_m3u8: {len(urls_m3u8)}')
109107

110108
streams = []
111109
for url_m3u8 in urls_m3u8:
@@ -119,4 +117,4 @@ def get(self):
119117
streams[0] += stream
120118
stream = streams[0]
121119

122-
return {'url': stream, 'title': title, 'name': format_filename(title, id, '.mp4'), 'url_thumb': url_thumb}
120+
return {'url': stream, 'title': title, 'name': format_filename(title, vid, '.mp4'), 'url_thumb': url_thumb}

src/extractor/artstation_downloader.py

Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import downloader
33
from error_printer import print_error
44
from translator import tr_
5-
from utils import Downloader, Soup, get_print, lazy, Session, try_n, File, clean_title, check_alive, File, get_ext, get_max_range
5+
from utils import Downloader, Soup, get_print, lazy, Session, try_n, File, clean_title, check_alive, get_ext, get_max_range
66
import dateutil.parser
77
import utils
88

@@ -46,6 +46,14 @@ def init(self):
4646
self.url = self.url_main
4747
self.print_(self.url)
4848

49+
@classmethod
50+
def fix_url(cls, url): #6516
51+
if '.artstation.com' in url:
52+
sub = url.split('.artstation.com')[0].split('/')[-1]
53+
if sub != 'www':
54+
url = f'https://www.artstation.com/{sub}'
55+
return url
56+
4957
@lazy
5058
def _id(self):
5159
_id = get_id(self.url, self.cw)
@@ -86,41 +94,25 @@ def get_imgs(id_, title, session, cw=None):
8694
url = f'https://www.artstation.com/users/{id_}/quick.json'
8795
j = downloader.read_json(url, referer, session=session)
8896
uid = j['id']
89-
aids = [a['id'] for a in j['albums_with_community_projects']]
90-
print_(f'albums: {aids}')
9197

9298
datas = []
9399
ids = set()
94-
for aid in aids:
95-
p = 1
96-
while p < 1000:
97-
check_alive(cw)
98-
url = f'https://www.artstation.com/users/{id_}/projects.json?album_id={aid}&page={p}&user_id={uid}'
99-
print(url)
100-
_e = None
101-
for i in range(4):
102-
try:
103-
j = downloader.read_json(url, referer, session=session)
104-
break
105-
except Exception as e:
106-
_e = e
107-
print(e)
108-
else:
109-
if _e is not None:
110-
raise _e
111-
112-
data = j['data']
113-
if not data:
114-
break
115-
for d in data:
116-
if d['id'] not in ids:
117-
ids.add(d['id'])
118-
datas.append(d)
119-
if cw:
120-
cw.setTitle(f'{tr_("페이지 읽는 중...")} {title} - {len(datas)}')
121-
else:
122-
print(len(datas))
123-
p += 1
100+
for p in range(1, 1000):
101+
check_alive(cw)
102+
url = f'https://www.artstation.com/users/{id_}/projects.json??user_id={uid}&page={p}' #6516
103+
j = try_n(4)(downloader.read_json)(url, referer, session=session)
104+
105+
data = j['data']
106+
if not data:
107+
break
108+
for d in data:
109+
if d['id'] not in ids:
110+
ids.add(d['id'])
111+
datas.append(d)
112+
if cw:
113+
cw.setTitle(f'{tr_("페이지 읽는 중...")} {title} - {len(datas)}')
114+
else:
115+
print(len(datas))
124116

125117
datas = sorted(datas, key=lambda data: int(data['id']), reverse=True)
126118

@@ -234,7 +226,7 @@ def get_imgs_page(id_art, session, date=None, cw=None, names=None):
234226

235227
d = {
236228
'date': date,
237-
'name': name,
229+
'name': clean_title(name),
238230
'page': page,
239231
}
240232
filename = utils.format('artstation', d, get_ext(url))

src/extractor/asmhentai_downloader.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#coding: utf8
22
import downloader
33
import ree as re
4-
from utils import Soup, urljoin, Downloader, join, Session, get_print, File
4+
from utils import Soup, urljoin, Downloader, join, Session, File, clean_title
55
import os
66
from ratelimit import limits, sleep_and_retry
77
import utils
@@ -27,7 +27,7 @@ def get(self):
2727
url = img['data-src']
2828
name, ext = os.path.splitext(os.path.basename(url).split('?')[0])
2929
d = {
30-
'name': name,
30+
'name': clean_title(name),
3131
}
3232
return {'url': url, 'name': utils.format('asmhentai', d, ext)}
3333

@@ -68,7 +68,6 @@ def read(self):
6868

6969

7070
def get_info(url, session, cw):
71-
print_ = get_print(cw)
7271
html = downloader.read_html(url, session=session)
7372
soup = Soup(html)
7473

src/extractor/avgle_downloader.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
#coding: utf8
22
import downloader
3-
import os
43
from m3u8_tools import M3u8_stream
5-
from utils import Soup, Downloader, LazyUrl, get_print, try_n, clean_title, check_alive, format_filename
4+
from utils import Soup, Downloader, LazyUrl, get_print, try_n, check_alive, format_filename
65
from io import BytesIO
7-
import constants
8-
from error_printer import print_error
96
import base64
107
import json
118
import webbrowser

src/extractor/bcy_downloader.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import downloader
33
from utils import Soup, cut_pair, LazyUrl, Downloader, get_print, get_max_range, try_n, clean_title, check_alive
44
import json
5-
import ree as re
65
import os
76
from translator import tr_
87

src/extractor/bdsmlr_downloader.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import ree as re
66
import os
77
from translator import tr_
8-
from timee import sleep
98
from error_printer import print_error
109
import clf2
1110
import errors

src/extractor/bili_downloader.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import downloader
22
import downloader_v3
3-
from utils import Downloader, get_print, format_filename, clean_title, get_resolution, try_n, Session, uuid, File, get_max_range
3+
from utils import Downloader, get_print, format_filename, clean_title, get_resolution, try_n, Session, uuid, File, get_max_range, query_url
44
import os
55
from io import BytesIO
66
import ffmpeg
77
import math
88
import ree as re
9-
import utils
109
import ytdl
1110
import constants
1211
from putils import DIR
@@ -154,13 +153,15 @@ def init(self):
154153
def key_id(cls, url):
155154
mobj = re.match(_VALID_URL, url)
156155
video_id = mobj.group('id')
157-
return video_id or url
156+
qs = query_url(url)
157+
p = qs.get('p', ['1'])[0] #6580
158+
return f'{video_id or url} {p}'
158159

159160
@property
160161
def id_(self):
161162
mobj = re.match(_VALID_URL, self.url)
162163
video_id = mobj.group('id')
163-
anime_id = mobj.group('anime_id')
164+
#anime_id = mobj.group('anime_id')
164165
return video_id
165166

166167
def read(self):

src/extractor/comicwalker_downloader.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import ree as re
55
from itertools import cycle
66
from io import BytesIO
7-
from timee import sleep
87
from translator import tr_
98
import page_selector
109
import utils
@@ -77,7 +76,7 @@ def get_imgs_page(page, cw):
7776
if hash is None:
7877
continue
7978
d = {
80-
'title': page.title,
79+
'title': clean_title(page.title),
8180
'page': len(imgs),
8281
}
8382
img = File_comicwalker({'src': src, 'hash': hash, 'referer': page.url, 'name': utils.format('comicwalker', d, '.jpg')})
@@ -113,7 +112,6 @@ def get_pages(url, soup=None):
113112

114113

115114
def get_title(soup, cw=None):
116-
print_ = get_print(cw)
117115
div = soup.find('div', class_='comicIndex-box') #6231
118116
if div is None:
119117
raise Exception('no title')

src/extractor/coub_downloader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from io import BytesIO as IO
44
import downloader
55
import ree as re
6-
import ffmpeg
76
PATTEN_IMAGIZER = r'coub-com-.+\.imagizer\.com'
87

98

@@ -67,6 +66,7 @@ def get(self, url):
6766
return self._url
6867

6968
def pp(self, filename):
69+
## import ffmpeg
7070
## f = IO()
7171
## downloader.download(self.f_audio['url'], buffer=f)
7272
## ffmpeg.merge(filename, f)

src/extractor/etc_downloader.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ def _get_video(url, session, cw, ie_key=None, allow_m3u8=True):
8686
'noplaylist': True,
8787
#'extract_flat': True,
8888
'playlistend': 1,
89+
'writesubtitles': True,
8990
}
9091
if ytdl.get_extractor_name(url) == 'spankbang':
9192
options['legacyserverconnect'] = True #6545

0 commit comments

Comments
 (0)