Improved auto tagging
This commit is contained in:
@@ -19,7 +19,7 @@ import re
|
||||
from interface.views import EnsembleMixin, ProjectMixin, AuthorizedResourceMixin
|
||||
from interface.models import Project
|
||||
from library.models import Collection, Work, Document, Section
|
||||
from library.music_tags import MUSIC_TAGS, MUSIC_TAG_BY_NAME, MusicTag
|
||||
from library.music_tags import MUSIC_TAGS, MusicTag, auto_tag
|
||||
from library import forms, models
|
||||
from library.pdf_utils import extract_pages, extract_and_concat
|
||||
|
||||
@@ -381,15 +381,9 @@ class WorkAddDocumentView(CollectionMixin, CreateView):
|
||||
|
||||
#name, ext = os.path.splitext(os.path.basename(doc.upload.name))
|
||||
if doc.doctype == models.Document.DOCTYPE_PDF:
|
||||
parts = re.split(r'[^A-Za-z]+', orig_name)
|
||||
parts.reverse()
|
||||
for word in parts:
|
||||
try:
|
||||
tag = MUSIC_TAG_BY_NAME[word.lower()]
|
||||
doc.sections.create(tag=tag)
|
||||
break
|
||||
except KeyError:
|
||||
pass
|
||||
inst = auto_tag(orig_name)
|
||||
if inst:
|
||||
doc.sections.create(tag=inst.abbreviate())
|
||||
|
||||
if self.request.headers['Accept'] == 'application/json':
|
||||
filename = os.path.basename(doc.upload.name)
|
||||
|
||||
Reference in New Issue
Block a user