Autotagging!

This commit is contained in:
Remy
2011-07-27 23:33:00 -07:00
parent 080871eda7
commit 6da8af133b
4 changed files with 22 additions and 9 deletions

View File

@@ -3,8 +3,9 @@ import time
import urllib, shutil, re
import lib.beets as beets
from lib.beets import autotag
from lib.beets.mediafile import MediaFile
import lib.musicbrainz2.webservice as ws
import headphones
from headphones import db, albumart, logger, helpers
@@ -165,7 +166,19 @@ def moveFiles(albumpath, release, tracks):
def correctMetadata(albumid, release, downloaded_track_list):
pass
logger.info('Writing metadata')
items = []
for downloaded_track in downloaded_track_list:
items.append(beets.library.Item.from_path(downloaded_track))
cur_artist, cur_album, out_tuples, rec = autotag.tag_album(items, search_artist=release['ArtistName'], search_album=release['AlbumTitle'])
distance, items, info = out_tuples[0]
autotag.apply_metadata(items, info)
for item in items:
item.write()
def renameFiles(albumpath, downloaded_track_list, release):

View File

@@ -157,11 +157,11 @@ def searchNZB(albumid=None, new=False):
try:
d = minidom.parseString(data)
node = d.documentElement
items = d.getElementsByTagName("item")
except ExpatError:
logger.error('Unable to get the NZBs.org feed. Check that your settings are correct - post a bug if they are')
node = d.documentElement
items = d.getElementsByTagName("item")
items = None
if len(items):

View File

@@ -309,7 +309,7 @@ configform = form = '''
<p><b>Folder Format</b>:<br><input type="text" name="folder_format" value="%s" size="60">
<br>
<i class="smalltext">Use: artist, album and year</i>
<i class="smalltext">Use: artist, album and year, '/' for directories. <br />E.g.: artist/album [year]</i>
</p>
<p><b>File Format</b>:<br><input type="text" name="file_format" value="%s" size="60">

View File

@@ -19,7 +19,7 @@ import logging
from collections import defaultdict
import re
from lib.munkres import Munkres
from unidecode import unidecode
#from unidecode import unidecode
from lib.beets.autotag import mb
from lib.beets import library, mediafile, plugins
@@ -119,8 +119,8 @@ def _string_dist_basic(str1, str2):
transliteration/lowering to ASCII characters. Normalized by string
length.
"""
str1 = unidecode(str1)
str2 = unidecode(str2)
# str1 = unidecode(str1)
# str2 = unidecode(str2)
str1 = re.sub(r'[^a-z0-9]', '', str1.lower())
str2 = re.sub(r'[^a-z0-9]', '', str2.lower())
if not str1 and not str2: