Compare commits

...

4 Commits

Author SHA1 Message Date
The-MAGI 3a91cc30c9
Merge 8a6fe2e420 into 1a366403d9 2024-04-28 19:50:40 +02:00
bashonly 1a366403d9
[build] Run `macos_legacy` job on `macos-12` (#9804)
`macos-latest` has been bumped to `macos-14-arm64` which breaks the builds

Authored by: bashonly
2024-04-28 15:35:17 +00:00
Simon Sawicki 7e26bd53f9
[core/windows] Fix tests for `sys.executable` with spaces (Fix for 64766459e3)
Authored by: Grub4K
2024-04-28 15:47:55 +02:00
The-MAGI 8a6fe2e420
[youporn] Fix extraction of video URLs
The API seems to be gone, but video_player_setup object will contain playervars, with URLs to fetch the format definitions.
2023-12-22 02:31:32 +02:00
3 changed files with 16 additions and 15 deletions

View File

@ -300,7 +300,7 @@ jobs:
macos_legacy:
needs: process
if: inputs.macos_legacy
runs-on: macos-latest
runs-on: macos-12
steps:
- uses: actions/checkout@v4

View File

@ -2090,10 +2090,7 @@ Line 1
args = [sys.executable, '-c', 'import sys; print(end=sys.argv[1])', argument, 'end']
assert run_shell(args) == expected
escaped = shell_quote(argument, shell=True)
args = f'{sys.executable} -c "import sys; print(end=sys.argv[1])" {escaped} end'
assert run_shell(args) == expected
assert run_shell(shell_quote(args, shell=True)) == expected
if __name__ == '__main__':

View File

@ -88,19 +88,27 @@ class YouPornIE(InfoExtractor):
def _real_extract(self, url):
video_id, display_id = self._match_valid_url(url).group('id', 'display_id')
definitions = self._download_json(
f'https://www.youporn.com/api/video/media_definitions/{video_id}/', display_id or video_id)
webpage = self._download_webpage(
f"https://www.youporn.com/watch/{video_id}", display_id or video_id,
headers={'Cookie': 'age_verified=1'},
)
def get_format_data(data, f):
return traverse_obj(data, lambda _, v: v['format'] == f and url_or_none(v['videoUrl']))
playervars = self._search_regex(r'^\s*playervars:\s*(\{.+?\})$', webpage, 'playervars', flags=re.MULTILINE)
playervars = self._parse_json(playervars, display_id or video_id)
defs_by_format = {x['format'] : x for x in playervars.get('mediaDefinitions', {})}
def get_format_data(f):
if not f in defs_by_format:
return []
return self._download_json(defs_by_format[f]['videoUrl'], display_id or video_id, f"{f}-formats")
formats = []
# Try to extract only the actual master m3u8 first, avoiding the duplicate single resolution "master" m3u8s
for hls_url in traverse_obj(get_format_data(definitions, 'hls'), (
for hls_url in traverse_obj(get_format_data('hls'), (
lambda _, v: not isinstance(v['defaultQuality'], bool), 'videoUrl'), (..., 'videoUrl')):
formats.extend(self._extract_m3u8_formats(hls_url, video_id, 'mp4', fatal=False, m3u8_id='hls'))
for definition in get_format_data(definitions, 'mp4'):
for definition in get_format_data('mp4'):
f = traverse_obj(definition, {
'url': 'videoUrl',
'filesize': ('videoSize', {int_or_none})
@ -123,10 +131,6 @@ class YouPornIE(InfoExtractor):
f['height'] = height
formats.append(f)
webpage = self._download_webpage(
'http://www.youporn.com/watch/%s' % video_id, display_id,
headers={'Cookie': 'age_verified=1'})
title = self._html_search_regex(
r'(?s)<div[^>]+class=["\']watchVideoTitle[^>]+>(.+?)</div>',
webpage, 'title', default=None) or self._og_search_title(