diff options
Diffstat (limited to 'devscripts/gh-pages.unused')
-rw-r--r-- | devscripts/gh-pages.unused/add-version.py | 43 | ||||
-rw-r--r-- | devscripts/gh-pages.unused/generate-download.py | 22 | ||||
-rw-r--r-- | devscripts/gh-pages.unused/sign-versions.py | 34 | ||||
-rw-r--r-- | devscripts/gh-pages.unused/update-copyright.py | 21 | ||||
-rw-r--r-- | devscripts/gh-pages.unused/update-feed.py | 76 | ||||
-rw-r--r-- | devscripts/gh-pages.unused/update-sites.py | 37 |
6 files changed, 233 insertions, 0 deletions
diff --git a/devscripts/gh-pages.unused/add-version.py b/devscripts/gh-pages.unused/add-version.py new file mode 100644 index 000000000..9ea01374d --- /dev/null +++ b/devscripts/gh-pages.unused/add-version.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python3 +from __future__ import unicode_literals + +import json +import sys +import hashlib +import os.path + + +if len(sys.argv) <= 1: + print('Specify the version number as parameter') + sys.exit() +version = sys.argv[1] + +with open('update/LATEST_VERSION', 'w') as f: + f.write(version) + +versions_info = json.load(open('update/versions.json')) +if 'signature' in versions_info: + del versions_info['signature'] + +new_version = {} + +filenames = { + 'bin': 'yt-dlp', + 'exe': 'yt-dlp.exe', + 'tar': 'yt-dlp-%s.tar.gz' % version} +build_dir = os.path.join('..', '..', 'build', version) +for key, filename in filenames.items(): + url = 'https://yt-dl.org/downloads/%s/%s' % (version, filename) + fn = os.path.join(build_dir, filename) + with open(fn, 'rb') as f: + data = f.read() + if not data: + raise ValueError('File %s is empty!' % fn) + sha256sum = hashlib.sha256(data).hexdigest() + new_version[key] = (url, sha256sum) + +versions_info['versions'][version] = new_version +versions_info['latest'] = version + +with open('update/versions.json', 'w') as jsonf: + json.dump(versions_info, jsonf, indent=4, sort_keys=True) diff --git a/devscripts/gh-pages.unused/generate-download.py b/devscripts/gh-pages.unused/generate-download.py new file mode 100644 index 000000000..a873d32ee --- /dev/null +++ b/devscripts/gh-pages.unused/generate-download.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 +from __future__ import unicode_literals + +import json + +versions_info = json.load(open('update/versions.json')) +version = versions_info['latest'] +version_dict = versions_info['versions'][version] + +# Read template page +with open('download.html.in', 'r', encoding='utf-8') as tmplf: + template = tmplf.read() + +template = template.replace('@PROGRAM_VERSION@', version) +template = template.replace('@PROGRAM_URL@', version_dict['bin'][0]) +template = template.replace('@PROGRAM_SHA256SUM@', version_dict['bin'][1]) +template = template.replace('@EXE_URL@', version_dict['exe'][0]) +template = template.replace('@EXE_SHA256SUM@', version_dict['exe'][1]) +template = template.replace('@TAR_URL@', version_dict['tar'][0]) +template = template.replace('@TAR_SHA256SUM@', version_dict['tar'][1]) +with open('download.html', 'w', encoding='utf-8') as dlf: + dlf.write(template) diff --git a/devscripts/gh-pages.unused/sign-versions.py b/devscripts/gh-pages.unused/sign-versions.py new file mode 100644 index 000000000..fa389c358 --- /dev/null +++ b/devscripts/gh-pages.unused/sign-versions.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 +from __future__ import unicode_literals, with_statement + +import rsa +import json +from binascii import hexlify + +try: + input = raw_input +except NameError: + pass + +versions_info = json.load(open('update/versions.json')) +if 'signature' in versions_info: + del versions_info['signature'] + +print('Enter the PKCS1 private key, followed by a blank line:') +privkey = b'' +while True: + try: + line = input() + except EOFError: + break + if line == '': + break + privkey += line.encode('ascii') + b'\n' +privkey = rsa.PrivateKey.load_pkcs1(privkey) + +signature = hexlify(rsa.pkcs1.sign(json.dumps(versions_info, sort_keys=True).encode('utf-8'), privkey, 'SHA-256')).decode() +print('signature: ' + signature) + +versions_info['signature'] = signature +with open('update/versions.json', 'w') as versionsf: + json.dump(versions_info, versionsf, indent=4, sort_keys=True) diff --git a/devscripts/gh-pages.unused/update-copyright.py b/devscripts/gh-pages.unused/update-copyright.py new file mode 100644 index 000000000..e122d0283 --- /dev/null +++ b/devscripts/gh-pages.unused/update-copyright.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python3 +# coding: utf-8 + +from __future__ import with_statement, unicode_literals + +import datetime +import glob +import io # For Python 2 compatibility +import os +import re + +year = str(datetime.datetime.now().year) +for fn in glob.glob('*.html*'): + with io.open(fn, encoding='utf-8') as f: + content = f.read() + newc = re.sub(r'(?P<copyright>Copyright © 2011-)(?P<year>[0-9]{4})', 'Copyright © 2011-' + year, content) + if content != newc: + tmpFn = fn + '.part' + with io.open(tmpFn, 'wt', encoding='utf-8') as outf: + outf.write(newc) + os.rename(tmpFn, fn) diff --git a/devscripts/gh-pages.unused/update-feed.py b/devscripts/gh-pages.unused/update-feed.py new file mode 100644 index 000000000..c9f2fdb07 --- /dev/null +++ b/devscripts/gh-pages.unused/update-feed.py @@ -0,0 +1,76 @@ +#!/usr/bin/env python3 +from __future__ import unicode_literals + +import datetime +import io +import json +import textwrap + + +atom_template = textwrap.dedent("""\ + <?xml version="1.0" encoding="utf-8"?> + <feed xmlns="http://www.w3.org/2005/Atom"> + <link rel="self" href="http://ytdl-org.github.io/youtube-dl/update/releases.atom" /> + <title>yt-dlp releases</title> + <id>https://yt-dl.org/feed/yt-dlp-updates-feed</id> + <updated>@TIMESTAMP@</updated> + @ENTRIES@ + </feed>""") + +entry_template = textwrap.dedent(""" + <entry> + <id>https://yt-dl.org/feed/yt-dlp-updates-feed/yt-dlp-@VERSION@</id> + <title>New version @VERSION@</title> + <link href="http://ytdl-org.github.io/yt-dlp" /> + <content type="xhtml"> + <div xmlns="http://www.w3.org/1999/xhtml"> + Downloads available at <a href="https://yt-dl.org/downloads/@VERSION@/">https://yt-dl.org/downloads/@VERSION@/</a> + </div> + </content> + <author> + <name>The yt-dlp maintainers</name> + </author> + <updated>@TIMESTAMP@</updated> + </entry> + """) + +now = datetime.datetime.now() +now_iso = now.isoformat() + 'Z' + +atom_template = atom_template.replace('@TIMESTAMP@', now_iso) + +versions_info = json.load(open('update/versions.json')) +versions = list(versions_info['versions'].keys()) +versions.sort() + +entries = [] +for v in versions: + fields = v.split('.') + year, month, day = map(int, fields[:3]) + faked = 0 + patchlevel = 0 + while True: + try: + datetime.date(year, month, day) + except ValueError: + day -= 1 + faked += 1 + assert day > 0 + continue + break + if len(fields) >= 4: + try: + patchlevel = int(fields[3]) + except ValueError: + patchlevel = 1 + timestamp = '%04d-%02d-%02dT00:%02d:%02dZ' % (year, month, day, faked, patchlevel) + + entry = entry_template.replace('@TIMESTAMP@', timestamp) + entry = entry.replace('@VERSION@', v) + entries.append(entry) + +entries_str = textwrap.indent(''.join(entries), '\t') +atom_template = atom_template.replace('@ENTRIES@', entries_str) + +with io.open('update/releases.atom', 'w', encoding='utf-8') as atom_file: + atom_file.write(atom_template) diff --git a/devscripts/gh-pages.unused/update-sites.py b/devscripts/gh-pages.unused/update-sites.py new file mode 100644 index 000000000..b53685fcc --- /dev/null +++ b/devscripts/gh-pages.unused/update-sites.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python3 +from __future__ import unicode_literals + +import sys +import os +import textwrap + +# We must be able to import yt_dlp +sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) + +import yt_dlp + + +def main(): + with open('supportedsites.html.in', 'r', encoding='utf-8') as tmplf: + template = tmplf.read() + + ie_htmls = [] + for ie in yt_dlp.list_extractors(age_limit=None): + ie_html = '<b>{}</b>'.format(ie.IE_NAME) + ie_desc = getattr(ie, 'IE_DESC', None) + if ie_desc is False: + continue + elif ie_desc is not None: + ie_html += ': {}'.format(ie.IE_DESC) + if not ie.working(): + ie_html += ' (Currently broken)' + ie_htmls.append('<li>{}</li>'.format(ie_html)) + + template = template.replace('@SITES@', textwrap.indent('\n'.join(ie_htmls), '\t')) + + with open('supportedsites.html', 'w', encoding='utf-8') as sitesf: + sitesf.write(template) + + +if __name__ == '__main__': + main() |