mirror of
https://github.com/rembo10/headphones.git
synced 2026-03-21 20:29:27 +00:00
Mark new albums added to musicbrainz in the last 21 days as wanted (if AUTOWANT_UPCOMING is selected)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user