Fix some year est issues & add ability for oputil fb scan --update to pick up years

This commit is contained in:
Bryan Ashby 2017-11-18 14:09:17 -07:00
parent 1b414b9b8c
commit f0b9cd102d
2 changed files with 17 additions and 8 deletions

View File

@ -670,12 +670,17 @@ function getDefaultConfig() {
// Patterns should produce the year in the first submatch. // Patterns should produce the year in the first submatch.
// The extracted year may be YY or YYYY // 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((?:[1-2][0-9][0-9]{2}))[\\-\\/\\.][0-3]?[0-9][\\-\\/\\.][0-3]?[0-9]\\b', // yyyy-mm-dd, yyyy/mm/dd, ...
"\\b('[1789][0-9])\\b", // eslint-disable-line quotes '\\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[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 '\\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((?: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. // :TODO: DD/MMM/YY, DD/MMMM/YY, DD/MMM/YYYY, etc.
], ],

View File

@ -172,8 +172,8 @@ function scanFileAreaForChanges(areaInfo, options, cb) {
// //
// We'll update the entry if the following conditions are met: // We'll update the entry if the following conditions are met:
// * We have a single duplicate, and: // * We have a single duplicate, and:
// * --update was passed or the existing entry's desc or // * --update was passed or the existing entry's desc,
// longDesc are blank/empty // longDesc, or yearEst are blank/empty
// //
if(argv.update && 1 === dupeEntries.length) { if(argv.update && 1 === dupeEntries.length) {
const FileEntry = require('../../core/file_entry.js'); const FileEntry = require('../../core/file_entry.js');
@ -193,15 +193,19 @@ function scanFileAreaForChanges(areaInfo, options, cb) {
if( tagsEq && if( tagsEq &&
fileEntry.desc === existingEntry.desc && 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'); console.info('Dupe');
return nextFile(null); return nextFile(null);
} }
console.info('Dupe (updating)'); 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); updateTags(existingEntry);
finalizeEntryAndPersist(true, existingEntry, descHandler, err => { finalizeEntryAndPersist(true, existingEntry, descHandler, err => {