mirror of
				https://github.com/yt-dlp/yt-dlp.git
				synced 2025-10-31 06:35:12 +00:00 
			
		
		
		
	Add format type B for outtmpl to treat the value as bytes
				
					
				
			This is useful to limit the filename to a certain number of bytes rather than characters Closes #1003
This commit is contained in:
		| @@ -907,7 +907,7 @@ class YoutubeDL(object): | ||||
|     def validate_outtmpl(cls, outtmpl): | ||||
|         ''' @return None or Exception object ''' | ||||
|         outtmpl = re.sub( | ||||
|             STR_FORMAT_RE_TMPL.format('[^)]*', '[ljq]'), | ||||
|             STR_FORMAT_RE_TMPL.format('[^)]*', '[ljqB]'), | ||||
|             lambda mobj: f'{mobj.group(0)[:-1]}s', | ||||
|             cls._outtmpl_expandpath(outtmpl)) | ||||
|         try: | ||||
| @@ -939,7 +939,7 @@ class YoutubeDL(object): | ||||
|         } | ||||
|  | ||||
|         TMPL_DICT = {} | ||||
|         EXTERNAL_FORMAT_RE = re.compile(STR_FORMAT_RE_TMPL.format('[^)]*', f'[{STR_FORMAT_TYPES}ljq]')) | ||||
|         EXTERNAL_FORMAT_RE = re.compile(STR_FORMAT_RE_TMPL.format('[^)]*', f'[{STR_FORMAT_TYPES}ljqB]')) | ||||
|         MATH_FUNCTIONS = { | ||||
|             '+': float.__add__, | ||||
|             '-': float.__sub__, | ||||
| @@ -1031,6 +1031,9 @@ class YoutubeDL(object): | ||||
|                 value, fmt = json.dumps(value, default=_dumpjson_default), str_fmt | ||||
|             elif fmt[-1] == 'q': | ||||
|                 value, fmt = compat_shlex_quote(str(value)), str_fmt | ||||
|             elif fmt[-1] == 'B': | ||||
|                 value = f'%{str_fmt}'.encode('utf-8') % str(value).encode('utf-8') | ||||
|                 value, fmt = value.decode('utf-8', 'ignore'), 's' | ||||
|             elif fmt[-1] == 'c': | ||||
|                 value = str(value) | ||||
|                 if value is None: | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 pukkandan
					pukkandan