Mark new albums added to musicbrainz in the last 21 days as wanted (if AUTOWANT_UPCOMING is selected)

This commit is contained in:
rembo10
2012-10-25 20:04:06 -03:00
parent 75ec1e75e8
commit 2fb45f489a
2 changed files with 19 additions and 2 deletions

View File

@@ -118,6 +118,17 @@ def now():
now = datetime.datetime.now()
return now.strftime("%Y-%m-%d %H:%M:%S")
def get_age(date):
split_date = date.split('-')
try:
days_old = int(split_date[0])*365 + int(split_date[1])*30 + int(split_date[2])
except IndexError:
days_old = False
return days_old
def bytes_to_mb(bytes):
mb = int(bytes)/1048576

View File

@@ -358,11 +358,17 @@ def addArtisttoDB(artistid, extrasonly=False):
if not rg_exists:
newValueDict['DateAdded']= helpers.today()
today = helpers.today()
newValueDict['DateAdded']= today
if headphones.AUTOWANT_ALL:
newValueDict['Status'] = "Wanted"
elif album['ReleaseDate'] > helpers.today() and headphones.AUTOWANT_UPCOMING:
elif album['ReleaseDate'] > today and headphones.AUTOWANT_UPCOMING:
newValueDict['Status'] = "Wanted"
# Sometimes "new" albums are added to musicbrainz after their release date, so let's try to catch these
# The first test just makes sure we have year-month-day
elif helpers.get_age(album['ReleaseDate']) and helpers.get_age(today) - helpers.get_age(album['ReleaseDate']) < 21 and headphones.AUTOWANT_UPCOMING:
newValueDict['Status'] = "Wanted"
else:
newValueDict['Status'] = "Skipped"