update.py 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
  1. from __future__ import annotations
  2. import atexit
  3. import contextlib
  4. import hashlib
  5. import json
  6. import os
  7. import platform
  8. import re
  9. import subprocess
  10. import sys
  11. from dataclasses import dataclass
  12. from zipimport import zipimporter
  13. from .compat import functools # isort: split
  14. from .compat import compat_realpath, compat_shlex_quote
  15. from .networking import Request
  16. from .networking.exceptions import HTTPError, network_exceptions
  17. from .utils import (
  18. NO_DEFAULT,
  19. Popen,
  20. deprecation_warning,
  21. format_field,
  22. remove_end,
  23. shell_quote,
  24. system_identifier,
  25. version_tuple,
  26. )
  27. from .version import (
  28. CHANNEL,
  29. ORIGIN,
  30. RELEASE_GIT_HEAD,
  31. UPDATE_HINT,
  32. VARIANT,
  33. __version__,
  34. )
  35. UPDATE_SOURCES = {
  36. 'stable': 'yt-dlp/yt-dlp',
  37. 'nightly': 'yt-dlp/yt-dlp-nightly-builds',
  38. 'master': 'yt-dlp/yt-dlp-master-builds',
  39. }
  40. REPOSITORY = UPDATE_SOURCES['stable']
  41. _INVERSE_UPDATE_SOURCES = {value: key for key, value in UPDATE_SOURCES.items()}
  42. _VERSION_RE = re.compile(r'(\d+\.)*\d+')
  43. _HASH_PATTERN = r'[\da-f]{40}'
  44. _COMMIT_RE = re.compile(rf'Generated from: https://(?:[^/?#]+/){{3}}commit/(?P<hash>{_HASH_PATTERN})')
  45. API_BASE_URL = 'https://api.github.com/repos'
  46. # Backwards compatibility variables for the current channel
  47. API_URL = f'{API_BASE_URL}/{REPOSITORY}/releases'
  48. @functools.cache
  49. def _get_variant_and_executable_path():
  50. """@returns (variant, executable_path)"""
  51. if getattr(sys, 'frozen', False):
  52. path = sys.executable
  53. if not hasattr(sys, '_MEIPASS'):
  54. return 'py2exe', path
  55. elif sys._MEIPASS == os.path.dirname(path):
  56. return f'{sys.platform}_dir', path
  57. elif sys.platform == 'darwin':
  58. machine = '_legacy' if version_tuple(platform.mac_ver()[0]) < (10, 15) else ''
  59. else:
  60. machine = f'_{platform.machine().lower()}'
  61. # Ref: https://en.wikipedia.org/wiki/Uname#Examples
  62. if machine[1:] in ('x86', 'x86_64', 'amd64', 'i386', 'i686'):
  63. machine = '_x86' if platform.architecture()[0][:2] == '32' else ''
  64. return f'{remove_end(sys.platform, "32")}{machine}_exe', path
  65. path = os.path.dirname(__file__)
  66. if isinstance(__loader__, zipimporter):
  67. return 'zip', os.path.join(path, '..')
  68. elif (os.path.basename(sys.argv[0]) in ('__main__.py', '-m')
  69. and os.path.exists(os.path.join(path, '../.git/HEAD'))):
  70. return 'source', path
  71. return 'unknown', path
  72. def detect_variant():
  73. return VARIANT or _get_variant_and_executable_path()[0]
  74. @functools.cache
  75. def current_git_head():
  76. if detect_variant() != 'source':
  77. return
  78. with contextlib.suppress(Exception):
  79. stdout, _, _ = Popen.run(
  80. ['git', 'rev-parse', '--short', 'HEAD'],
  81. text=True, cwd=os.path.dirname(os.path.abspath(__file__)),
  82. stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  83. if re.fullmatch('[0-9a-f]+', stdout.strip()):
  84. return stdout.strip()
  85. _FILE_SUFFIXES = {
  86. 'zip': '',
  87. 'py2exe': '_min.exe',
  88. 'win_exe': '.exe',
  89. 'win_x86_exe': '_x86.exe',
  90. 'darwin_exe': '_macos',
  91. 'darwin_legacy_exe': '_macos_legacy',
  92. 'linux_exe': '_linux',
  93. 'linux_aarch64_exe': '_linux_aarch64',
  94. 'linux_armv7l_exe': '_linux_armv7l',
  95. }
  96. _NON_UPDATEABLE_REASONS = {
  97. **{variant: None for variant in _FILE_SUFFIXES}, # Updatable
  98. **{variant: f'Auto-update is not supported for unpackaged {name} executable; Re-download the latest release'
  99. for variant, name in {'win32_dir': 'Windows', 'darwin_dir': 'MacOS', 'linux_dir': 'Linux'}.items()},
  100. 'source': 'You cannot update when running from source code; Use git to pull the latest changes',
  101. 'unknown': 'You installed yt-dlp from a manual build or with a package manager; Use that to update',
  102. 'other': 'You are using an unofficial build of yt-dlp; Build the executable again',
  103. }
  104. def is_non_updateable():
  105. if UPDATE_HINT:
  106. return UPDATE_HINT
  107. return _NON_UPDATEABLE_REASONS.get(
  108. detect_variant(), _NON_UPDATEABLE_REASONS['unknown' if VARIANT else 'other'])
  109. def _get_binary_name():
  110. return format_field(_FILE_SUFFIXES, detect_variant(), template='yt-dlp%s', ignore=None, default=None)
  111. def _get_system_deprecation():
  112. MIN_SUPPORTED, MIN_RECOMMENDED = (3, 8), (3, 8)
  113. if sys.version_info > MIN_RECOMMENDED:
  114. return None
  115. major, minor = sys.version_info[:2]
  116. if sys.version_info < MIN_SUPPORTED:
  117. msg = f'Python version {major}.{minor} is no longer supported'
  118. else:
  119. msg = (f'Support for Python version {major}.{minor} has been deprecated. '
  120. '\nYou may stop receiving updates on this version at any time')
  121. major, minor = MIN_RECOMMENDED
  122. return f'{msg}! Please update to Python {major}.{minor} or above'
  123. def _sha256_file(path):
  124. h = hashlib.sha256()
  125. mv = memoryview(bytearray(128 * 1024))
  126. with open(os.path.realpath(path), 'rb', buffering=0) as f:
  127. for n in iter(lambda: f.readinto(mv), 0):
  128. h.update(mv[:n])
  129. return h.hexdigest()
  130. def _make_label(origin, tag, version=None):
  131. if '/' in origin:
  132. channel = _INVERSE_UPDATE_SOURCES.get(origin, origin)
  133. else:
  134. channel = origin
  135. label = f'{channel}@{tag}'
  136. if version and version != tag:
  137. label += f' build {version}'
  138. if channel != origin:
  139. label += f' from {origin}'
  140. return label
  141. @dataclass
  142. class UpdateInfo:
  143. """
  144. Update target information
  145. Can be created by `query_update()` or manually.
  146. Attributes:
  147. tag The release tag that will be updated to. If from query_update,
  148. the value is after API resolution and update spec processing.
  149. The only property that is required.
  150. version The actual numeric version (if available) of the binary to be updated to,
  151. after API resolution and update spec processing. (default: None)
  152. requested_version Numeric version of the binary being requested (if available),
  153. after API resolution only. (default: None)
  154. commit Commit hash (if available) of the binary to be updated to,
  155. after API resolution and update spec processing. (default: None)
  156. This value will only match the RELEASE_GIT_HEAD of prerelease builds.
  157. binary_name Filename of the binary to be updated to. (default: current binary name)
  158. checksum Expected checksum (if available) of the binary to be
  159. updated to. (default: None)
  160. """
  161. tag: str
  162. version: str | None = None
  163. requested_version: str | None = None
  164. commit: str | None = None
  165. binary_name: str | None = _get_binary_name()
  166. checksum: str | None = None
  167. _has_update = True
  168. class Updater:
  169. # XXX: use class variables to simplify testing
  170. _channel = CHANNEL
  171. _origin = ORIGIN
  172. _update_sources = UPDATE_SOURCES
  173. def __init__(self, ydl, target: str | None = None):
  174. self.ydl = ydl
  175. # For backwards compat, target needs to be treated as if it could be None
  176. self.requested_channel, sep, self.requested_tag = (target or self._channel).rpartition('@')
  177. # Check if requested_tag is actually the requested repo/channel
  178. if not sep and ('/' in self.requested_tag or self.requested_tag in self._update_sources):
  179. self.requested_channel = self.requested_tag
  180. self.requested_tag: str = None # type: ignore (we set it later)
  181. elif not self.requested_channel:
  182. # User did not specify a channel, so we are requesting the default channel
  183. self.requested_channel = self._channel.partition('@')[0]
  184. # --update should not be treated as an exact tag request even if CHANNEL has a @tag
  185. self._exact = bool(target) and target != self._channel
  186. if not self.requested_tag:
  187. # User did not specify a tag, so we request 'latest' and track that no exact tag was passed
  188. self.requested_tag = 'latest'
  189. self._exact = False
  190. if '/' in self.requested_channel:
  191. # requested_channel is actually a repository
  192. self.requested_repo = self.requested_channel
  193. if not self.requested_repo.startswith('yt-dlp/') and self.requested_repo != self._origin:
  194. self.ydl.report_warning(
  195. f'You are switching to an {self.ydl._format_err("unofficial", "red")} executable '
  196. f'from {self.ydl._format_err(self.requested_repo, self.ydl.Styles.EMPHASIS)}. '
  197. f'Run {self.ydl._format_err("at your own risk", "light red")}')
  198. self._block_restart('Automatically restarting into custom builds is disabled for security reasons')
  199. else:
  200. # Check if requested_channel resolves to a known repository or else raise
  201. self.requested_repo = self._update_sources.get(self.requested_channel)
  202. if not self.requested_repo:
  203. self._report_error(
  204. f'Invalid update channel {self.requested_channel!r} requested. '
  205. f'Valid channels are {", ".join(self._update_sources)}', True)
  206. self._identifier = f'{detect_variant()} {system_identifier()}'
  207. @property
  208. def current_version(self):
  209. """Current version"""
  210. return __version__
  211. @property
  212. def current_commit(self):
  213. """Current commit hash"""
  214. return RELEASE_GIT_HEAD
  215. def _download_asset(self, name, tag=None):
  216. if not tag:
  217. tag = self.requested_tag
  218. path = 'latest/download' if tag == 'latest' else f'download/{tag}'
  219. url = f'https://github.com/{self.requested_repo}/releases/{path}/{name}'
  220. self.ydl.write_debug(f'Downloading {name} from {url}')
  221. return self.ydl.urlopen(url).read()
  222. def _call_api(self, tag):
  223. tag = f'tags/{tag}' if tag != 'latest' else tag
  224. url = f'{API_BASE_URL}/{self.requested_repo}/releases/{tag}'
  225. self.ydl.write_debug(f'Fetching release info: {url}')
  226. return json.loads(self.ydl.urlopen(Request(url, headers={
  227. 'Accept': 'application/vnd.github+json',
  228. 'User-Agent': 'yt-dlp',
  229. 'X-GitHub-Api-Version': '2022-11-28',
  230. })).read().decode())
  231. def _get_version_info(self, tag: str) -> tuple[str | None, str | None]:
  232. if _VERSION_RE.fullmatch(tag):
  233. return tag, None
  234. api_info = self._call_api(tag)
  235. if tag == 'latest':
  236. requested_version = api_info['tag_name']
  237. else:
  238. match = re.search(rf'\s+(?P<version>{_VERSION_RE.pattern})$', api_info.get('name', ''))
  239. requested_version = match.group('version') if match else None
  240. if re.fullmatch(_HASH_PATTERN, api_info.get('target_commitish', '')):
  241. target_commitish = api_info['target_commitish']
  242. else:
  243. match = _COMMIT_RE.match(api_info.get('body', ''))
  244. target_commitish = match.group('hash') if match else None
  245. if not (requested_version or target_commitish):
  246. self._report_error('One of either version or commit hash must be available on the release', expected=True)
  247. return requested_version, target_commitish
  248. def _download_update_spec(self, source_tags):
  249. for tag in source_tags:
  250. try:
  251. return self._download_asset('_update_spec', tag=tag).decode()
  252. except network_exceptions as error:
  253. if isinstance(error, HTTPError) and error.status == 404:
  254. continue
  255. self._report_network_error(f'fetch update spec: {error}')
  256. self._report_error(
  257. f'The requested tag {self.requested_tag} does not exist for {self.requested_repo}', True)
  258. return None
  259. def _process_update_spec(self, lockfile: str, resolved_tag: str):
  260. lines = lockfile.splitlines()
  261. is_version2 = any(line.startswith('lockV2 ') for line in lines)
  262. for line in lines:
  263. if is_version2:
  264. if not line.startswith(f'lockV2 {self.requested_repo} '):
  265. continue
  266. _, _, tag, pattern = line.split(' ', 3)
  267. else:
  268. if not line.startswith('lock '):
  269. continue
  270. _, tag, pattern = line.split(' ', 2)
  271. if re.match(pattern, self._identifier):
  272. if _VERSION_RE.fullmatch(tag):
  273. if not self._exact:
  274. return tag
  275. elif self._version_compare(tag, resolved_tag):
  276. return resolved_tag
  277. elif tag != resolved_tag:
  278. continue
  279. self._report_error(
  280. f'yt-dlp cannot be updated to {resolved_tag} since you are on an older Python version', True)
  281. return None
  282. return resolved_tag
  283. def _version_compare(self, a: str, b: str):
  284. """
  285. Compare two version strings
  286. This function SHOULD NOT be called if self._exact == True
  287. """
  288. if _VERSION_RE.fullmatch(f'{a}.{b}'):
  289. return version_tuple(a) >= version_tuple(b)
  290. return a == b
  291. def query_update(self, *, _output=False) -> UpdateInfo | None:
  292. """Fetches info about the available update
  293. @returns An `UpdateInfo` if there is an update available, else None
  294. """
  295. if not self.requested_repo:
  296. self._report_error('No target repository could be determined from input')
  297. return None
  298. try:
  299. requested_version, target_commitish = self._get_version_info(self.requested_tag)
  300. except network_exceptions as e:
  301. self._report_network_error(f'obtain version info ({e})', delim='; Please try again later or')
  302. return None
  303. if self._exact and self._origin != self.requested_repo:
  304. has_update = True
  305. elif requested_version:
  306. if self._exact:
  307. has_update = self.current_version != requested_version
  308. else:
  309. has_update = not self._version_compare(self.current_version, requested_version)
  310. elif target_commitish:
  311. has_update = target_commitish != self.current_commit
  312. else:
  313. has_update = False
  314. resolved_tag = requested_version if self.requested_tag == 'latest' else self.requested_tag
  315. current_label = _make_label(self._origin, self._channel.partition("@")[2] or self.current_version, self.current_version)
  316. requested_label = _make_label(self.requested_repo, resolved_tag, requested_version)
  317. latest_or_requested = f'{"Latest" if self.requested_tag == "latest" else "Requested"} version: {requested_label}'
  318. if not has_update:
  319. if _output:
  320. self.ydl.to_screen(f'{latest_or_requested}\nyt-dlp is up to date ({current_label})')
  321. return None
  322. update_spec = self._download_update_spec(('latest', None) if requested_version else (None,))
  323. if not update_spec:
  324. return None
  325. # `result_` prefixed vars == post-_process_update_spec() values
  326. result_tag = self._process_update_spec(update_spec, resolved_tag)
  327. if not result_tag or result_tag == self.current_version:
  328. return None
  329. elif result_tag == resolved_tag:
  330. result_version = requested_version
  331. elif _VERSION_RE.fullmatch(result_tag):
  332. result_version = result_tag
  333. else: # actual version being updated to is unknown
  334. result_version = None
  335. checksum = None
  336. # Non-updateable variants can get update_info but need to skip checksum
  337. if not is_non_updateable():
  338. try:
  339. hashes = self._download_asset('SHA2-256SUMS', result_tag)
  340. except network_exceptions as error:
  341. if not isinstance(error, HTTPError) or error.status != 404:
  342. self._report_network_error(f'fetch checksums: {error}')
  343. return None
  344. self.ydl.report_warning('No hash information found for the release, skipping verification')
  345. else:
  346. for ln in hashes.decode().splitlines():
  347. if ln.endswith(_get_binary_name()):
  348. checksum = ln.split()[0]
  349. break
  350. if not checksum:
  351. self.ydl.report_warning('The hash could not be found in the checksum file, skipping verification')
  352. if _output:
  353. update_label = _make_label(self.requested_repo, result_tag, result_version)
  354. self.ydl.to_screen(
  355. f'Current version: {current_label}\n{latest_or_requested}'
  356. + (f'\nUpgradable to: {update_label}' if update_label != requested_label else ''))
  357. return UpdateInfo(
  358. tag=result_tag,
  359. version=result_version,
  360. requested_version=requested_version,
  361. commit=target_commitish if result_tag == resolved_tag else None,
  362. checksum=checksum)
  363. def update(self, update_info=NO_DEFAULT):
  364. """Update yt-dlp executable to the latest version
  365. @param update_info `UpdateInfo | None` as returned by query_update()
  366. """
  367. if update_info is NO_DEFAULT:
  368. update_info = self.query_update(_output=True)
  369. if not update_info:
  370. return False
  371. err = is_non_updateable()
  372. if err:
  373. self._report_error(err, True)
  374. return False
  375. self.ydl.to_screen(f'Current Build Hash: {_sha256_file(self.filename)}')
  376. update_label = _make_label(self.requested_repo, update_info.tag, update_info.version)
  377. self.ydl.to_screen(f'Updating to {update_label} ...')
  378. directory = os.path.dirname(self.filename)
  379. if not os.access(self.filename, os.W_OK):
  380. return self._report_permission_error(self.filename)
  381. elif not os.access(directory, os.W_OK):
  382. return self._report_permission_error(directory)
  383. new_filename, old_filename = f'{self.filename}.new', f'{self.filename}.old'
  384. if detect_variant() == 'zip': # Can be replaced in-place
  385. new_filename, old_filename = self.filename, None
  386. try:
  387. if os.path.exists(old_filename or ''):
  388. os.remove(old_filename)
  389. except OSError:
  390. return self._report_error('Unable to remove the old version')
  391. try:
  392. newcontent = self._download_asset(update_info.binary_name, update_info.tag)
  393. except network_exceptions as e:
  394. if isinstance(e, HTTPError) and e.status == 404:
  395. return self._report_error(
  396. f'The requested tag {self.requested_repo}@{update_info.tag} does not exist', True)
  397. return self._report_network_error(f'fetch updates: {e}', tag=update_info.tag)
  398. if not update_info.checksum:
  399. self._block_restart('Automatically restarting into unverified builds is disabled for security reasons')
  400. elif hashlib.sha256(newcontent).hexdigest() != update_info.checksum:
  401. return self._report_network_error('verify the new executable', tag=update_info.tag)
  402. try:
  403. with open(new_filename, 'wb') as outf:
  404. outf.write(newcontent)
  405. except OSError:
  406. return self._report_permission_error(new_filename)
  407. if old_filename:
  408. mask = os.stat(self.filename).st_mode
  409. try:
  410. os.rename(self.filename, old_filename)
  411. except OSError:
  412. return self._report_error('Unable to move current version')
  413. try:
  414. os.rename(new_filename, self.filename)
  415. except OSError:
  416. self._report_error('Unable to overwrite current version')
  417. return os.rename(old_filename, self.filename)
  418. variant = detect_variant()
  419. if variant.startswith('win') or variant == 'py2exe':
  420. atexit.register(Popen, f'ping 127.0.0.1 -n 5 -w 1000 & del /F "{old_filename}"',
  421. shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
  422. elif old_filename:
  423. try:
  424. os.remove(old_filename)
  425. except OSError:
  426. self._report_error('Unable to remove the old version')
  427. try:
  428. os.chmod(self.filename, mask)
  429. except OSError:
  430. return self._report_error(
  431. f'Unable to set permissions. Run: sudo chmod a+rx {compat_shlex_quote(self.filename)}')
  432. self.ydl.to_screen(f'Updated yt-dlp to {update_label}')
  433. return True
  434. @functools.cached_property
  435. def filename(self):
  436. """Filename of the executable"""
  437. return compat_realpath(_get_variant_and_executable_path()[1])
  438. @functools.cached_property
  439. def cmd(self):
  440. """The command-line to run the executable, if known"""
  441. # There is no sys.orig_argv in py < 3.10. Also, it can be [] when frozen
  442. if getattr(sys, 'orig_argv', None):
  443. return sys.orig_argv
  444. elif getattr(sys, 'frozen', False):
  445. return sys.argv
  446. def restart(self):
  447. """Restart the executable"""
  448. assert self.cmd, 'Must be frozen or Py >= 3.10'
  449. self.ydl.write_debug(f'Restarting: {shell_quote(self.cmd)}')
  450. _, _, returncode = Popen.run(self.cmd)
  451. return returncode
  452. def _block_restart(self, msg):
  453. def wrapper():
  454. self._report_error(f'{msg}. Restart yt-dlp to use the updated version', expected=True)
  455. return self.ydl._download_retcode
  456. self.restart = wrapper
  457. def _report_error(self, msg, expected=False):
  458. self.ydl.report_error(msg, tb=False if expected else None)
  459. self.ydl._download_retcode = 100
  460. def _report_permission_error(self, file):
  461. self._report_error(f'Unable to write to {file}; try running as administrator', True)
  462. def _report_network_error(self, action, delim=';', tag=None):
  463. if not tag:
  464. tag = self.requested_tag
  465. self._report_error(
  466. f'Unable to {action}{delim} visit https://github.com/{self.requested_repo}/releases/'
  467. + tag if tag == "latest" else f"tag/{tag}", True)
  468. # XXX: Everything below this line in this class is deprecated / for compat only
  469. @property
  470. def _target_tag(self):
  471. """Deprecated; requested tag with 'tags/' prepended when necessary for API calls"""
  472. return f'tags/{self.requested_tag}' if self.requested_tag != 'latest' else self.requested_tag
  473. def _check_update(self):
  474. """Deprecated; report whether there is an update available"""
  475. return bool(self.query_update(_output=True))
  476. def __getattr__(self, attribute: str):
  477. """Compat getter function for deprecated attributes"""
  478. deprecated_props_map = {
  479. 'check_update': '_check_update',
  480. 'target_tag': '_target_tag',
  481. 'target_channel': 'requested_channel',
  482. }
  483. update_info_props_map = {
  484. 'has_update': '_has_update',
  485. 'new_version': 'version',
  486. 'latest_version': 'requested_version',
  487. 'release_name': 'binary_name',
  488. 'release_hash': 'checksum',
  489. }
  490. if attribute not in deprecated_props_map and attribute not in update_info_props_map:
  491. raise AttributeError(f'{type(self).__name__!r} object has no attribute {attribute!r}')
  492. msg = f'{type(self).__name__}.{attribute} is deprecated and will be removed in a future version'
  493. if attribute in deprecated_props_map:
  494. source_name = deprecated_props_map[attribute]
  495. if not source_name.startswith('_'):
  496. msg += f'. Please use {source_name!r} instead'
  497. source = self
  498. mapping = deprecated_props_map
  499. else: # attribute in update_info_props_map
  500. msg += '. Please call query_update() instead'
  501. source = self.query_update()
  502. if source is None:
  503. source = UpdateInfo('', None, None, None)
  504. source._has_update = False
  505. mapping = update_info_props_map
  506. deprecation_warning(msg)
  507. for target_name, source_name in mapping.items():
  508. value = getattr(source, source_name)
  509. setattr(self, target_name, value)
  510. return getattr(self, attribute)
  511. def run_update(ydl):
  512. """Update the program file with the latest version from the repository
  513. @returns Whether there was a successful update (No update = False)
  514. """
  515. return Updater(ydl).update()
  516. __all__ = ['Updater']