Upgrade yt_dlp and download script

This commit is contained in:
2025-05-02 16:11:08 -05:00
parent 3a2e8eeb08
commit d68d9ce4f9
1194 changed files with 60099 additions and 44436 deletions

View File

@@ -1,12 +1,10 @@
import re
import urllib.parse
from .common import InfoExtractor
from ..compat import compat_parse_qs
from ..dependencies import websockets
from ..networking import Request
from ..utils import (
ExtractorError,
WebSocketsWrapper,
js_to_json,
traverse_obj,
update_url_query,
@@ -16,7 +14,7 @@ from ..utils import (
class FC2IE(InfoExtractor):
_VALID_URL = r'^(?:https?://video\.fc2\.com/(?:[^/]+/)*content/|fc2:)(?P<id>[^/]+)'
_VALID_URL = r'(?:https?://video\.fc2\.com/(?:[^/]+/)*content/|fc2:)(?P<id>[^/]+)'
IE_NAME = 'fc2'
_NETRC_MACHINE = 'fc2'
_TESTS = [{
@@ -94,7 +92,7 @@ class FC2IE(InfoExtractor):
description = self._og_search_description(webpage, default=None)
vidplaylist = self._download_json(
'https://video.fc2.com/api/v3/videoplaylist/%s?sh=1&fs=0' % video_id, video_id,
f'https://video.fc2.com/api/v3/videoplaylist/{video_id}?sh=1&fs=0', video_id,
note='Downloading info page')
vid_url = traverse_obj(vidplaylist, ('playlist', 'nq'))
if not vid_url:
@@ -129,22 +127,22 @@ class FC2EmbedIE(InfoExtractor):
def _real_extract(self, url):
mobj = self._match_valid_url(url)
query = compat_parse_qs(mobj.group('query'))
query = urllib.parse.parse_qs(mobj.group('query'))
video_id = query['i'][-1]
title = query.get('tl', ['FC2 video %s' % video_id])[0]
title = query.get('tl', [f'FC2 video {video_id}'])[0]
sj = query.get('sj', [None])[0]
thumbnail = None
if sj:
# See thumbnailImagePath() in ServerConst.as of flv2.swf
thumbnail = 'http://video%s-thumbnail.fc2.com/up/pic/%s.jpg' % (
thumbnail = 'http://video{}-thumbnail.fc2.com/up/pic/{}.jpg'.format(
sj, '/'.join((video_id[:6], video_id[6:8], video_id[-2], video_id[-1], video_id)))
return {
'_type': 'url_transparent',
'ie_key': FC2IE.ie_key(),
'url': 'fc2:%s' % video_id,
'url': f'fc2:{video_id}',
'title': title,
'thumbnail': thumbnail,
}
@@ -167,10 +165,8 @@ class FC2LiveIE(InfoExtractor):
}]
def _real_extract(self, url):
if not websockets:
raise ExtractorError('websockets library is not available. Please install it.', expected=True)
video_id = self._match_id(url)
webpage = self._download_webpage('https://live.fc2.com/%s/' % video_id, video_id)
webpage = self._download_webpage(f'https://live.fc2.com/{video_id}/', video_id)
self._set_cookie('live.fc2.com', 'js-player_size', '1')
@@ -179,7 +175,7 @@ class FC2LiveIE(InfoExtractor):
'channel': '1',
'profile': '1',
'user': '1',
'streamid': video_id
'streamid': video_id,
}), note='Requesting member info')
control_server = self._download_json(
@@ -199,13 +195,9 @@ class FC2LiveIE(InfoExtractor):
ws_url = update_url_query(control_server['url'], {'control_token': control_server['control_token']})
playlist_data = None
self.to_screen('%s: Fetching HLS playlist info via WebSocket' % video_id)
ws = WebSocketsWrapper(ws_url, {
'Cookie': str(self._get_cookies('https://live.fc2.com/'))[12:],
ws = self._request_webpage(Request(ws_url, headers={
'Origin': 'https://live.fc2.com',
'Accept': '*/*',
'User-Agent': self.get_param('http_headers')['User-Agent'],
})
}), video_id, note='Fetching HLS playlist info via WebSocket')
self.write_debug('Sending HLS server request')
@@ -232,7 +224,7 @@ class FC2LiveIE(InfoExtractor):
self.write_debug('Goodbye')
playlist_data = data
break
self.write_debug('Server said: %s%s' % (recv[:100], '...' if len(recv) > 100 else ''))
self.write_debug('Server said: {}{}'.format(recv[:100], '...' if len(recv) > 100 else ''))
if not playlist_data:
raise ExtractorError('Unable to fetch HLS playlist info via WebSocket')