Skip to content

Commit

Permalink
1.4.7 add cover description error
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurBeaulieu committed Aug 31, 2020
1 parent 861b13f commit 4c1c594
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 15 deletions.
2 changes: 1 addition & 1 deletion OstrichRemover.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from src.utils.tools import *
# Globals
global scriptVersion
scriptVersion = '1.4.5'
scriptVersion = '1.4.7'


# Script main frame
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# OstrichRemover

![](https://badgen.net/badge/version/1.4.5/blue) ![](https://badgen.net/badge/license/GPL-3.0/green)
![](https://badgen.net/badge/version/1.4.7/blue) ![](https://badgen.net/badge/license/GPL-3.0/green)

##### Like your audio files to be correctly tagged ? *OstrichRemover* might help you !

Expand All @@ -23,7 +23,7 @@ Available options :
- `-v` or `--verbose` for a verbose output.

The script will crawl the folder you gave as an argument and will report you any error it found in your file naming / tagging. If specified with a `-d` of `--dump` flag, errors can be outputed in a JSON file, to be further reviewed in the `web-report/index.html` file (just drag and drop the json file in the input area).
*OstrichRemover* can detect **35 errors** per file (so far). Those errors are grouped in four categories that are detailed [in the wiki](https://github.com/ArthurBeaulieu/OstrichRemover/wiki/Tracked-Errors), respectively:
*OstrichRemover* can detect **37 errors** per file (so far). Those errors are grouped in four categories that are detailed [in the wiki](https://github.com/ArthurBeaulieu/OstrichRemover/wiki/Tracked-Errors), respectively:

- *Category 1* – File system naming inconsistencies ;
- *Category 2* – File system naming against ID3 tags ;
Expand Down
11 changes: 8 additions & 3 deletions src/models/track.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def __init__(self, fileType, pathList, fileName, audioTagPath):
self.hasCover = False
self.cover = {}
self.coverType = ''
self.coverDesc = ''
# Filesystem path and name as lists (separator is ` - `)
self.pathList = pathList
self.fileType = fileType
Expand Down Expand Up @@ -192,13 +193,17 @@ def _computeRemixer(self):
# Test the cover existence in the file
def _containsCover(self):
# Extract image from file
if self.fileType == 'MP3' and 'APIC:' in self.audioTag:
self.cover = self.audioTag['APIC:'].data
self.coverType = self.audioTag['APIC:'].mime
if self.fileType == 'MP3':
mp3Cover = self.audioTag.getall('APIC')[0]
if mp3Cover is not None:
self.cover = mp3Cover.data
self.coverType = mp3Cover.mime
self.coverDesc = mp3Cover.desc
elif self.fileType == 'FLAC':
if len(self.audioTag.pictures) > 0:
self.cover = self.audioTag.pictures[0].data
self.coverType = self.audioTag.pictures[0].mime
self.coverDesc = self.audioTag.pictures[0].desc
else:
self.cover = self.audioTag.pictures
# Test cover existence
Expand Down
2 changes: 1 addition & 1 deletion src/references/refGenre.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class RefGenre(object):
'Progressive Metal', 'Progressive Metalcore', 'Progressive Psytrance',
'Progressive Rock', 'Progressive Trance', 'Psychedelic Blues', 'Psychedelic Funk',
'Psychedelic Pop', 'Psychedelic Rock', 'Psychedelic Soul', 'Psychill', 'Psytrance',
'Punk', 'Punk Rock', 'Raga Rock', 'Ragga', 'Raggatek', 'Rap', 'Rap Be', 'Rap Fr',
'Punk', 'Punk Rock', 'Raga Rock', 'Ragga', 'Raggatek', 'Raï', 'Rap', 'Rap Be', 'Rap Fr',
'Rap Rock', 'Rap Uk', 'Rap Us', 'Rawstyle', 'R&B', 'Reggae', 'Reggae Metal',
'Reggaestep', 'Reggaeton', 'Riddim', 'Rock', 'Rockabilly', "Rock'n'Roll", 'Rocksteady',
'Romantic', 'Roots Reggae', 'Shoegaze', 'Ska', 'Ska Punk', 'Slowcore', 'Slow Rock',
Expand Down
8 changes: 8 additions & 0 deletions src/scan/trackTester.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,14 @@ def _testCoverValidity(self):
self.errors.append(ErrorEnum.INVALID_COVER)
img.close()
os.remove('tmp.jpg') # GC
if self.track.coverDesc == '':
self.errorCounter += 1
self.errors.append(ErrorEnum.NO_COVER_DESCRIPTION)
else:
description = self.track.albumArtist + ' - ' + self.track.year + ' - ' + self.track.albumTitle + ' - Front.jpg'
if self.track.coverDesc != description and self._areStringsMatchingWithFoldernameRestrictions(self.track.coverDesc, description) is False:
self.errorCounter += 1
self.errors.append(ErrorEnum.COVER_DESCRIPTION_NOT_MATCHING)


# Test ID3 fields to check if they are indeed integer (floating are forbidden in those)
Expand Down
20 changes: 15 additions & 5 deletions src/utils/errorEnum.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,21 @@ class ErrorEnum(Enum):
'errorCode': 32,
'errorValue': "There is a tag that has several fields, which is unauthorized"
}
# ErrorCode 33 : The year tag doesn't match the year in released date tag
YEAR_VS_RELEASE_YEAR = {
'errorCode': 33,
'errorValue': "The year tag doesn't match the year in released date tag"
}
# ErrorCode 35 : Cover has no description in tag
NO_COVER_DESCRIPTION = {
'errorCode': 35,
'errorValue': "Cover has no description"
}
# ErrorCode 36 : Cover description doesn't match the fileName
COVER_DESCRIPTION_NOT_MATCHING = {
'errorCode': 36,
'errorValue': "Cover description doesn't match cover filename"
}
## ------------
# Category 4 : Track tags coherence with album metrics
# ErrorCode 14 : Computed album total track is not equal to the track total track tag
Expand Down Expand Up @@ -178,11 +193,6 @@ class ErrorEnum(Enum):
'errorCode': 31,
'errorValue': "Language tag is not consistent over album tracks"
}
# ErrorCode 33 : The year tag doesn't match the year in released date tag
YEAR_VS_RELEASE_YEAR = {
'errorCode': 33,
'errorValue': "The year tag doesn't match the year in released date tag"
}
# ErrorCode 34 : There is no cover, or there are more than one cover
COVER_NOT_UNIQUE = {
'errorCode': 34,
Expand Down
14 changes: 12 additions & 2 deletions src/utils/uiBuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,12 @@ def _printErroredTracksReport_aux(errorCode, trackTester):
# ErrorCode 32 : A tag in file doesn't have a unique field
elif errorCode == 32:
printTrackErrorInfo(errorCode, t.title, 'Each tag must have only one field for its data')
# ErrorCode 35 : Cover has no description in tag
elif errorCode == 35:
printTrackErrorInfo(errorCode, t.coverDesc, 'Cover description is missing')
# ErrorCode 36 : Cover description doesn't match the fileName
elif errorCode == 36:
printTrackErrorInfo(errorCode, t.coverDesc, 'Cover description doesn\'t match the convention')


# Auxilliary, print an error about a given album
Expand Down Expand Up @@ -379,7 +385,9 @@ def printTrackErrorInfo(errorCode, string1, string2):
# ErrorCode 19 : Cover is not a 1000x1000 jpg image
# ErrorCode 20 : Track has no cover
# ErrorCode 34 : There is no cover, or there are more than one cover
elif errorCode == 19 or errorCode == 20 or errorCode == 34:
# ErrorCode 35 : Cover has no description in tag
# ErrorCode 36 : Cover description doesn't match the fileName
elif errorCode == 19 or errorCode == 20 or errorCode == 34 or errorCode == 35 or errorCode == 36:
location1 = 'From Cover Tag '
# ErrorCode 22 : Cover format is not optimized (not jpg)
elif errorCode == 22:
Expand Down Expand Up @@ -475,7 +483,9 @@ def getTopicStringFromErrorCode(errorCode):
# ErrorCode 19 : Cover is not a 1000x1000 jpg image
# ErrorCode 20 : Track has no cover
# ErrorCode 34 : There is no cover, or there are more than one cover
elif errorCode == 19 or errorCode == 20 or errorCode == 34:
# ErrorCode 35 : Cover has no description in tag
# ErrorCode 36 : Cover description doesn't match the fileName
elif errorCode == 19 or errorCode == 20 or errorCode == 34 or errorCode == 35 or errorCode == 36:
topic = '-------- Cover Error'
# ErrorCode 21 : Release artist folder name doesn't match the track album artist tag
elif errorCode == 21:
Expand Down
2 changes: 1 addition & 1 deletion web-report/js/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import AnalysisView from './views/AnalysisView.js';


let view = null; // The active view in report-container
const scriptVersion = '1.4.5';
const scriptVersion = '1.4.7';


// Display notification global method that can accessed through window object
Expand Down

0 comments on commit 4c1c594

Please sign in to comment.