Skip to content

Commit

Permalink
^q^
Browse files Browse the repository at this point in the history
  • Loading branch information
KurtBestor committed Dec 27, 2021
1 parent 52faf32 commit ea966f1
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/extractor/manatoki_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def get_imgs_page(page, title, referer, session, cw):
continue
if '/img/blank.gif' in img:
continue
img = Image(img, page, len(imgs))
img = Image(img, page, len(imgs))
imgs.append(img)

## if not imgs:
Expand Down
29 changes: 18 additions & 11 deletions src/extractor/twitter_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class Downloader_twitter(Downloader):
type = 'twitter'
URLS = [suitable]
MAX_CORE = 8
MAX_SPEED = 4.0
#MAX_SPEED = 4.0

def init(self):
self.session = get_session()
Expand Down Expand Up @@ -569,10 +569,10 @@ def __init__(self, url, referer, id, time, p, format, cw=None, isVideo=False, tr
self.time = time
self.p = p
self.n_thread = n_thread
if not isVideo:
url_alter = Url_alter(url)
if isVideo:
url_alter = self.get #4185
else:
url_alter = None
url_alter = Url_alter(url)
if isVideo and get_ext(url).lower() not in ['.mp4', '.m3u8']:
get = self.get
else:
Expand All @@ -591,35 +591,42 @@ def __init__(self, url, referer, id, time, p, format, cw=None, isVideo=False, tr

@sleep_and_retry
@limits(1, 5)
def get(self, _):
def get(self, _=None):
if self._url_cache:
return self._url_cache
print_ = get_print(self.cw)
for try_ in range(self.try_n):
try:
d = ytdl.YoutubeDL(cw=self.cw)
info = d.extract_info(self._url)
info = d.extract_info(self.referer)

fs = info['formats']
for f in fs:
print_('{} {} - {}'.format(f['height'], f['protocol'], f['url']))
print_('{} {} - {}'.format(f.get('height'), f['protocol'], f['url']))
def key(f):
h = f['height']
h = f.get('height', 0)
if not f['protocol'].startswith('http'):
h -= .1
return h
f = sorted(fs, key=key)[-1]
for f in sorted(fs, key=key, reverse=True):
if downloader.ok_url(f['url'], self.referer): #4185
break
else:
print_('invalid video: {}'.format(f['url']))
else:
raise Exception('no valid videos')
url = f['url']
ext = get_ext(url)
self.ext = ext
print_('get_video: {} {}'.format(url, ext))
if ext.lower() == '.m3u8':
url = ffmpeg.Stream(url, cw=self.cw)
url = ffmpeg.Stream(url)
url._live = False
self._url_cache = url
return url
except Exception as e:
e_ = e
msg = print_error(e)[(-1)]
msg = print_error(e)[0]
print_('\nTwitter video Error:\n{}'.format(msg))
if try_ < self.try_n - 1:
sleep(10, self.cw)
Expand Down
4 changes: 4 additions & 0 deletions translation/changelog_en.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@

- #4137

- #4185

- #4196

- 기타 자잘한 것들


Expand Down
4 changes: 4 additions & 0 deletions translation/changelog_ko.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@

- #4137

- #4185

- #4196

- 기타 자잘한 것들


Expand Down

0 comments on commit ea966f1

Please sign in to comment.