From f0b9cd102d2d20af1ee2610bead548688d91e34f Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Sat, 18 Nov 2017 14:09:17 -0700 Subject: [PATCH] Fix some year est issues & add ability for oputil fb scan --update to pick up years --- core/config.js | 11 ++++++++--- core/oputil/oputil_file_base.js | 14 +++++++++----- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/core/config.js b/core/config.js index e33648b9..367143b6 100644 --- a/core/config.js +++ b/core/config.js @@ -670,12 +670,17 @@ function getDefaultConfig() { // Patterns should produce the year in the first submatch. // The extracted year may be YY or YYYY // - '\\b((?:[1-2][0-9][0-9]{2}))[\\-\\/\\.][0-3]?[0-9][\\-\\/\\.][0-3]?[0-9]|[0-3]?[0-9][\\-\\/\\.][0-3]?[0-9][\\-\\/\\.]((?:[0-9]{2})?[0-9]{2})\\b', // yyyy-mm-dd, m/d/yyyy, mm-dd-yyyy, etc. - "\\b('[1789][0-9])\\b", // eslint-disable-line quotes + '\\b((?:[1-2][0-9][0-9]{2}))[\\-\\/\\.][0-3]?[0-9][\\-\\/\\.][0-3]?[0-9]\\b', // yyyy-mm-dd, yyyy/mm/dd, ... + '\\b[0-3]?[0-9][\\-\\/\\.][0-3]?[0-9][\\-\\/\\.]((?:[1-2][0-9][0-9]{2}))\\b', // mm/dd/yyyy, mm.dd.yyyy, ... + '\\b((?:[1789][0-9]))[\\-\\/\\.][0-3]?[0-9][\\-\\/\\.][0-3]?[0-9]\\b', // yy-mm-dd, yy-mm-dd, ... + '\\b[0-3]?[0-9][\\-\\/\\.][0-3]?[0-9][\\-\\/\\.]((?:[1789][0-9]))\\b', // mm-dd-yy, mm/dd/yy, ... + //'\\b((?:[1-2][0-9][0-9]{2}))[\\-\\/\\.][0-3]?[0-9][\\-\\/\\.][0-3]?[0-9]|[0-3]?[0-9][\\-\\/\\.][0-3]?[0-9][\\-\\/\\.]((?:[0-9]{2})?[0-9]{2})\\b', // yyyy-mm-dd, m/d/yyyy, mm-dd-yyyy, etc. + //"\\b('[1789][0-9])\\b", // eslint-disable-line quotes '\\b[0-3]?[0-9][\\-\\/\\.](?:jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec|january|february|march|april|may|june|july|august|september|october|november|december)[\\-\\/\\.]((?:[0-9]{2})?[0-9]{2})\\b', '\\b(?:jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec|january|february|march|april|may|june|july|august|september|october|november|december),?\\s[0-9]+(?:st|nd|rd|th)?,?\\s((?:[0-9]{2})?[0-9]{2})\\b', // November 29th, 1997 - '\\(((?:19|20)[0-9]{2})\\)', // (19xx) or (20xx) -- do this before 19xx 20xx such that this has priority + '\\(((?:19|20)[0-9]{2})\\)', // (19xx) or (20xx) -- with parens -- do this before 19xx 20xx such that this has priority '\\b((?:19|20)[0-9]{2})\\b', // simple 19xx or 20xx with word boundaries + '\\b\'([17-9][0-9])\\b', // '95, '17, ... // :TODO: DD/MMM/YY, DD/MMMM/YY, DD/MMM/YYYY, etc. ], diff --git a/core/oputil/oputil_file_base.js b/core/oputil/oputil_file_base.js index 0c4c6065..835db5b9 100644 --- a/core/oputil/oputil_file_base.js +++ b/core/oputil/oputil_file_base.js @@ -172,8 +172,8 @@ function scanFileAreaForChanges(areaInfo, options, cb) { // // We'll update the entry if the following conditions are met: // * We have a single duplicate, and: - // * --update was passed or the existing entry's desc or - // longDesc are blank/empty + // * --update was passed or the existing entry's desc, + // longDesc, or yearEst are blank/empty // if(argv.update && 1 === dupeEntries.length) { const FileEntry = require('../../core/file_entry.js'); @@ -193,15 +193,19 @@ function scanFileAreaForChanges(areaInfo, options, cb) { if( tagsEq && fileEntry.desc === existingEntry.desc && - fileEntry.descLong == existingEntry.descLong) + fileEntry.descLong == existingEntry.descLong && + fileEntry.meta.est_release_year == existingEntry.meta.est_release_year) { console.info('Dupe'); return nextFile(null); } console.info('Dupe (updating)'); - existingEntry.desc = fileEntry.desc; - existingEntry.descLong = fileEntry.descLong; + + // don't allow overwrite of values if new version is blank + existingEntry.desc = fileEntry.desc || existingEntry.desc; + existingEntry.descLong = fileEntry.descLong || existingEntry.descLong; + existingEntry.meta.est_release_year = fileEntry.meta.est_release_year || existingEntry.meta.est_release_year; updateTags(existingEntry); finalizeEntryAndPersist(true, existingEntry, descHandler, err => {