mirror of https://github.com/yt-dlp/yt-dlp.git
[metadataparser] Don't set `None` when the field didn't match
Fixes: https://github.com/ytdl-org/youtube-dl/issues/31118#issuecomment-1198254512
This commit is contained in:
parent
2eae7d507c
commit
4f547d6d2c
|
@ -1,7 +1,7 @@
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from .common import PostProcessor
|
from .common import PostProcessor
|
||||||
from ..utils import Namespace
|
from ..utils import Namespace, filter_dict
|
||||||
|
|
||||||
|
|
||||||
class MetadataParserPP(PostProcessor):
|
class MetadataParserPP(PostProcessor):
|
||||||
|
@ -68,9 +68,9 @@ class MetadataParserPP(PostProcessor):
|
||||||
if match is None:
|
if match is None:
|
||||||
self.to_screen(f'Could not interpret {inp!r} as {out!r}')
|
self.to_screen(f'Could not interpret {inp!r} as {out!r}')
|
||||||
return
|
return
|
||||||
for attribute, value in match.groupdict().items():
|
for attribute, value in filter_dict(match.groupdict()).items():
|
||||||
info[attribute] = value
|
info[attribute] = value
|
||||||
self.to_screen('Parsed %s from %r: %r' % (attribute, template, value if value is not None else 'NA'))
|
self.to_screen(f'Parsed {attribute} from {template!r}: {value!r}')
|
||||||
|
|
||||||
template = self.field_to_template(inp)
|
template = self.field_to_template(inp)
|
||||||
out_re = re.compile(self.format_to_regex(out))
|
out_re = re.compile(self.format_to_regex(out))
|
||||||
|
|
Loading…
Reference in New Issue