1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-09-03 16:45:17 +00:00

Add version to infojson

This commit is contained in:
pukkandan
2022-08-24 13:03:33 +05:30
parent 2516cafb28
commit b5e7a2e69d
2 changed files with 25 additions and 14 deletions

View File

@ -1,4 +1,5 @@
import atexit
import contextlib
import hashlib
import json
import os
@ -50,6 +51,19 @@ def detect_variant():
return VARIANT or _get_variant_and_executable_path()[0]
@functools.cache
def current_git_head():
if detect_variant() != 'source':
return
with contextlib.suppress(Exception):
stdout, _, _ = Popen.run(
['git', 'rev-parse', '--short', 'HEAD'],
text=True, cwd=os.path.dirname(os.path.abspath(__file__)),
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if re.fullmatch('[0-9a-f]+', stdout.strip()):
return stdout.strip()
_FILE_SUFFIXES = {
'zip': '',
'py2exe': '_min.exe',