mirror of
https://github.com/rembo10/headphones.git
synced 2026-07-22 17:04:01 +01:00
Mark alhad albums as downloaded instead of skipped (or wanted when it's a new artist/album)
This commit is contained in:
+12
-3
@@ -136,6 +136,8 @@ LOSSY_MEDIA_FORMATS = ["mp3", "aac", "ogg", "ape", "m4a"]
|
|||||||
LOSSLESS_MEDIA_FORMATS = ["flac"]
|
LOSSLESS_MEDIA_FORMATS = ["flac"]
|
||||||
MEDIA_FORMATS = LOSSY_MEDIA_FORMATS + LOSSLESS_MEDIA_FORMATS
|
MEDIA_FORMATS = LOSSY_MEDIA_FORMATS + LOSSLESS_MEDIA_FORMATS
|
||||||
|
|
||||||
|
ALBUM_COMPLETION_PCT = None # This is used in importer.py to determine how complete an album needs to be - to be considered "downloaded". Percentage from 0-100
|
||||||
|
|
||||||
TORRENTBLACKHOLE_DIR = None
|
TORRENTBLACKHOLE_DIR = None
|
||||||
NUMBEROFSEEDERS = 10
|
NUMBEROFSEEDERS = 10
|
||||||
ISOHUNT = None
|
ISOHUNT = None
|
||||||
@@ -242,7 +244,8 @@ def initialize():
|
|||||||
NZBSORG, NZBSORG_UID, NZBSORG_HASH, NEWZBIN, NEWZBIN_UID, NEWZBIN_PASSWORD, LASTFM_USERNAME, INTERFACE, FOLDER_PERMISSIONS, \
|
NZBSORG, NZBSORG_UID, NZBSORG_HASH, NEWZBIN, NEWZBIN_UID, NEWZBIN_PASSWORD, LASTFM_USERNAME, INTERFACE, FOLDER_PERMISSIONS, \
|
||||||
ENCODERFOLDER, ENCODER, BITRATE, SAMPLINGFREQUENCY, MUSIC_ENCODER, ADVANCEDENCODER, ENCODEROUTPUTFORMAT, ENCODERQUALITY, ENCODERVBRCBR, \
|
ENCODERFOLDER, ENCODER, BITRATE, SAMPLINGFREQUENCY, MUSIC_ENCODER, ADVANCEDENCODER, ENCODEROUTPUTFORMAT, ENCODERQUALITY, ENCODERVBRCBR, \
|
||||||
ENCODERLOSSLESS, PROWL_ENABLED, PROWL_PRIORITY, PROWL_KEYS, PROWL_ONSNATCH, MIRRORLIST, MIRROR, CUSTOMHOST, CUSTOMPORT, \
|
ENCODERLOSSLESS, PROWL_ENABLED, PROWL_PRIORITY, PROWL_KEYS, PROWL_ONSNATCH, MIRRORLIST, MIRROR, CUSTOMHOST, CUSTOMPORT, \
|
||||||
CUSTOMSLEEP, HPUSER, HPPASS, XBMC_ENABLED, XBMC_HOST, XBMC_USERNAME, XBMC_PASSWORD, XBMC_UPDATE, XBMC_NOTIFY, NMA_ENABLED, NMA_APIKEY, NMA_PRIORITY, SYNOINDEX_ENABLED
|
CUSTOMSLEEP, HPUSER, HPPASS, XBMC_ENABLED, XBMC_HOST, XBMC_USERNAME, XBMC_PASSWORD, XBMC_UPDATE, XBMC_NOTIFY, NMA_ENABLED, NMA_APIKEY, NMA_PRIORITY, SYNOINDEX_ENABLED, \
|
||||||
|
ALBUM_COMPLETION_PCT
|
||||||
|
|
||||||
if __INITIALIZED__:
|
if __INITIALIZED__:
|
||||||
return False
|
return False
|
||||||
@@ -259,6 +262,7 @@ def initialize():
|
|||||||
CheckSection('XBMC')
|
CheckSection('XBMC')
|
||||||
CheckSection('NMA')
|
CheckSection('NMA')
|
||||||
CheckSection('Synoindex')
|
CheckSection('Synoindex')
|
||||||
|
CheckSection('Advanced')
|
||||||
|
|
||||||
# Set global variables based on config file or use defaults
|
# Set global variables based on config file or use defaults
|
||||||
CONFIG_VERSION = check_setting_str(CFG, 'General', 'config_version', '0')
|
CONFIG_VERSION = check_setting_str(CFG, 'General', 'config_version', '0')
|
||||||
@@ -383,8 +387,10 @@ def initialize():
|
|||||||
CUSTOMHOST = check_setting_str(CFG, 'General', 'customhost', 'localhost')
|
CUSTOMHOST = check_setting_str(CFG, 'General', 'customhost', 'localhost')
|
||||||
CUSTOMPORT = check_setting_int(CFG, 'General', 'customport', 5000)
|
CUSTOMPORT = check_setting_int(CFG, 'General', 'customport', 5000)
|
||||||
CUSTOMSLEEP = check_setting_int(CFG, 'General', 'customsleep', 1)
|
CUSTOMSLEEP = check_setting_int(CFG, 'General', 'customsleep', 1)
|
||||||
HPUSER = check_setting_str(CFG, 'General', 'hpuser', 'username')
|
HPUSER = check_setting_str(CFG, 'General', 'hpuser', '')
|
||||||
HPPASS = check_setting_str(CFG, 'General', 'hppass', 'password')
|
HPPASS = check_setting_str(CFG, 'General', 'hppass', '')
|
||||||
|
|
||||||
|
ALBUM_COMPLETION_PCT = check_setting_int(CFG, 'Advanced', 'album_completion_pct', 80)
|
||||||
|
|
||||||
# update folder formats in the config & bump up config version
|
# update folder formats in the config & bump up config version
|
||||||
if CONFIG_VERSION == '0':
|
if CONFIG_VERSION == '0':
|
||||||
@@ -662,6 +668,9 @@ def config_write():
|
|||||||
new_config['General']['hpuser'] = HPUSER
|
new_config['General']['hpuser'] = HPUSER
|
||||||
new_config['General']['hppass'] = HPPASS
|
new_config['General']['hppass'] = HPPASS
|
||||||
|
|
||||||
|
new_config['Advanced'] = {}
|
||||||
|
new_config['Advanced']['album_completion_pct'] = ALBUM_COMPLETION_PCT
|
||||||
|
|
||||||
new_config.write()
|
new_config.write()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+19
-2
@@ -156,7 +156,7 @@ def addArtisttoDB(artistid, extrasonly=False):
|
|||||||
rgid = rg['id']
|
rgid = rg['id']
|
||||||
|
|
||||||
# check if the album already exists
|
# check if the album already exists
|
||||||
rg_exists = myDB.select("SELECT * from albums WHERE AlbumID=?", [rg['id']])
|
rg_exists = myDB.action("SELECT * from albums WHERE AlbumID=?", [rg['id']]).fetchone()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
release_dict = mb.getReleaseGroup(rgid)
|
release_dict = mb.getReleaseGroup(rgid)
|
||||||
@@ -180,7 +180,7 @@ def addArtisttoDB(artistid, extrasonly=False):
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Only change the status & add DateAdded if the album is not already in the database
|
# Only change the status & add DateAdded if the album is not already in the database
|
||||||
if not len(rg_exists):
|
if not rg_exists:
|
||||||
|
|
||||||
newValueDict['DateAdded']= helpers.today()
|
newValueDict['DateAdded']= helpers.today()
|
||||||
|
|
||||||
@@ -193,6 +193,10 @@ def addArtisttoDB(artistid, extrasonly=False):
|
|||||||
|
|
||||||
myDB.upsert("albums", newValueDict, controlValueDict)
|
myDB.upsert("albums", newValueDict, controlValueDict)
|
||||||
|
|
||||||
|
# This is used to see how many tracks you have from an album - to mark it as downloaded. Default is 80%, can be set in config as ALBUM_COMPLETION_PCT
|
||||||
|
total_track_count = len(release_dict['tracks'])
|
||||||
|
|
||||||
|
|
||||||
for track in release_dict['tracks']:
|
for track in release_dict['tracks']:
|
||||||
|
|
||||||
cleanname = helpers.cleanName(artist['artist_name'] + ' ' + rg['title'] + ' ' + track['title'])
|
cleanname = helpers.cleanName(artist['artist_name'] + ' ' + rg['title'] + ' ' + track['title'])
|
||||||
@@ -217,6 +221,7 @@ def addArtisttoDB(artistid, extrasonly=False):
|
|||||||
if not match:
|
if not match:
|
||||||
match = myDB.action('SELECT Location, BitRate, Format from have WHERE TrackID=?', [track['id']]).fetchone()
|
match = myDB.action('SELECT Location, BitRate, Format from have WHERE TrackID=?', [track['id']]).fetchone()
|
||||||
if match:
|
if match:
|
||||||
|
have_track_count += 1
|
||||||
newValueDict['Location'] = match['Location']
|
newValueDict['Location'] = match['Location']
|
||||||
newValueDict['BitRate'] = match['BitRate']
|
newValueDict['BitRate'] = match['BitRate']
|
||||||
newValueDict['Format'] = match['Format']
|
newValueDict['Format'] = match['Format']
|
||||||
@@ -224,6 +229,18 @@ def addArtisttoDB(artistid, extrasonly=False):
|
|||||||
|
|
||||||
myDB.upsert("tracks", newValueDict, controlValueDict)
|
myDB.upsert("tracks", newValueDict, controlValueDict)
|
||||||
|
|
||||||
|
# Mark albums as downloaded if they have at least 80% (by default, configurable) of the album
|
||||||
|
have_track_count = len(myDB.select('SELECT * from tracks WHERE AlbumID=? AND Location IS NOT NULL', [rg['id']]))
|
||||||
|
|
||||||
|
if rg_exists:
|
||||||
|
if rg_exists['Status'] == 'Skipped' and ((have_track_count/float(total_track_count)) >= (headphones.ALBUM_COMPLETION_PCT/100.0)):
|
||||||
|
logger.info('album exists, marking as downloaded 1')
|
||||||
|
myDB.action('UPDATE albums SET Status=? WHERE AlbumID=?', ['Downloaded', rg['id']])
|
||||||
|
else:
|
||||||
|
if ((have_track_count/float(total_track_count)) >= (headphones.ALBUM_COMPLETION_PCT/100.0)):
|
||||||
|
logger.info('album exists, marking as downloaded 2')
|
||||||
|
myDB.action('UPDATE albums SET Status=? WHERE AlbumID=?', ['Downloaded', rg['id']])
|
||||||
|
|
||||||
logger.debug(u"Updating album cache for " + rg['title'])
|
logger.debug(u"Updating album cache for " + rg['title'])
|
||||||
cache.getThumb(AlbumID=rg['id'])
|
cache.getThumb(AlbumID=rg['id'])
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user