]> jfr.im git - yt-dlp.git/blobdiff - devscripts/make_issue_template.py
[cleanup] Misc (#8182)
[yt-dlp.git] / devscripts / make_issue_template.py
index 90e7e0b43e7b16c00a2acc2f74edcfccb3315d87..39b95c8da68a58248cc1fca106da838972d091a8 100644 (file)
@@ -7,20 +7,14 @@
 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 
 
-import optparse
 import re
 
-
-def read(fname):
-    with open(fname, encoding='utf-8') as f:
-        return f.read()
-
-
-# Get the version without importing the package
-def read_version(fname):
-    exec(compile(read(fname), fname, 'exec'))
-    return locals()['__version__']
-
+from devscripts.utils import (
+    get_filename_args,
+    read_file,
+    read_version,
+    write_file,
+)
 
 VERBOSE_TMPL = '''
   - type: checkboxes
@@ -30,6 +24,8 @@ def read_version(fname):
       options:
         - label: Run **your** yt-dlp command with **-vU** flag added (`yt-dlp -vU <your command line>`)
           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
@@ -58,20 +54,24 @@ def read_version(fname):
       required: true
 '''.strip()
 
+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()
 
-def main():
-    parser = optparse.OptionParser(usage='%prog INFILE OUTFILE')
-    _, args = parser.parse_args()
-    if len(args) != 2:
-        parser.error('Expected an input and an output filename')
 
-    fields = {'version': read_version('yt_dlp/version.py')}
+def main():
+    fields = {'version': read_version(), '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 = args
-    with open(outfile, 'w', encoding='utf-8') as outf:
-        outf.write(read(infile) % fields)
+    infile, outfile = get_filename_args(has_infile=True)
+    write_file(outfile, read_file(infile) % fields)
 
 
 if __name__ == '__main__':