From 9d83ad93d04a1e16fe4a2acadf5f9f10bef6d1b9 Mon Sep 17 00:00:00 2001 From: pukkandan Date: Sat, 5 Jun 2021 21:25:06 +0530 Subject: [cleanup] Mark unused files --- devscripts/buildserver.py | 2 + devscripts/gh-pages.unused/add-version.py | 43 ++++++++++++++ devscripts/gh-pages.unused/generate-download.py | 22 +++++++ devscripts/gh-pages.unused/sign-versions.py | 34 +++++++++++ devscripts/gh-pages.unused/update-copyright.py | 21 +++++++ devscripts/gh-pages.unused/update-feed.py | 76 +++++++++++++++++++++++++ devscripts/gh-pages.unused/update-sites.py | 37 ++++++++++++ devscripts/gh-pages/add-version.py | 43 -------------- devscripts/gh-pages/generate-download.py | 22 ------- devscripts/gh-pages/sign-versions.py | 34 ----------- devscripts/gh-pages/update-copyright.py | 21 ------- devscripts/gh-pages/update-feed.py | 76 ------------------------- devscripts/gh-pages/update-sites.py | 37 ------------ devscripts/release.sh | 1 + devscripts/wine-py2exe.sh | 2 + 15 files changed, 238 insertions(+), 233 deletions(-) create mode 100644 devscripts/gh-pages.unused/add-version.py create mode 100644 devscripts/gh-pages.unused/generate-download.py create mode 100644 devscripts/gh-pages.unused/sign-versions.py create mode 100644 devscripts/gh-pages.unused/update-copyright.py create mode 100644 devscripts/gh-pages.unused/update-feed.py create mode 100644 devscripts/gh-pages.unused/update-sites.py delete mode 100755 devscripts/gh-pages/add-version.py delete mode 100755 devscripts/gh-pages/generate-download.py delete mode 100755 devscripts/gh-pages/sign-versions.py delete mode 100755 devscripts/gh-pages/update-copyright.py delete mode 100755 devscripts/gh-pages/update-feed.py delete mode 100755 devscripts/gh-pages/update-sites.py (limited to 'devscripts') diff --git a/devscripts/buildserver.py b/devscripts/buildserver.py index 9b5305a67..cd544b816 100644 --- a/devscripts/buildserver.py +++ b/devscripts/buildserver.py @@ -1,3 +1,5 @@ +# UNUSED + #!/usr/bin/python3 import argparse 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'(?PCopyright © 2011-)(?P[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("""\ + + + + yt-dlp releases + https://yt-dl.org/feed/yt-dlp-updates-feed + @TIMESTAMP@ + @ENTRIES@ + """) + +entry_template = textwrap.dedent(""" + + https://yt-dl.org/feed/yt-dlp-updates-feed/yt-dlp-@VERSION@ + New version @VERSION@ + + +
+ Downloads available at https://yt-dl.org/downloads/@VERSION@/ +
+
+ + The yt-dlp maintainers + + @TIMESTAMP@ +
+ """) + +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 = '{}'.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('
  • {}
  • '.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() diff --git a/devscripts/gh-pages/add-version.py b/devscripts/gh-pages/add-version.py deleted file mode 100755 index 9ea01374d..000000000 --- a/devscripts/gh-pages/add-version.py +++ /dev/null @@ -1,43 +0,0 @@ -#!/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/generate-download.py b/devscripts/gh-pages/generate-download.py deleted file mode 100755 index a873d32ee..000000000 --- a/devscripts/gh-pages/generate-download.py +++ /dev/null @@ -1,22 +0,0 @@ -#!/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/sign-versions.py b/devscripts/gh-pages/sign-versions.py deleted file mode 100755 index fa389c358..000000000 --- a/devscripts/gh-pages/sign-versions.py +++ /dev/null @@ -1,34 +0,0 @@ -#!/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/update-copyright.py b/devscripts/gh-pages/update-copyright.py deleted file mode 100755 index e122d0283..000000000 --- a/devscripts/gh-pages/update-copyright.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/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'(?PCopyright © 2011-)(?P[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/update-feed.py b/devscripts/gh-pages/update-feed.py deleted file mode 100755 index c9f2fdb07..000000000 --- a/devscripts/gh-pages/update-feed.py +++ /dev/null @@ -1,76 +0,0 @@ -#!/usr/bin/env python3 -from __future__ import unicode_literals - -import datetime -import io -import json -import textwrap - - -atom_template = textwrap.dedent("""\ - - - - yt-dlp releases - https://yt-dl.org/feed/yt-dlp-updates-feed - @TIMESTAMP@ - @ENTRIES@ - """) - -entry_template = textwrap.dedent(""" - - https://yt-dl.org/feed/yt-dlp-updates-feed/yt-dlp-@VERSION@ - New version @VERSION@ - - -
    - Downloads available at https://yt-dl.org/downloads/@VERSION@/ -
    -
    - - The yt-dlp maintainers - - @TIMESTAMP@ -
    - """) - -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/update-sites.py b/devscripts/gh-pages/update-sites.py deleted file mode 100755 index b53685fcc..000000000 --- a/devscripts/gh-pages/update-sites.py +++ /dev/null @@ -1,37 +0,0 @@ -#!/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 = '{}'.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('
  • {}
  • '.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() diff --git a/devscripts/release.sh b/devscripts/release.sh index d0266f391..188b166e6 100755 --- a/devscripts/release.sh +++ b/devscripts/release.sh @@ -1,4 +1,5 @@ # Unused + #!/bin/bash # IMPORTANT: the following assumptions are made diff --git a/devscripts/wine-py2exe.sh b/devscripts/wine-py2exe.sh index dc2d6501a..8bc8ce55b 100755 --- a/devscripts/wine-py2exe.sh +++ b/devscripts/wine-py2exe.sh @@ -1,3 +1,5 @@ +# UNUSED + #!/bin/bash # Run with as parameter a setup.py that works in the current directory -- cgit v1.2.3