mirror of
https://github.com/rembo10/headphones.git
synced 2026-05-09 13:19:28 +01:00
More Extras
- Artist Refresh, if removing extras from Modify/Fetch Extras then also remove from db - mb, use secondary type if type = Album and different, e.g DJ-mix - utorrent - only check “Put new downloads in” directory
This commit is contained in:
@@ -193,14 +193,17 @@ def addArtisttoDB(artistid, extrasonly=False, forcefull=False):
|
||||
except IndexError:
|
||||
includeExtras = False
|
||||
|
||||
#Clean all references to release group in dB that are no longer referenced in musicbrainz
|
||||
#Clean all references to release group in dB that are no longer referenced from the musicbrainz refresh
|
||||
group_list = []
|
||||
force_repackage = 0
|
||||
#Don't nuke the database if there's a MusicBrainz error
|
||||
if len(artist['releasegroups']) != 0 and not extrasonly:
|
||||
if len(artist['releasegroups']) != 0:
|
||||
for groups in artist['releasegroups']:
|
||||
group_list.append(groups['id'])
|
||||
remove_missing_groups_from_albums = myDB.select("SELECT AlbumID FROM albums WHERE ArtistID=?", [artistid])
|
||||
if not extrasonly:
|
||||
remove_missing_groups_from_albums = myDB.select("SELECT AlbumID FROM albums WHERE ArtistID=?", [artistid])
|
||||
else:
|
||||
remove_missing_groups_from_albums = myDB.select('SELECT AlbumID FROM albums WHERE ArtistID=? AND Status="Skipped" AND Type!="Album"', [artistid])
|
||||
for items in remove_missing_groups_from_albums:
|
||||
if items['AlbumID'] not in group_list:
|
||||
# Remove all from albums/tracks that aren't in release groups
|
||||
@@ -209,13 +212,12 @@ def addArtisttoDB(artistid, extrasonly=False, forcefull=False):
|
||||
myDB.action("DELETE FROM tracks WHERE AlbumID=?", [items['AlbumID']])
|
||||
myDB.action("DELETE FROM alltracks WHERE AlbumID=?", [items['AlbumID']])
|
||||
myDB.action('DELETE from releases WHERE ReleaseGroupID=?', [items['AlbumID']])
|
||||
logger.info("[%s] Removing all references to release group %s to reflect MusicBrainz" % (artist['artist_name'], items['AlbumID']))
|
||||
force_repackage = 1
|
||||
elif extrasonly:
|
||||
# Not really sure what we're doing here but don't want to log the message below if we're fetching extras only
|
||||
pass
|
||||
logger.info("[%s] Removing all references to release group %s to reflect MusicBrainz refresh" % (artist['artist_name'], items['AlbumID']))
|
||||
if not extrasonly:
|
||||
force_repackage = 1
|
||||
else:
|
||||
logger.info("[%s] There was either an error pulling data from MusicBrainz or there might not be any releases for this category" % artist['artist_name'])
|
||||
if not extrasonly:
|
||||
logger.info("[%s] There was either an error pulling data from MusicBrainz or there might not be any releases for this category" % artist['artist_name'])
|
||||
|
||||
# Then search for releases within releasegroups, if releases don't exist, then remove from allalbums/alltracks
|
||||
album_searches = []
|
||||
|
||||
@@ -177,10 +177,10 @@ def findRelease(name, limit=1, artist=None):
|
||||
rg_type = ''
|
||||
if 'type' in result['release-group']:
|
||||
rg_type = result['release-group']['type']
|
||||
if 'secondary-type-list' in result['release-group']:
|
||||
if rg_type == 'Album' and 'secondary-type-list' in result['release-group']:
|
||||
secondary_type = result['release-group']['secondary-type-list'][0]
|
||||
if secondary_type != rg_type:
|
||||
rg_type += ' + ' + secondary_type
|
||||
rg_type = secondary_type
|
||||
|
||||
releaselist.append({
|
||||
'uniquename': unicode(result['artist-credit'][0]['artist']['name']),
|
||||
@@ -272,13 +272,17 @@ def getArtist(artistid, extrasonly=False):
|
||||
if includeExtras:
|
||||
|
||||
# Need to convert extras string from something like '2,5.6' to ['ep','live','remix'] (append new extras to end)
|
||||
extras = db_artist['Extras']
|
||||
if db_artist['Extras']:
|
||||
extras = map(int, db_artist['Extras'].split(','))
|
||||
else:
|
||||
extras = []
|
||||
extras_list = ["single", "ep", "compilation", "soundtrack", "live", "remix", "spokenword", "audiobook", "other", "dj-mix", "mixtape/street", "broadcast", "interview"]
|
||||
|
||||
includes = []
|
||||
|
||||
i = 1
|
||||
for extra in extras_list:
|
||||
if str(i) in extras:
|
||||
if i in extras:
|
||||
includes.append(extra)
|
||||
i += 1
|
||||
|
||||
@@ -299,10 +303,10 @@ def getArtist(artistid, extrasonly=False):
|
||||
for rg in mb_extras_list:
|
||||
|
||||
rg_type = rg['type']
|
||||
if 'secondary-type-list' in rg:
|
||||
if rg_type == 'Album' and 'secondary-type-list' in rg:
|
||||
secondary_type = rg['secondary-type-list'][0]
|
||||
if secondary_type != rg_type:
|
||||
rg_type += ' + ' + secondary_type
|
||||
rg_type = secondary_type
|
||||
|
||||
releasegroups.append({
|
||||
'title': unicode(rg['title']),
|
||||
@@ -380,10 +384,10 @@ def getRelease(releaseid, include_artist_info=True):
|
||||
try:
|
||||
release['rg_type'] = unicode(results['release-group']['type'])
|
||||
|
||||
if 'secondary-type-list' in results['release-group']:
|
||||
if release['rg_type'] == 'Album' and 'secondary-type-list' in results['release-group']:
|
||||
secondary_type = unicode(results['release-group']['secondary-type-list'][0])
|
||||
if secondary_type != release['rg_type']:
|
||||
release['rg_type'] += ' + ' + secondary_type
|
||||
release['rg_type'] = secondary_type
|
||||
|
||||
except KeyError:
|
||||
release['rg_type'] = u'Unknown'
|
||||
@@ -467,10 +471,10 @@ def get_new_releases(rgid,includeExtras=False,forcefull=False):
|
||||
raise Exception('No release group associated with release id ' + releasedata['id'] + ' album id' + rgid)
|
||||
release['Type'] = unicode(releasedata['release-group']['type'])
|
||||
|
||||
if 'secondary-type-list' in releasedata['release-group']:
|
||||
if release['Type'] == 'Album' and 'secondary-type-list' in releasedata['release-group']:
|
||||
secondary_type = unicode(releasedata['release-group']['secondary-type-list'][0])
|
||||
if secondary_type != release['Type']:
|
||||
release['Type'] += ' + ' + secondary_type
|
||||
release['Type'] = secondary_type
|
||||
|
||||
#making the assumption that the most important artist will be first in the list
|
||||
if 'artist-credit' in releasedata:
|
||||
|
||||
@@ -180,7 +180,7 @@ def setSeedRatio(hash, ratio):
|
||||
uTorrentClient.setprops(hash,'seed_ratio', ratio * 10)
|
||||
else:
|
||||
# TODO passing -1 should be unlimited
|
||||
uTorrentClient.setprops(hash,'seed_ratio', -1.00)
|
||||
uTorrentClient.setprops(hash,'seed_ratio', -10)
|
||||
|
||||
def dirTorrent(hash, cacheid=None, return_name=None):
|
||||
|
||||
@@ -214,8 +214,8 @@ def addTorrent(link, hash):
|
||||
# Get Active Directory from settings
|
||||
active_dir, completed_dir = getSettingsDirectories()
|
||||
|
||||
if not active_dir or not completed_dir:
|
||||
logger.error('Could not get "Put new downloads in:" or "Move completed downloads to:" directories from uTorrent settings, please ensure they are set')
|
||||
if not active_dir:
|
||||
logger.error('Could not get "Put new downloads in:" directory from uTorrent settings, please ensure it is set')
|
||||
return None
|
||||
|
||||
uTorrentClient.add_url(link)
|
||||
|
||||
@@ -87,17 +87,16 @@ class WebInterface(object):
|
||||
|
||||
# Serve the extras up as a dict to make things easier for new templates (append new extras to the end)
|
||||
extras_list = ["single", "ep", "compilation", "soundtrack", "live", "remix", "spokenword", "audiobook", "other", "djmix", "mixtape_street", "broadcast", "interview"]
|
||||
if artist['Extras']:
|
||||
artist_extras = map(int, artist['Extras'].split(','))
|
||||
else:
|
||||
artist_extras = []
|
||||
|
||||
extras_dict = OrderedDict()
|
||||
|
||||
if not artist['Extras']:
|
||||
artist_extras = ""
|
||||
else:
|
||||
artist_extras = artist['Extras']
|
||||
|
||||
i = 1
|
||||
for extra in extras_list:
|
||||
if str(i) in artist_extras:
|
||||
if i in artist_extras:
|
||||
extras_dict[extra] = "checked"
|
||||
else:
|
||||
extras_dict[extra] = ""
|
||||
@@ -1154,12 +1153,16 @@ class WebInterface(object):
|
||||
|
||||
# Need to convert EXTRAS to a dictionary we can pass to the config: it'll come in as a string like 2,5,6,8 (append new extras to the end)
|
||||
extras_list = ["single", "ep", "compilation", "soundtrack", "live", "remix", "spokenword", "audiobook", "other", "djmix", "mixtape_street", "broadcast", "interview"]
|
||||
if headphones.EXTRAS:
|
||||
extras = map(int, headphones.EXTRAS.split(','))
|
||||
else:
|
||||
extras = []
|
||||
|
||||
extras_dict = OrderedDict()
|
||||
|
||||
i = 1
|
||||
for extra in extras_list:
|
||||
if str(i) in headphones.EXTRAS:
|
||||
if i in extras:
|
||||
extras_dict[extra] = "checked"
|
||||
else:
|
||||
extras_dict[extra] = ""
|
||||
|
||||
Reference in New Issue
Block a user