Compare commits

...

4 Commits

Author SHA1 Message Date
JerryZhouSirui 9479cb32e7
Merge 8bcbfcd076 into 1a366403d9 2024-04-29 01:28:05 +09: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
JerryZhouSirui 8bcbfcd076 Fix BeatPort Extractor 2024-04-26 16:59:49 -04:00
3 changed files with 36 additions and 47 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

@ -2,7 +2,7 @@ import re
from .common import InfoExtractor
from ..compat import compat_str
from ..utils import int_or_none
from ..utils import int_or_none, ExtractorError
class BeatportIE(InfoExtractor):
@ -43,55 +43,47 @@ class BeatportIE(InfoExtractor):
webpage = self._download_webpage(url, display_id)
playables = self._parse_json(
self._search_regex(
r'window\.Playables\s*=\s*({.+?});', webpage,
'playables info', flags=re.DOTALL),
track_id)
try:
playables_json = self._search_regex(
r'window\.Playables\s*=\s*({.+?})\s*;', webpage,
'playables info', default='{}', flags=re.DOTALL)
playables = self._parse_json(playables_json, track_id)
except re.error:
raise ExtractorError('Failed to extract playables information. The page structure may have changed.')
track = next(t for t in playables['tracks'] if t['id'] == int(track_id))
if not playables or 'tracks' not in playables:
raise ExtractorError('No playable tracks found in the extracted information.')
title = ', '.join((a['name'] for a in track['artists'])) + ' - ' + track['name']
if track['mix']:
track = next((t for t in playables['tracks'] if t['id'] == int(track_id)), None)
if not track:
raise ExtractorError(f'No track with ID {track_id} found.')
title = ', '.join(a['name'] for a in track['artists']) + ' - ' + track['name']
if track.get('mix'):
title += ' (' + track['mix'] + ')'
formats = []
for ext, info in track['preview'].items():
if not info['url']:
continue
fmt = {
'url': info['url'],
'ext': ext,
'format_id': ext,
'vcodec': 'none',
}
if ext == 'mp3':
fmt['acodec'] = 'mp3'
fmt['abr'] = 96
fmt['asr'] = 44100
elif ext == 'mp4':
fmt['acodec'] = 'aac'
fmt['abr'] = 96
fmt['asr'] = 44100
formats.append(fmt)
for ext, info in track.get('preview', {}).items():
url = info.get('url')
if url:
fmt = {
'url': url,
'ext': ext,
'format_id': ext,
'vcodec': 'none',
'acodec': 'mp3' if ext == 'mp3' else 'aac',
'abr': 96,
'asr': 44100
}
formats.append(fmt)
images = []
for name, info in track['images'].items():
image_url = info.get('url')
if name == 'dynamic' or not image_url:
continue
image = {
'id': name,
'url': image_url,
'height': int_or_none(info.get('height')),
'width': int_or_none(info.get('width')),
}
images.append(image)
images = [{'id': name, 'url': info['url'], 'height': int_or_none(info.get('height')), 'width': int_or_none(info.get('width'))}
for name, info in track.get('images', {}).items() if name != 'dynamic' and info.get('url')]
return {
'id': compat_str(track.get('id')) or track_id,
'display_id': track.get('slug') or display_id,
'id': compat_str(track.get('id', track_id)),
'display_id': track.get('slug', display_id),
'title': title,
'formats': formats,
'thumbnails': images,
'thumbnails': images
}