Compare commits

...

5 Commits

Author SHA1 Message Date
pukkandan
24093d52a7
[update] Prepare to remove Python 3.6 support 2022-07-17 18:45:44 +05:30
pukkandan
f5e438a976
[compat] Let PyInstaller detect _legacy module 2022-07-17 18:45:43 +05:30
pukkandan
d08e1e6875
Fix bug in 5200976949 2022-07-17 17:03:54 +05:30
sqrtNOT
956f1cf805
[extractor/philharmoniedeparis] Fix extractor (#4367)
Closes #4297
Authored by: sqrtNOT
2022-07-17 16:29:56 +05:30
sqrtNOT
129dfa5f45
[extractor/WSJArticle] Fix video id extraction (#4268)
Closes #4249
Authored by: sqrtNOT
2022-07-17 16:04:33 +05:30
6 changed files with 48 additions and 52 deletions

View File

@ -6,11 +6,10 @@ import sys
from PyInstaller.__main__ import run as run_pyinstaller from PyInstaller.__main__ import run as run_pyinstaller
OS_NAME, MACHINE = sys.platform, platform.machine() OS_NAME, MACHINE, ARCH = sys.platform, platform.machine(), platform.architecture()[0][:2]
if MACHINE in ('x86_64', 'amd64'): if MACHINE in ('x86_64', 'AMD64') or ('i' in MACHINE and '86' in MACHINE):
MACHINE = '' # NB: Windows x86 has MACHINE = AMD64 irrespective of bitness
elif 'i' in MACHINE and '86' in MACHINE: MACHINE = 'x86' if ARCH == '32' else ''
MACHINE = 'x86'
def main(): def main():
@ -34,9 +33,6 @@ def main():
'--icon=devscripts/logo.ico', '--icon=devscripts/logo.ico',
'--upx-exclude=vcruntime140.dll', '--upx-exclude=vcruntime140.dll',
'--noconfirm', '--noconfirm',
# NB: Modules that are only imported dynamically must be added here.
# --collect-submodules may not work correctly if user has a yt-dlp installed via PIP
'--hidden-import=yt_dlp.compat._legacy',
*dependency_options(), *dependency_options(),
*opts, *opts,
'yt_dlp/__main__.py', 'yt_dlp/__main__.py',
@ -51,7 +47,6 @@ def parse_options():
# Compatibility with older arguments # Compatibility with older arguments
opts = sys.argv[1:] opts = sys.argv[1:]
if opts[0:1] in (['32'], ['64']): if opts[0:1] in (['32'], ['64']):
ARCH = platform.architecture()[0][:2]
if ARCH != opts[0]: if ARCH != opts[0]:
raise Exception(f'{opts[0]}bit executable cannot be built on a {ARCH}bit system') raise Exception(f'{opts[0]}bit executable cannot be built on a {ARCH}bit system')
opts = opts[1:] opts = opts[1:]

View File

@ -24,7 +24,6 @@ import urllib.request
from string import ascii_letters from string import ascii_letters
from .cache import Cache from .cache import Cache
from .compat import HAS_LEGACY as compat_has_legacy
from .compat import compat_os_name, compat_shlex_quote from .compat import compat_os_name, compat_shlex_quote
from .cookies import load_cookies from .cookies import load_cookies
from .downloader import FFmpegFD, get_suitable_downloader, shorten_protocol_name from .downloader import FFmpegFD, get_suitable_downloader, shorten_protocol_name
@ -589,8 +588,8 @@ class YoutubeDL:
current_version = sys.version_info[:2] current_version = sys.version_info[:2]
if current_version < MIN_RECOMMENDED: if current_version < MIN_RECOMMENDED:
msg = ('Support for Python version %d.%d has been deprecated. ' msg = ('Support for Python version %d.%d has been deprecated. '
'See https://github.com/yt-dlp/yt-dlp/issues/3764 for more details. ' 'See https://github.com/yt-dlp/yt-dlp/issues/3764 for more details.'
'You will recieve only one more update on this version') '\n You will no longer recieve updates on this version')
if current_version < MIN_SUPPORTED: if current_version < MIN_SUPPORTED:
msg = 'Python version %d.%d is no longer supported' msg = 'Python version %d.%d is no longer supported'
self.deprecation_warning( self.deprecation_warning(
@ -623,8 +622,6 @@ class YoutubeDL:
self.deprecation_warning(msg) self.deprecation_warning(msg)
self.params['compat_opts'] = set(self.params.get('compat_opts', ())) self.params['compat_opts'] = set(self.params.get('compat_opts', ()))
if not compat_has_legacy:
self.params['compat_opts'].add('no-compat-legacy')
if 'list-formats' in self.params['compat_opts']: if 'list-formats' in self.params['compat_opts']:
self.params['listformats_table'] = False self.params['listformats_table'] = False

View File

@ -8,14 +8,8 @@ from ._deprecated import * # noqa: F401, F403
from .compat_utils import passthrough_module from .compat_utils import passthrough_module
# XXX: Implement this the same way as other DeprecationWarnings without circular import # XXX: Implement this the same way as other DeprecationWarnings without circular import
try: passthrough_module(__name__, '._legacy', callback=lambda attr: warnings.warn(
passthrough_module(__name__, '._legacy', callback=lambda attr: warnings.warn(
DeprecationWarning(f'{__name__}.{attr} is deprecated'), stacklevel=2)) DeprecationWarning(f'{__name__}.{attr} is deprecated'), stacklevel=2))
HAS_LEGACY = True
except ModuleNotFoundError:
# Keep working even without _legacy module
HAS_LEGACY = False
del passthrough_module
# HTMLParseError has been deprecated in Python 3.3 and removed in # HTMLParseError has been deprecated in Python 3.3 and removed in
@ -76,3 +70,9 @@ if compat_os_name in ('nt', 'ce'):
return userhome + path[i:] return userhome + path[i:]
else: else:
compat_expanduser = os.path.expanduser compat_expanduser = os.path.expanduser
# NB: Add modules that are imported dynamically here so that PyInstaller can find them
# See https://github.com/pyinstaller/pyinstaller-hooks-contrib/issues/438
if False:
from . import _legacy # noqa: F401

View File

@ -1,9 +1,6 @@
from .common import InfoExtractor from .common import InfoExtractor
from ..compat import compat_str from ..compat import compat_str
from ..utils import ( from ..utils import try_get
try_get,
urljoin,
)
class PhilharmonieDeParisIE(InfoExtractor): class PhilharmonieDeParisIE(InfoExtractor):
@ -12,27 +9,29 @@ class PhilharmonieDeParisIE(InfoExtractor):
https?:// https?://
(?: (?:
live\.philharmoniedeparis\.fr/(?:[Cc]oncert/|embed(?:app)?/|misc/Playlist\.ashx\?id=)| live\.philharmoniedeparis\.fr/(?:[Cc]oncert/|embed(?:app)?/|misc/Playlist\.ashx\?id=)|
pad\.philharmoniedeparis\.fr/doc/CIMU/ pad\.philharmoniedeparis\.fr/(?:doc/CIMU/|player\.aspx\?id=)|
philharmoniedeparis\.fr/fr/live/concert/|
otoplayer\.philharmoniedeparis\.fr/fr/embed/
) )
(?P<id>\d+) (?P<id>\d+)
''' '''
_TESTS = [{ _TESTS = [{
'url': 'http://pad.philharmoniedeparis.fr/doc/CIMU/1086697/jazz-a-la-villette-knower', 'url': 'https://philharmoniedeparis.fr/fr/live/concert/1129666-danses-symphoniques',
'md5': 'a0a4b195f544645073631cbec166a2c2', 'md5': '24bdb7e86c200c107680e1f7770330ae',
'info_dict': { 'info_dict': {
'id': '1086697', 'id': '1129666',
'ext': 'mp4', 'ext': 'mp4',
'title': 'Jazz à la Villette : Knower', 'title': 'Danses symphoniques. Orchestre symphonique Divertimento - Zahia Ziouani. Bizet, de Falla, Stravinski, Moussorgski, Saint-Saëns',
}, },
}, { }, {
'url': 'http://live.philharmoniedeparis.fr/concert/1032066.html', 'url': 'https://philharmoniedeparis.fr/fr/live/concert/1032066-akademie-fur-alte-musik-berlin-rias-kammerchor-rene-jacobs-passion-selon-saint-jean-de-johann',
'info_dict': { 'info_dict': {
'id': '1032066', 'id': '1032066',
'title': 'md5:0a031b81807b3593cffa3c9a87a167a0', 'title': 'Akademie für alte Musik Berlin, Rias Kammerchor, René Jacobs : Passion selon saint Jean de Johann Sebastian Bach',
}, },
'playlist_mincount': 2, 'playlist_mincount': 2,
}, { }, {
'url': 'http://live.philharmoniedeparis.fr/Concert/1030324.html', 'url': 'https://philharmoniedeparis.fr/fr/live/concert/1030324-orchestre-philharmonique-de-radio-france-myung-whun-chung-renaud-capucon-pascal-dusapin-johannes',
'only_matching': True, 'only_matching': True,
}, { }, {
'url': 'http://live.philharmoniedeparis.fr/misc/Playlist.ashx?id=1030324&track=&lang=fr', 'url': 'http://live.philharmoniedeparis.fr/misc/Playlist.ashx?id=1030324&track=&lang=fr',
@ -41,16 +40,15 @@ class PhilharmonieDeParisIE(InfoExtractor):
'url': 'https://live.philharmoniedeparis.fr/embedapp/1098406/berlioz-fantastique-lelio-les-siecles-national-youth-choir-of.html?lang=fr-FR', 'url': 'https://live.philharmoniedeparis.fr/embedapp/1098406/berlioz-fantastique-lelio-les-siecles-national-youth-choir-of.html?lang=fr-FR',
'only_matching': True, 'only_matching': True,
}, { }, {
'url': 'https://live.philharmoniedeparis.fr/embed/1098406/berlioz-fantastique-lelio-les-siecles-national-youth-choir-of.html?lang=fr-FR', 'url': 'https://otoplayer.philharmoniedeparis.fr/fr/embed/1098406?lang=fr-FR',
'only_matching': True, 'only_matching': True,
}] }]
_LIVE_URL = 'https://live.philharmoniedeparis.fr'
def _real_extract(self, url): def _real_extract(self, url):
video_id = self._match_id(url) video_id = self._match_id(url)
config = self._download_json( config = self._download_json(
'%s/otoPlayer/config.ashx' % self._LIVE_URL, video_id, query={ 'https://otoplayer.philharmoniedeparis.fr/fr/config/%s.json' % video_id, video_id, query={
'id': video_id, 'id': video_id,
'lang': 'fr-FR', 'lang': 'fr-FR',
}) })
@ -72,9 +70,8 @@ class PhilharmonieDeParisIE(InfoExtractor):
if not format_url or format_url in format_urls: if not format_url or format_url in format_urls:
continue continue
format_urls.add(format_url) format_urls.add(format_url)
m3u8_url = urljoin(self._LIVE_URL, format_url)
formats.extend(self._extract_m3u8_formats( formats.extend(self._extract_m3u8_formats(
m3u8_url, video_id, 'mp4', entry_protocol='m3u8_native', format_url, video_id, 'mp4', entry_protocol='m3u8_native',
m3u8_id='hls', fatal=False)) m3u8_id='hls', fatal=False))
if not formats and not self.get_param('ignore_no_formats'): if not formats and not self.get_param('ignore_no_formats'):
return return
@ -82,21 +79,19 @@ class PhilharmonieDeParisIE(InfoExtractor):
return { return {
'title': title, 'title': title,
'formats': formats, 'formats': formats,
'thumbnail': files.get('thumbnail'),
} }
thumbnail = urljoin(self._LIVE_URL, config.get('image'))
info = extract_entry(config) info = extract_entry(config)
if info: if info:
info.update({ info.update({
'id': video_id, 'id': video_id,
'thumbnail': thumbnail,
}) })
return info return info
entries = [] entries = []
for num, chapter in enumerate(config['chapters'], start=1): for num, chapter in enumerate(config['chapters'], start=1):
entry = extract_entry(chapter) entry = extract_entry(chapter)
if entry is None:
continue
entry['id'] = '%s-%d' % (video_id, num) entry['id'] = '%s-%d' % (video_id, num)
entries.append(entry) entries.append(entry)

View File

@ -116,5 +116,6 @@ class WSJArticleIE(InfoExtractor):
article_id = self._match_id(url) article_id = self._match_id(url)
webpage = self._download_webpage(url, article_id) webpage = self._download_webpage(url, article_id)
video_id = self._search_regex( video_id = self._search_regex(
r'data-src=["\']([a-fA-F0-9-]{36})', webpage, 'video id') r'(?:id=["\']video|video-|iframe\.html\?guid=|data-src=["\'])([a-fA-F0-9-]{36})',
webpage, 'video id')
return self.url_result('wsj:%s' % video_id, WSJIE.ie_key(), video_id) return self.url_result('wsj:%s' % video_id, WSJIE.ie_key(), video_id)

View File

@ -88,8 +88,7 @@ class Updater:
@functools.cached_property @functools.cached_property
def _tag(self): def _tag(self):
latest = self._get_version_info('latest')['tag_name'] if version_tuple(__version__) >= version_tuple(self.latest_version):
if version_tuple(__version__) >= version_tuple(latest):
return 'latest' return 'latest'
identifier = f'{detect_variant()} {system_identifier()}' identifier = f'{detect_variant()} {system_identifier()}'
@ -113,9 +112,16 @@ class Updater:
@property @property
def new_version(self): def new_version(self):
"""Version of the latest release""" """Version of the latest release we can update to"""
if self._tag.startswith('tags/'):
return self._tag[5:]
return self._get_version_info(self._tag)['tag_name'] return self._get_version_info(self._tag)['tag_name']
@property
def latest_version(self):
"""Version of the latest release"""
return self._get_version_info('latest')['tag_name']
@property @property
def has_update(self): def has_update(self):
"""Whether there is an update available""" """Whether there is an update available"""
@ -161,13 +167,15 @@ class Updater:
"""Report whether there is an update available""" """Report whether there is an update available"""
try: try:
self.ydl.to_screen( self.ydl.to_screen(
f'Latest version: {self.new_version}, Current version: {self.current_version}') f'Latest version: {self.latest_version}, Current version: {self.current_version}')
if not self.has_update:
if self._tag == 'latest':
return self.ydl.to_screen(f'yt-dlp is up to date ({__version__})')
return self.ydl.report_warning(
'yt-dlp cannot be updated any further since you are on an older Python version')
except Exception: except Exception:
return self._report_network_error('obtain version info', delim='; Please try again later or') return self._report_network_error('obtain version info', delim='; Please try again later or')
if not self.has_update:
return self.ydl.to_screen(f'yt-dlp is up to date ({__version__})')
if not is_non_updateable(): if not is_non_updateable():
self.ydl.to_screen(f'Current Build Hash {_sha256_file(self.filename)}') self.ydl.to_screen(f'Current Build Hash {_sha256_file(self.filename)}')
return True return True