Merge pull request #176 from sbuser/post-processor-fixes

Postprocessing fixes: fix for files in windows with an smb name, added sanity checks for manual post-processing
This commit is contained in:
rembo10
2011-08-02 11:18:22 -07:00
3 changed files with 31 additions and 24 deletions

View File

@@ -104,9 +104,12 @@ def extract_data(s):
pattern = re.compile(r'(?P<name>.*?)\s\-\s(?P<album>.*?)\s\[(?P<year>.*?)\]', re.VERBOSE)
match = pattern.match(s)
name = match.group("name")
album = match.group("album")
year = match.group("year")
return (name, album, year)
if match:
name = match.group("name")
album = match.group("album")
year = match.group("year")
return (name, album, year)
else:
return (None, None, None)

View File

@@ -237,7 +237,7 @@ def correctMetadata(albumid, release, downloaded_track_list):
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'])
if rec == 'RECOMMEND_NONE':
@@ -367,21 +367,23 @@ def forcePostProcess():
albumpath = unicode(os.path.join(download_dir, folder))
name, album, year = helpers.extract_data(folder)
myDB = db.DBConnection()
release = myDB.action('SELECT AlbumID, ArtistName, AlbumTitle from albums WHERE ArtistName=? and AlbumTitle=?', [name, album]).fetchone()
if release:
logger.info('Found a match in the database: %s - %s. Verifying to make sure it is the correct album' % (release['ArtistName'], release['AlbumTitle']))
verify(release['AlbumID'], albumpath)
else:
logger.info('Querying MusicBrainz for the release group id for: %s - %s' % (name, album))
from headphones import mb
try:
rgid = mb.findAlbumID(name, album)
except:
logger.error('Can not get release information for this album')
if rgid:
rgid = unicode(rgid)
verify(rgid, albumpath)
if name and album and year:
myDB = db.DBConnection()
release = myDB.action('SELECT AlbumID, ArtistName, AlbumTitle from albums WHERE ArtistName=? and AlbumTitle=?', [name, album]).fetchone()
if release:
logger.info('Found a match in the database: %s - %s. Verifying to make sure it is the correct album' % (release['ArtistName'], release['AlbumTitle']))
verify(release['AlbumID'], albumpath)
else:
logger.info('Querying MusicBrainz for the release group id for: %s - %s' % (name, album))
from headphones import mb
try:
rgid = mb.findAlbumID(name, album)
except:
logger.error('Can not get release information for this album')
continue
if rgid:
rgid = unicode(rgid)
verify(rgid, albumpath)

View File

@@ -162,7 +162,9 @@ def syspath(path, pathmod=None):
path = path.decode('utf8', 'replace')
# Add the magic prefix if it isn't already there
if not path.startswith(u'\\\\?\\'):
# Not sure what the magic prefix he was adding actually does but if it's a network path
# it breaks when we add the prefix - ignore the addition if the \\ is already there
if not path.startswith(u'\\\\?\\') and not path.startswith(u'\\'):
path = u'\\\\?\\' + path
return path