mirror of
https://github.com/rembo10/headphones.git
synced 2026-05-16 08:35:32 +01:00
Added file name test for post-processing, fixed typo in webinterface
This commit is contained in:
@@ -389,7 +389,6 @@ def start():
|
||||
SCHED.add_interval_job(importer.scanMusic, minutes=LIBRARYSCAN_INTERVAL)
|
||||
SCHED.add_interval_job(versioncheck.checkGithub, minutes=300)
|
||||
SCHED.add_interval_job(postprocessor.checkFolder, minutes=5)
|
||||
postprocessor.checkFolder()
|
||||
|
||||
SCHED.start()
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import os
|
||||
import time
|
||||
|
||||
import urllib, shutil
|
||||
import urllib, shutil, re
|
||||
|
||||
from lib.beets.mediafile import MediaFile
|
||||
import lib.musicbrainz2.webservice as ws
|
||||
@@ -33,12 +33,9 @@ def verify(albumid, albumpath):
|
||||
for r,d,f in os.walk(albumpath):
|
||||
for files in f:
|
||||
if any(files.endswith(x) for x in (".mp3", ".flac", ".aac", ".ogg", ".ape")):
|
||||
downloaded_track_list.append(os.path.join(r, files))
|
||||
|
||||
# test #1: filenames
|
||||
downloaded_track_list.append(os.path.join(r, files))
|
||||
|
||||
|
||||
# test #2: metadata.
|
||||
# test #1: metadata - usually works
|
||||
for downloaded_track in downloaded_track_list:
|
||||
try:
|
||||
f = MediaFile(downloaded_track)
|
||||
@@ -48,30 +45,41 @@ def verify(albumid, albumpath):
|
||||
doPostProcessing(albumid, albumpath, release, tracks, downloaded_track_list)
|
||||
return
|
||||
|
||||
# test #2: filenames
|
||||
for downloaded_track in downloaded_track_list:
|
||||
track_name = os.path.splitext(downloaded_track)[0]
|
||||
split_track_name = re.sub('[\.\-\_]', ' ', track_name).lower()
|
||||
for track in tracks:
|
||||
if helpers.latinToAscii(track['TrackTitle'].lower()).encode('UTF-8') in helpers.latinToAscii(split_track_name).encode('UTF-8'):
|
||||
doPostProcessing(albumid, albumpath, release, tracks, downloaded_track_list)
|
||||
return
|
||||
|
||||
# test #3: number of songs and duration
|
||||
db_track_duration = 0
|
||||
downloaded_track_duration = 0
|
||||
|
||||
for track in tracks:
|
||||
try:
|
||||
db_track_duration += track['TrackDuration']/1000
|
||||
except:
|
||||
downloaded_track_duration = False
|
||||
break
|
||||
if len(tracks) == len(downloaded_track_list):
|
||||
|
||||
for track in tracks:
|
||||
try:
|
||||
db_track_duration += track['TrackDuration']/1000
|
||||
except:
|
||||
downloaded_track_duration = False
|
||||
break
|
||||
|
||||
for downloaded_track in downloaded_track_list:
|
||||
try:
|
||||
f = MediaFile(downloaded_track)
|
||||
downloaded_track_duration += f.length
|
||||
except:
|
||||
downloaded_track_duration = False
|
||||
break
|
||||
|
||||
for downloaded_track in downloaded_track_list:
|
||||
try:
|
||||
f = MediaFile(downloaded_track)
|
||||
downloaded_track_duration += f.length
|
||||
except:
|
||||
downloaded_track_duration = False
|
||||
break
|
||||
|
||||
if downloaded_track_duration and db_track_duration:
|
||||
delta = abs(downloaded_track_duration - db_track_duration)
|
||||
if len(tracks) == len(downloaded_track_list) and delta < 100:
|
||||
doPostProcessing(albumid, albumpath, release, tracks, downloaded_track_list)
|
||||
return
|
||||
if downloaded_track_duration and db_track_duration:
|
||||
delta = abs(downloaded_track_duration - db_track_duration)
|
||||
if delta < 240:
|
||||
doPostProcessing(albumid, albumpath, release, tracks, downloaded_track_list)
|
||||
return
|
||||
|
||||
logger.warn('Could not identify album: %s. It may not be the intended album.' % albumpath)
|
||||
myDB.action('UPDATE snatched SET status = "Unprocessed" WHERE AlbumID=?', [albumid])
|
||||
|
||||
@@ -25,7 +25,7 @@ class WebInterface(object):
|
||||
def home(self):
|
||||
page = [templates._header]
|
||||
if not headphones.CURRENT_VERSION:
|
||||
page.append('''<div class="updatebar">You're running an unknown version of Heapdhones. <a class="blue" href="update">Click here to update</a></div>''')
|
||||
page.append('''<div class="updatebar">You're running an unknown version of Headphones. <a class="blue" href="update">Click here to update</a></div>''')
|
||||
elif headphones.CURRENT_VERSION != headphones.LATEST_VERSION and headphones.INSTALL_TYPE != 'win':
|
||||
page.append('''<div class="updatebar">A <a class="blue" href="http://github.com/rembo10/headphones/compare/%s...%s">
|
||||
newer version</a> is available. You're %s commits behind. <a class="blue" href="update">Click here to update</a></div>
|
||||
|
||||
Reference in New Issue
Block a user