X-Git-Url: https://jfr.im/git/yt-dlp.git/blobdiff_plain/cb2ea2d5efea3c419d04da9132fb42a89a43ab96..5c019f6328ad40d66561eac3c4de0b3cd070d0f6:/devscripts/make_issue_template.py diff --git a/devscripts/make_issue_template.py b/devscripts/make_issue_template.py index 37cb0d4ee..a5d59f3c0 100644 --- a/devscripts/make_issue_template.py +++ b/devscripts/make_issue_template.py @@ -1,29 +1,72 @@ -#!/usr/bin/env python -from __future__ import unicode_literals +#!/usr/bin/env python3 -import io -import optparse +# Allow direct execution +import os +import sys +sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -def main(): - parser = optparse.OptionParser(usage='%prog INFILE OUTFILE') - options, args = parser.parse_args() - if len(args) != 2: - parser.error('Expected an input and an output filename') - infile, outfile = args +import re + +from devscripts.utils import get_filename_args, read_file, write_file + +VERBOSE_TMPL = ''' + - type: checkboxes + id: verbose + attributes: + label: Provide verbose output that clearly demonstrates the problem + options: + - label: Run **your** yt-dlp command with **-vU** flag added (`yt-dlp -vU `) + required: true + - label: "If using API, add `'verbose': True` to `YoutubeDL` params instead" + required: false + - label: Copy the WHOLE output (starting with `[debug] Command-line config`) and insert it below + required: true + - type: textarea + id: log + attributes: + label: Complete Verbose Output + description: | + It should start like this: + placeholder: | + [debug] Command-line config: ['-vU', 'https://www.youtube.com/watch?v=BaW_jenozKc'] + [debug] Encodings: locale cp65001, fs utf-8, pref cp65001, out utf-8, error utf-8, screen utf-8 + [debug] yt-dlp version nightly@... from yt-dlp/yt-dlp [b634ba742] (win_exe) + [debug] Python 3.8.10 (CPython 64bit) - Windows-10-10.0.22000-SP0 + [debug] exe versions: ffmpeg N-106550-g072101bd52-20220410 (fdk,setts), ffprobe N-106624-g391ce570c8-20220415, phantomjs 2.1.1 + [debug] Optional libraries: Cryptodome-3.15.0, brotli-1.0.9, certifi-2022.06.15, mutagen-1.45.1, sqlite3-2.6.0, websockets-10.3 + [debug] Proxy map: {} + [debug] Request Handlers: urllib, requests + [debug] Loaded 1893 extractors + [debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp-nightly-builds/releases/latest + yt-dlp is up to date (nightly@... from yt-dlp/yt-dlp-nightly-builds) + [youtube] Extracting URL: https://www.youtube.com/watch?v=BaW_jenozKc + + render: shell + validations: + required: true +'''.strip() - with io.open(infile, encoding='utf-8') as inf: - issue_template_tmpl = inf.read() +NO_SKIP = ''' + - type: checkboxes + attributes: + label: DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE + description: Fill all fields even if you think it is irrelevant for the issue + options: + - label: I understand that I will be **blocked** if I *intentionally* remove or skip any mandatory\\* field + required: true +'''.strip() - # Get the version from youtube_dlc/version.py without importing the package - exec(compile(open('youtube_dlc/version.py').read(), - 'youtube_dlc/version.py', 'exec')) - out = issue_template_tmpl % {'version': locals()['__version__']} +def main(): + fields = {'no_skip': NO_SKIP} + fields['verbose'] = VERBOSE_TMPL % fields + fields['verbose_optional'] = re.sub(r'(\n\s+validations:)?\n\s+required: true', '', fields['verbose']) + + infile, outfile = get_filename_args(has_infile=True) + write_file(outfile, read_file(infile) % fields) - with io.open(outfile, 'w', encoding='utf-8') as outf: - outf.write(out) if __name__ == '__main__': main()