mirror of
https://github.com/novoid/guess-filename.py.git
synced 2026-02-16 13:24:15 +00:00
further character sanitization: brackets
This commit is contained in:
parent
b9825617a8
commit
42016beaf1
1 changed files with 4 additions and 2 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
PROG_VERSION = u"Time-stamp: <2024-11-16 12:53:10 vk>"
|
PROG_VERSION = u"Time-stamp: <2024-11-17 16:07:55 vk>"
|
||||||
|
|
||||||
|
|
||||||
# TODO:
|
# TODO:
|
||||||
|
|
@ -1036,7 +1036,9 @@ class GuessFilename(object):
|
||||||
'required meta data for YouTube download file style')
|
'required meta data for YouTube download file style')
|
||||||
# example from unit tests: "2007-09-13 youtube - The Star7 PDA Prototype - Ahg8OBYixL0.mp4"
|
# example from unit tests: "2007-09-13 youtube - The Star7 PDA Prototype - Ahg8OBYixL0.mp4"
|
||||||
# sanitizing title since it may contain characters that are not valid or practical in a file name:
|
# sanitizing title since it may contain characters that are not valid or practical in a file name:
|
||||||
sanitized_title = data['fulltitle'].replace('/', '∕')
|
# slash / → issue with renaming since it is the folder separation characters on most file systems
|
||||||
|
# brackets [] → it interferes with orgdown file link with description
|
||||||
|
sanitized_title = data['fulltitle'].replace('/', u'∕').replace('[', u'⌜').replace(']', u'⌟')
|
||||||
return data['upload_date'][:4] + '-' + data['upload_date'][4:6] + '-' + data['upload_date'][6:] + ' ' + data["extractor"] + ' - ' + sanitized_title + ' - ' + data["display_id"] + ' ' + data["duration_string"].replace(':', ';') + '.' + data["ext"]
|
return data['upload_date'][:4] + '-' + data['upload_date'][4:6] + '-' + data['upload_date'][6:] + ' ' + data["extractor"] + ' - ' + sanitized_title + ' - ' + data["display_id"] + ' ' + data["duration_string"].replace(':', ';') + '.' + data["ext"]
|
||||||
else:
|
else:
|
||||||
logging.debug('derive_new_filename_from_json_metadata: found all required meta data ' +
|
logging.debug('derive_new_filename_from_json_metadata: found all required meta data ' +
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue