make_issue_template.py 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #!/usr/bin/env python3
  2. # Allow direct execution
  3. import os
  4. import sys
  5. sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
  6. import optparse
  7. import re
  8. def read(fname):
  9. with open(fname, encoding='utf-8') as f:
  10. return f.read()
  11. # Get the version without importing the package
  12. def read_version(fname):
  13. exec(compile(read(fname), fname, 'exec'))
  14. return locals()['__version__']
  15. VERBOSE_TMPL = '''
  16. - type: checkboxes
  17. id: verbose
  18. attributes:
  19. label: Provide verbose output that clearly demonstrates the problem
  20. options:
  21. - label: Run **your** yt-dlp command with **-vU** flag added (`yt-dlp -vU <your command line>`)
  22. required: true
  23. - label: Copy the WHOLE output (starting with `[debug] Command-line config`) and insert it below
  24. required: true
  25. - type: textarea
  26. id: log
  27. attributes:
  28. label: Complete Verbose Output
  29. description: |
  30. It should start like this:
  31. placeholder: |
  32. [debug] Command-line config: ['-vU', 'test:youtube']
  33. [debug] Portable config "yt-dlp.conf": ['-i']
  34. [debug] Encodings: locale cp65001, fs utf-8, pref cp65001, out utf-8, error utf-8, screen utf-8
  35. [debug] yt-dlp version %(version)s [9d339c4] (win32_exe)
  36. [debug] Python 3.8.10 (CPython 64bit) - Windows-10-10.0.22000-SP0
  37. [debug] Checking exe version: ffmpeg -bsfs
  38. [debug] Checking exe version: ffprobe -bsfs
  39. [debug] exe versions: ffmpeg N-106550-g072101bd52-20220410 (fdk,setts), ffprobe N-106624-g391ce570c8-20220415, phantomjs 2.1.1
  40. [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
  41. [debug] Proxy map: {}
  42. [debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest
  43. Latest version: %(version)s, Current version: %(version)s
  44. yt-dlp is up to date (%(version)s)
  45. <more lines>
  46. render: shell
  47. validations:
  48. required: true
  49. '''.strip()
  50. def main():
  51. parser = optparse.OptionParser(usage='%prog INFILE OUTFILE')
  52. _, args = parser.parse_args()
  53. if len(args) != 2:
  54. parser.error('Expected an input and an output filename')
  55. fields = {'version': read_version('yt_dlp/version.py')}
  56. fields['verbose'] = VERBOSE_TMPL % fields
  57. fields['verbose_optional'] = re.sub(r'(\n\s+validations:)?\n\s+required: true', '', fields['verbose'])
  58. infile, outfile = args
  59. with open(outfile, 'w', encoding='utf-8') as outf:
  60. outf.write(read(infile) % fields)
  61. if __name__ == '__main__':
  62. main()