/** * la classe qui repère des patterns */ import {tagSectionSeparator} from "./configs"; export default class finders{ patternsFiles = { 'downloaded_pic': /^\-\w{15}\.jpg/, // FyB8cZnWIAc21rw.jpg 'telegram_pic': /^\-\d{19}_\d{4}/, // -4900281569878475578_1109.jpg 'open_camera': /^IMG_OC_\d{8}/i, // IMG_OC_20230617_092120_3.jpg 'screenshot': /^Screenshot/i, // Screenshot 2023-06-15 at 15-26-04 Instance Panoramax OSM-FR.png } static findScreenshot (inputString) { return inputString.match(/screenshot/i) || inputString.match(/capture d'écran/i) } static findFormattedDate(filepath) { let found = filepath.match(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/ig) console.log('found', found) return found } static findFileExtension (inputString) { let match = inputString.match(/\.\w{3,4}$/i) return match } /** * find the section of file name which contains the free text to describe the picture * @param fileName * @returns {*|string} */ static findFileNameFreeTextPart(fileName) { fileName = fileName.replace(this.findFileExtension(fileName), '') let boom = fileName.split(tagSectionSeparator) if (boom.length) { let freeTextPart = boom[0].trim() console.log('freeTextPart', freeTextPart) return freeTextPart } return fileName.trim() } }