mirror of
				https://github.com/yt-dlp/yt-dlp.git
				synced 2025-10-31 06:35:12 +00:00 
			
		
		
		
	[cleanup] Misc cleanup and refactor (#2173)
This commit is contained in:
		| @@ -6,22 +6,25 @@ import re | ||||
| import sys | ||||
| 
 | ||||
| README_FILE = 'README.md' | ||||
| helptext = sys.stdin.read() | ||||
| 
 | ||||
| OPTIONS_START = 'General Options:' | ||||
| OPTIONS_END = 'CONFIGURATION' | ||||
| EPILOG_START = 'See full documentation' | ||||
| 
 | ||||
| 
 | ||||
| helptext = sys.stdin.read() | ||||
| if isinstance(helptext, bytes): | ||||
|     helptext = helptext.decode('utf-8') | ||||
| 
 | ||||
| start, end = helptext.index(f'\n  {OPTIONS_START}'), helptext.index(f'\n{EPILOG_START}') | ||||
| options = re.sub(r'(?m)^  (\w.+)$', r'## \1', helptext[start + 1: end + 1]) | ||||
| 
 | ||||
| with open(README_FILE, encoding='utf-8') as f: | ||||
|     oldreadme = f.read() | ||||
|     readme = f.read() | ||||
| 
 | ||||
| header = oldreadme[:oldreadme.index('## General Options:')] | ||||
| footer = oldreadme[oldreadme.index('# CONFIGURATION'):] | ||||
| 
 | ||||
| options = helptext[helptext.index('  General Options:'):] | ||||
| options = re.sub(r'(?m)^  (\w.+)$', r'## \1', options) | ||||
| options = options + '\n' | ||||
| header = readme[:readme.index(f'## {OPTIONS_START}')] | ||||
| footer = readme[readme.index(f'# {OPTIONS_END}'):] | ||||
| 
 | ||||
| with open(README_FILE, 'w', encoding='utf-8') as f: | ||||
|     f.write(header) | ||||
|     f.write(options) | ||||
|     f.write(footer) | ||||
|     for part in (header, options, footer): | ||||
|         f.write(part) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 pukkandan
					pukkandan