]>
jfr.im git - yt-dlp.git/blob - devscripts/update-formulae.py
4 Usage: python3 ./devscripts/update-formulae.py <path-to-formulae-rb> <version>
5 version can be either 0-aligned (yt-dlp version) or normalized (PyPi version)
8 # Allow direct execution
12 sys
.path
.insert(0, os
.path
.dirname(os
.path
.dirname(os
.path
.abspath(__file__
))))
19 from devscripts
.utils
import read_file
, write_file
21 filename
, version
= sys
.argv
[1:]
23 normalized_version
= '.'.join(str(int(x
)) for x
in version
.split('.'))
25 pypi_release
= json
.loads(urllib
.request
.urlopen(
26 'https://pypi.org/pypi/yt-dlp/%s/json' % normalized_version
29 tarball_file
= next(x
for x
in pypi_release
['urls'] if x
['filename'].endswith('.tar.gz'))
31 sha256sum
= tarball_file
['digests']['sha256']
32 url
= tarball_file
['url']
34 formulae_text
= read_file(filename
)
36 formulae_text
= re
.sub(r
'sha256 "[0-9a-f]*?"', 'sha256 "%s"' % sha256sum
, formulae_text
, count
=1)
37 formulae_text
= re
.sub(r
'url "[^"]*?"', 'url "%s"' % url
, formulae_text
, count
=1)
39 write_file(filename
, formulae_text
)