mirror of
https://github.com/rembo10/headphones.git
synced 2026-07-20 16:03:59 +01:00
Fix E201,E202,E211,E241,E303 whitespace issues
This commit is contained in:
+27
-27
@@ -31,17 +31,17 @@ def switch(AlbumID, ReleaseID):
|
|||||||
'SELECT * from alltracks WHERE ReleaseID=?', [ReleaseID]).fetchall()
|
'SELECT * from alltracks WHERE ReleaseID=?', [ReleaseID]).fetchall()
|
||||||
myDB.action('DELETE from tracks WHERE AlbumID=?', [AlbumID])
|
myDB.action('DELETE from tracks WHERE AlbumID=?', [AlbumID])
|
||||||
|
|
||||||
controlValueDict = {"AlbumID": AlbumID}
|
controlValueDict = {"AlbumID": AlbumID}
|
||||||
|
|
||||||
newValueDict = {"ArtistID": newalbumdata['ArtistID'],
|
newValueDict = {"ArtistID": newalbumdata['ArtistID'],
|
||||||
"ArtistName": newalbumdata['ArtistName'],
|
"ArtistName": newalbumdata['ArtistName'],
|
||||||
"AlbumTitle": newalbumdata['AlbumTitle'],
|
"AlbumTitle": newalbumdata['AlbumTitle'],
|
||||||
"ReleaseID": newalbumdata['ReleaseID'],
|
"ReleaseID": newalbumdata['ReleaseID'],
|
||||||
"AlbumASIN": newalbumdata['AlbumASIN'],
|
"AlbumASIN": newalbumdata['AlbumASIN'],
|
||||||
"ReleaseDate": newalbumdata['ReleaseDate'],
|
"ReleaseDate": newalbumdata['ReleaseDate'],
|
||||||
"Type": newalbumdata['Type'],
|
"Type": newalbumdata['Type'],
|
||||||
"ReleaseCountry": newalbumdata['ReleaseCountry'],
|
"ReleaseCountry": newalbumdata['ReleaseCountry'],
|
||||||
"ReleaseFormat": newalbumdata['ReleaseFormat']
|
"ReleaseFormat": newalbumdata['ReleaseFormat']
|
||||||
}
|
}
|
||||||
|
|
||||||
myDB.upsert("albums", newValueDict, controlValueDict)
|
myDB.upsert("albums", newValueDict, controlValueDict)
|
||||||
@@ -53,21 +53,21 @@ def switch(AlbumID, ReleaseID):
|
|||||||
|
|
||||||
for track in newtrackdata:
|
for track in newtrackdata:
|
||||||
|
|
||||||
controlValueDict = {"TrackID": track['TrackID'],
|
controlValueDict = {"TrackID": track['TrackID'],
|
||||||
"AlbumID": AlbumID}
|
"AlbumID": AlbumID}
|
||||||
|
|
||||||
newValueDict = {"ArtistID": track['ArtistID'],
|
newValueDict = {"ArtistID": track['ArtistID'],
|
||||||
"ArtistName": track['ArtistName'],
|
"ArtistName": track['ArtistName'],
|
||||||
"AlbumTitle": track['AlbumTitle'],
|
"AlbumTitle": track['AlbumTitle'],
|
||||||
"AlbumASIN": track['AlbumASIN'],
|
"AlbumASIN": track['AlbumASIN'],
|
||||||
"ReleaseID": track['ReleaseID'],
|
"ReleaseID": track['ReleaseID'],
|
||||||
"TrackTitle": track['TrackTitle'],
|
"TrackTitle": track['TrackTitle'],
|
||||||
"TrackDuration": track['TrackDuration'],
|
"TrackDuration": track['TrackDuration'],
|
||||||
"TrackNumber": track['TrackNumber'],
|
"TrackNumber": track['TrackNumber'],
|
||||||
"CleanName": track['CleanName'],
|
"CleanName": track['CleanName'],
|
||||||
"Location": track['Location'],
|
"Location": track['Location'],
|
||||||
"Format": track['Format'],
|
"Format": track['Format'],
|
||||||
"BitRate": track['BitRate']
|
"BitRate": track['BitRate']
|
||||||
}
|
}
|
||||||
|
|
||||||
myDB.upsert("tracks", newValueDict, controlValueDict)
|
myDB.upsert("tracks", newValueDict, controlValueDict)
|
||||||
@@ -88,9 +88,9 @@ def switch(AlbumID, ReleaseID):
|
|||||||
havetracks = len(myDB.select(
|
havetracks = len(myDB.select(
|
||||||
'SELECT TrackTitle from tracks WHERE ArtistID=? AND Location IS NOT NULL', [newalbumdata['ArtistID']]))
|
'SELECT TrackTitle from tracks WHERE ArtistID=? AND Location IS NOT NULL', [newalbumdata['ArtistID']]))
|
||||||
|
|
||||||
controlValueDict = {"ArtistID": newalbumdata['ArtistID']}
|
controlValueDict = {"ArtistID": newalbumdata['ArtistID']}
|
||||||
|
|
||||||
newValueDict = {"TotalTracks": totaltracks,
|
newValueDict = {"TotalTracks": totaltracks,
|
||||||
"HaveTracks": havetracks}
|
"HaveTracks": havetracks}
|
||||||
|
|
||||||
myDB.upsert("artists", newValueDict, controlValueDict)
|
myDB.upsert("artists", newValueDict, controlValueDict)
|
||||||
|
|||||||
+8
-8
@@ -191,11 +191,11 @@ class Cache(object):
|
|||||||
if not db_info or not db_info['LastUpdated'] or not self._is_current(date=db_info['LastUpdated']):
|
if not db_info or not db_info['LastUpdated'] or not self._is_current(date=db_info['LastUpdated']):
|
||||||
|
|
||||||
self._update_cache()
|
self._update_cache()
|
||||||
info_dict = { 'Summary': self.info_summary, 'Content': self.info_content }
|
info_dict = {'Summary': self.info_summary, 'Content': self.info_content}
|
||||||
return info_dict
|
return info_dict
|
||||||
|
|
||||||
else:
|
else:
|
||||||
info_dict = { 'Summary': db_info['Summary'], 'Content': db_info['Content'] }
|
info_dict = {'Summary': db_info['Summary'], 'Content': db_info['Content']}
|
||||||
return info_dict
|
return info_dict
|
||||||
|
|
||||||
def get_image_links(self, ArtistID=None, AlbumID=None):
|
def get_image_links(self, ArtistID=None, AlbumID=None):
|
||||||
@@ -240,7 +240,7 @@ class Cache(object):
|
|||||||
if not thumb_url:
|
if not thumb_url:
|
||||||
logger.debug('No album thumbnail image found on last.fm')
|
logger.debug('No album thumbnail image found on last.fm')
|
||||||
|
|
||||||
return {'artwork': image_url, 'thumbnail': thumb_url }
|
return {'artwork': image_url, 'thumbnail': thumb_url}
|
||||||
|
|
||||||
def remove_from_cache(self, ArtistID=None, AlbumID=None):
|
def remove_from_cache(self, ArtistID=None, AlbumID=None):
|
||||||
"""
|
"""
|
||||||
@@ -343,13 +343,13 @@ class Cache(object):
|
|||||||
|
|
||||||
#Save the content & summary to the database no matter what if we've opened up the url
|
#Save the content & summary to the database no matter what if we've opened up the url
|
||||||
if self.id_type == 'artist':
|
if self.id_type == 'artist':
|
||||||
controlValueDict = {"ArtistID": self.id}
|
controlValueDict = {"ArtistID": self.id}
|
||||||
else:
|
else:
|
||||||
controlValueDict = {"ReleaseGroupID": self.id}
|
controlValueDict = {"ReleaseGroupID": self.id}
|
||||||
|
|
||||||
newValueDict = {"Summary": self.info_summary,
|
newValueDict = {"Summary": self.info_summary,
|
||||||
"Content": self.info_content,
|
"Content": self.info_content,
|
||||||
"LastUpdated": helpers.today()}
|
"LastUpdated": helpers.today()}
|
||||||
|
|
||||||
myDB.upsert("descriptions", newValueDict, controlValueDict)
|
myDB.upsert("descriptions", newValueDict, controlValueDict)
|
||||||
|
|
||||||
|
|||||||
+10
-10
@@ -381,16 +381,16 @@ class Config(object):
|
|||||||
if self.CONFIG_VERSION == '1':
|
if self.CONFIG_VERSION == '1':
|
||||||
from headphones.helpers import replace_all
|
from headphones.helpers import replace_all
|
||||||
file_values = {
|
file_values = {
|
||||||
'Track': '$Track',
|
'Track': '$Track',
|
||||||
'Title': '$Title',
|
'Title': '$Title',
|
||||||
'Artist': '$Artist',
|
'Artist': '$Artist',
|
||||||
'Album': '$Album',
|
'Album': '$Album',
|
||||||
'Year': '$Year',
|
'Year': '$Year',
|
||||||
'track': '$track',
|
'track': '$track',
|
||||||
'title': '$title',
|
'title': '$title',
|
||||||
'artist': '$artist',
|
'artist': '$artist',
|
||||||
'album': '$album',
|
'album': '$album',
|
||||||
'year': '$year'
|
'year': '$year'
|
||||||
}
|
}
|
||||||
folder_values = {
|
folder_values = {
|
||||||
'Artist': '$Artist',
|
'Artist': '$Artist',
|
||||||
|
|||||||
@@ -12,11 +12,11 @@ def getXldProfile(xldProfile):
|
|||||||
try:
|
try:
|
||||||
preferences = plistlib.Plist.fromFile(expandedPath)
|
preferences = plistlib.Plist.fromFile(expandedPath)
|
||||||
except (expat.ExpatError):
|
except (expat.ExpatError):
|
||||||
os.system("/usr/bin/plutil -convert xml1 %s" % expandedPath )
|
os.system("/usr/bin/plutil -convert xml1 %s" % expandedPath)
|
||||||
try:
|
try:
|
||||||
preferences = plistlib.Plist.fromFile(expandedPath)
|
preferences = plistlib.Plist.fromFile(expandedPath)
|
||||||
except (ImportError):
|
except (ImportError):
|
||||||
os.system("/usr/bin/plutil -convert binary1 %s" % expandedPath )
|
os.system("/usr/bin/plutil -convert binary1 %s" % expandedPath)
|
||||||
logger.info('The plist at "%s" has a date in it, and therefore is not useable.' % expandedPath)
|
logger.info('The plist at "%s" has a date in it, and therefore is not useable.' % expandedPath)
|
||||||
return(xldProfileNotFound, None, None)
|
return(xldProfileNotFound, None, None)
|
||||||
except (ImportError):
|
except (ImportError):
|
||||||
|
|||||||
+11
-11
@@ -33,7 +33,7 @@ RE_CD = re.compile(r"^(CD|dics)\s*[0-9]+$", re.I)
|
|||||||
|
|
||||||
|
|
||||||
def multikeysort(items, columns):
|
def multikeysort(items, columns):
|
||||||
comparers = [ ((itemgetter(col[1:].strip()), -1) if col.startswith('-') else (itemgetter(col.strip()), 1)) for col in columns]
|
comparers = [((itemgetter(col[1:].strip()), -1) if col.startswith('-') else (itemgetter(col.strip()), 1)) for col in columns]
|
||||||
|
|
||||||
def comparer(left, right):
|
def comparer(left, right):
|
||||||
for fn, mult in comparers:
|
for fn, mult in comparers:
|
||||||
@@ -290,7 +290,7 @@ def expand_subfolders(f):
|
|||||||
return
|
return
|
||||||
|
|
||||||
# Split into path components
|
# Split into path components
|
||||||
media_folders = [ split_path(media_folder) for media_folder in media_folders ]
|
media_folders = [split_path(media_folder) for media_folder in media_folders]
|
||||||
|
|
||||||
# Correct folder endings such as CD1 etc.
|
# Correct folder endings such as CD1 etc.
|
||||||
for index, media_folder in enumerate(media_folders):
|
for index, media_folder in enumerate(media_folders):
|
||||||
@@ -298,7 +298,7 @@ def expand_subfolders(f):
|
|||||||
media_folders[index] = media_folders[index][:-1]
|
media_folders[index] = media_folders[index][:-1]
|
||||||
|
|
||||||
# Verify the result by computing path depth relative to root.
|
# Verify the result by computing path depth relative to root.
|
||||||
path_depths = [ len(media_folder) for media_folder in media_folders ]
|
path_depths = [len(media_folder) for media_folder in media_folders]
|
||||||
difference = max(path_depths) - min(path_depths)
|
difference = max(path_depths) - min(path_depths)
|
||||||
|
|
||||||
if difference > 0:
|
if difference > 0:
|
||||||
@@ -308,15 +308,15 @@ def expand_subfolders(f):
|
|||||||
# directory may contain separate CD's and maybe some extra's. The
|
# directory may contain separate CD's and maybe some extra's. The
|
||||||
# structure may look like X albums at same depth, and (one or more)
|
# structure may look like X albums at same depth, and (one or more)
|
||||||
# extra folders with a higher depth.
|
# extra folders with a higher depth.
|
||||||
extra_media_folders = [ media_folder[:min(path_depths)] for media_folder in media_folders if len(media_folder) > min(path_depths) ]
|
extra_media_folders = [media_folder[:min(path_depths)] for media_folder in media_folders if len(media_folder) > min(path_depths)]
|
||||||
extra_media_folders = list(set([ os.path.join(*media_folder) for media_folder in extra_media_folders ]))
|
extra_media_folders = list(set([os.path.join(*media_folder) for media_folder in extra_media_folders]))
|
||||||
|
|
||||||
logger.info("Please look at the following folder(s), since they cause the depth difference: %s", extra_media_folders)
|
logger.info("Please look at the following folder(s), since they cause the depth difference: %s", extra_media_folders)
|
||||||
return
|
return
|
||||||
|
|
||||||
# Convert back to paths and remove duplicates, which may be there after
|
# Convert back to paths and remove duplicates, which may be there after
|
||||||
# correcting the paths
|
# correcting the paths
|
||||||
media_folders = list(set([ os.path.join(*media_folder) for media_folder in media_folders ]))
|
media_folders = list(set([os.path.join(*media_folder) for media_folder in media_folders]))
|
||||||
|
|
||||||
# Don't return a result if the number of subfolders is one. In this case,
|
# Don't return a result if the number of subfolders is one. In this case,
|
||||||
# this algorithm will not improve processing and will likely interfere
|
# this algorithm will not improve processing and will likely interfere
|
||||||
@@ -406,9 +406,9 @@ def extract_metadata(f):
|
|||||||
return (None, None, None)
|
return (None, None, None)
|
||||||
|
|
||||||
# Count distinct values
|
# Count distinct values
|
||||||
artists = list(set([ x[0] for x in results ]))
|
artists = list(set([x[0] for x in results]))
|
||||||
albums = list(set([ x[1] for x in results ]))
|
albums = list(set([x[1] for x in results]))
|
||||||
years = list(set([ x[2] for x in results ]))
|
years = list(set([x[2] for x in results]))
|
||||||
|
|
||||||
# Remove things such as CD2 from album names
|
# Remove things such as CD2 from album names
|
||||||
if len(albums) > 1:
|
if len(albums) > 1:
|
||||||
@@ -436,8 +436,8 @@ def extract_metadata(f):
|
|||||||
|
|
||||||
# (Lots of) different artists. Could be a featuring album, so test for this.
|
# (Lots of) different artists. Could be a featuring album, so test for this.
|
||||||
if len(artists) > 1 and len(albums) == 1:
|
if len(artists) > 1 and len(albums) == 1:
|
||||||
split_artists = [ RE_FEATURING.split(artist) for artist in artists ]
|
split_artists = [RE_FEATURING.split(artist) for artist in artists]
|
||||||
featurings = [ len(split_artist) - 1 for split_artist in split_artists ]
|
featurings = [len(split_artist) - 1 for split_artist in split_artists]
|
||||||
logger.info("Album seem to feature %d different artists", sum(featurings))
|
logger.info("Album seem to feature %d different artists", sum(featurings))
|
||||||
|
|
||||||
if sum(featurings) > 0:
|
if sum(featurings) > 0:
|
||||||
|
|||||||
+131
-131
@@ -133,19 +133,19 @@ def addArtisttoDB(artistid, extrasonly=False, forcefull=False):
|
|||||||
|
|
||||||
# We need the current minimal info in the database instantly
|
# We need the current minimal info in the database instantly
|
||||||
# so we don't throw a 500 error when we redirect to the artistPage
|
# so we don't throw a 500 error when we redirect to the artistPage
|
||||||
controlValueDict = {"ArtistID": artistid}
|
controlValueDict = {"ArtistID": artistid}
|
||||||
|
|
||||||
# Don't replace a known artist name with an "Artist ID" placeholder
|
# Don't replace a known artist name with an "Artist ID" placeholder
|
||||||
dbartist = myDB.action('SELECT * FROM artists WHERE ArtistID=?', [artistid]).fetchone()
|
dbartist = myDB.action('SELECT * FROM artists WHERE ArtistID=?', [artistid]).fetchone()
|
||||||
|
|
||||||
# Only modify the Include Extras stuff if it's a new artist. We need it early so we know what to fetch
|
# Only modify the Include Extras stuff if it's a new artist. We need it early so we know what to fetch
|
||||||
if not dbartist:
|
if not dbartist:
|
||||||
newValueDict = {"ArtistName": "Artist ID: %s" % (artistid),
|
newValueDict = {"ArtistName": "Artist ID: %s" % (artistid),
|
||||||
"Status": "Loading",
|
"Status": "Loading",
|
||||||
"IncludeExtras": headphones.CONFIG.INCLUDE_EXTRAS,
|
"IncludeExtras": headphones.CONFIG.INCLUDE_EXTRAS,
|
||||||
"Extras": headphones.CONFIG.EXTRAS }
|
"Extras": headphones.CONFIG.EXTRAS}
|
||||||
else:
|
else:
|
||||||
newValueDict = {"Status": "Loading"}
|
newValueDict = {"Status": "Loading"}
|
||||||
|
|
||||||
myDB.upsert("artists", newValueDict, controlValueDict)
|
myDB.upsert("artists", newValueDict, controlValueDict)
|
||||||
|
|
||||||
@@ -162,10 +162,10 @@ def addArtisttoDB(artistid, extrasonly=False, forcefull=False):
|
|||||||
if not artist:
|
if not artist:
|
||||||
logger.warn("Error fetching artist info. ID: " + artistid)
|
logger.warn("Error fetching artist info. ID: " + artistid)
|
||||||
if dbartist is None:
|
if dbartist is None:
|
||||||
newValueDict = {"ArtistName": "Fetch failed, try refreshing. (%s)" % (artistid),
|
newValueDict = {"ArtistName": "Fetch failed, try refreshing. (%s)" % (artistid),
|
||||||
"Status": "Active"}
|
"Status": "Active"}
|
||||||
else:
|
else:
|
||||||
newValueDict = {"Status": "Active"}
|
newValueDict = {"Status": "Active"}
|
||||||
myDB.upsert("artists", newValueDict, controlValueDict)
|
myDB.upsert("artists", newValueDict, controlValueDict)
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -175,11 +175,11 @@ def addArtisttoDB(artistid, extrasonly=False, forcefull=False):
|
|||||||
sortname = artist['artist_name']
|
sortname = artist['artist_name']
|
||||||
|
|
||||||
logger.info(u"Now adding/updating: " + artist['artist_name'])
|
logger.info(u"Now adding/updating: " + artist['artist_name'])
|
||||||
controlValueDict = {"ArtistID": artistid}
|
controlValueDict = {"ArtistID": artistid}
|
||||||
newValueDict = {"ArtistName": artist['artist_name'],
|
newValueDict = {"ArtistName": artist['artist_name'],
|
||||||
"ArtistSortName": sortname,
|
"ArtistSortName": sortname,
|
||||||
"DateAdded": helpers.today(),
|
"DateAdded": helpers.today(),
|
||||||
"Status": "Loading"}
|
"Status": "Loading"}
|
||||||
|
|
||||||
myDB.upsert("artists", newValueDict, controlValueDict)
|
myDB.upsert("artists", newValueDict, controlValueDict)
|
||||||
|
|
||||||
@@ -292,26 +292,26 @@ def addArtisttoDB(artistid, extrasonly=False, forcefull=False):
|
|||||||
for items in find_hybrid_releases:
|
for items in find_hybrid_releases:
|
||||||
if items['ReleaseID'] != rg['id']: #don't include hybrid information, since that's what we're replacing
|
if items['ReleaseID'] != rg['id']: #don't include hybrid information, since that's what we're replacing
|
||||||
hybrid_release_id = items['ReleaseID']
|
hybrid_release_id = items['ReleaseID']
|
||||||
newValueDict = {"ArtistID": items['ArtistID'],
|
newValueDict = {"ArtistID": items['ArtistID'],
|
||||||
"ArtistName": items['ArtistName'],
|
"ArtistName": items['ArtistName'],
|
||||||
"AlbumTitle": items['AlbumTitle'],
|
"AlbumTitle": items['AlbumTitle'],
|
||||||
"AlbumID": items['AlbumID'],
|
"AlbumID": items['AlbumID'],
|
||||||
"AlbumASIN": items['AlbumASIN'],
|
"AlbumASIN": items['AlbumASIN'],
|
||||||
"ReleaseDate": items['ReleaseDate'],
|
"ReleaseDate": items['ReleaseDate'],
|
||||||
"Type": items['Type'],
|
"Type": items['Type'],
|
||||||
"ReleaseCountry": items['ReleaseCountry'],
|
"ReleaseCountry": items['ReleaseCountry'],
|
||||||
"ReleaseFormat": items['ReleaseFormat']
|
"ReleaseFormat": items['ReleaseFormat']
|
||||||
}
|
}
|
||||||
find_hybrid_tracks = myDB.action("SELECT * from alltracks WHERE ReleaseID=?", [hybrid_release_id])
|
find_hybrid_tracks = myDB.action("SELECT * from alltracks WHERE ReleaseID=?", [hybrid_release_id])
|
||||||
totalTracks = 1
|
totalTracks = 1
|
||||||
hybrid_track_array = []
|
hybrid_track_array = []
|
||||||
for hybrid_tracks in find_hybrid_tracks:
|
for hybrid_tracks in find_hybrid_tracks:
|
||||||
hybrid_track_array.append({
|
hybrid_track_array.append({
|
||||||
'number': hybrid_tracks['TrackNumber'],
|
'number': hybrid_tracks['TrackNumber'],
|
||||||
'title': hybrid_tracks['TrackTitle'],
|
'title': hybrid_tracks['TrackTitle'],
|
||||||
'id': hybrid_tracks['TrackID'],
|
'id': hybrid_tracks['TrackID'],
|
||||||
#'url': hybrid_tracks['TrackURL'],
|
#'url': hybrid_tracks['TrackURL'],
|
||||||
'duration': hybrid_tracks['TrackDuration']
|
'duration': hybrid_tracks['TrackDuration']
|
||||||
})
|
})
|
||||||
totalTracks += 1
|
totalTracks += 1
|
||||||
newValueDict['ReleaseID'] = hybrid_release_id
|
newValueDict['ReleaseID'] = hybrid_release_id
|
||||||
@@ -331,15 +331,15 @@ def addArtisttoDB(artistid, extrasonly=False, forcefull=False):
|
|||||||
# Use the ReleaseGroupID as the ReleaseID for the hybrid release to differentiate it
|
# Use the ReleaseGroupID as the ReleaseID for the hybrid release to differentiate it
|
||||||
# We can then use the condition WHERE ReleaseID == ReleaseGroupID to select it
|
# We can then use the condition WHERE ReleaseID == ReleaseGroupID to select it
|
||||||
# The hybrid won't have a country or a format
|
# The hybrid won't have a country or a format
|
||||||
controlValueDict = {"ReleaseID": rg['id']}
|
controlValueDict = {"ReleaseID": rg['id']}
|
||||||
|
|
||||||
newValueDict = {"ArtistID": artistid,
|
newValueDict = {"ArtistID": artistid,
|
||||||
"ArtistName": artist['artist_name'],
|
"ArtistName": artist['artist_name'],
|
||||||
"AlbumTitle": rg['title'],
|
"AlbumTitle": rg['title'],
|
||||||
"AlbumID": rg['id'],
|
"AlbumID": rg['id'],
|
||||||
"AlbumASIN": hybridrelease['AlbumASIN'],
|
"AlbumASIN": hybridrelease['AlbumASIN'],
|
||||||
"ReleaseDate": hybridrelease['ReleaseDate'],
|
"ReleaseDate": hybridrelease['ReleaseDate'],
|
||||||
"Type": rg['type']
|
"Type": rg['type']
|
||||||
}
|
}
|
||||||
|
|
||||||
myDB.upsert("allalbums", newValueDict, controlValueDict)
|
myDB.upsert("allalbums", newValueDict, controlValueDict)
|
||||||
@@ -348,18 +348,18 @@ def addArtisttoDB(artistid, extrasonly=False, forcefull=False):
|
|||||||
|
|
||||||
cleanname = helpers.cleanName(artist['artist_name'] + ' ' + rg['title'] + ' ' + track['title'])
|
cleanname = helpers.cleanName(artist['artist_name'] + ' ' + rg['title'] + ' ' + track['title'])
|
||||||
|
|
||||||
controlValueDict = {"TrackID": track['id'],
|
controlValueDict = {"TrackID": track['id'],
|
||||||
"ReleaseID": rg['id']}
|
"ReleaseID": rg['id']}
|
||||||
|
|
||||||
newValueDict = {"ArtistID": artistid,
|
newValueDict = {"ArtistID": artistid,
|
||||||
"ArtistName": artist['artist_name'],
|
"ArtistName": artist['artist_name'],
|
||||||
"AlbumTitle": rg['title'],
|
"AlbumTitle": rg['title'],
|
||||||
"AlbumASIN": hybridrelease['AlbumASIN'],
|
"AlbumASIN": hybridrelease['AlbumASIN'],
|
||||||
"AlbumID": rg['id'],
|
"AlbumID": rg['id'],
|
||||||
"TrackTitle": track['title'],
|
"TrackTitle": track['title'],
|
||||||
"TrackDuration": track['duration'],
|
"TrackDuration": track['duration'],
|
||||||
"TrackNumber": track['number'],
|
"TrackNumber": track['number'],
|
||||||
"CleanName": cleanname
|
"CleanName": cleanname
|
||||||
}
|
}
|
||||||
|
|
||||||
match = myDB.action('SELECT Location, BitRate, Format from have WHERE CleanName=?', [cleanname]).fetchone()
|
match = myDB.action('SELECT Location, BitRate, Format from have WHERE CleanName=?', [cleanname]).fetchone()
|
||||||
@@ -392,17 +392,17 @@ def addArtisttoDB(artistid, extrasonly=False, forcefull=False):
|
|||||||
|
|
||||||
album = myDB.action('SELECT * from allalbums WHERE ReleaseID=?', [releaseid]).fetchone()
|
album = myDB.action('SELECT * from allalbums WHERE ReleaseID=?', [releaseid]).fetchone()
|
||||||
|
|
||||||
controlValueDict = {"AlbumID": rg['id']}
|
controlValueDict = {"AlbumID": rg['id']}
|
||||||
|
|
||||||
newValueDict = {"ArtistID": album['ArtistID'],
|
newValueDict = {"ArtistID": album['ArtistID'],
|
||||||
"ArtistName": album['ArtistName'],
|
"ArtistName": album['ArtistName'],
|
||||||
"AlbumTitle": album['AlbumTitle'],
|
"AlbumTitle": album['AlbumTitle'],
|
||||||
"ReleaseID": album['ReleaseID'],
|
"ReleaseID": album['ReleaseID'],
|
||||||
"AlbumASIN": album['AlbumASIN'],
|
"AlbumASIN": album['AlbumASIN'],
|
||||||
"ReleaseDate": album['ReleaseDate'],
|
"ReleaseDate": album['ReleaseDate'],
|
||||||
"Type": album['Type'],
|
"Type": album['Type'],
|
||||||
"ReleaseCountry": album['ReleaseCountry'],
|
"ReleaseCountry": album['ReleaseCountry'],
|
||||||
"ReleaseFormat": album['ReleaseFormat']
|
"ReleaseFormat": album['ReleaseFormat']
|
||||||
}
|
}
|
||||||
|
|
||||||
if rg_exists:
|
if rg_exists:
|
||||||
@@ -440,21 +440,21 @@ def addArtisttoDB(artistid, extrasonly=False, forcefull=False):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
for track in tracks:
|
for track in tracks:
|
||||||
controlValueDict = {"TrackID": track['TrackID'],
|
controlValueDict = {"TrackID": track['TrackID'],
|
||||||
"AlbumID": rg['id']}
|
"AlbumID": rg['id']}
|
||||||
|
|
||||||
newValueDict = {"ArtistID": track['ArtistID'],
|
newValueDict = {"ArtistID": track['ArtistID'],
|
||||||
"ArtistName": track['ArtistName'],
|
"ArtistName": track['ArtistName'],
|
||||||
"AlbumTitle": track['AlbumTitle'],
|
"AlbumTitle": track['AlbumTitle'],
|
||||||
"AlbumASIN": track['AlbumASIN'],
|
"AlbumASIN": track['AlbumASIN'],
|
||||||
"ReleaseID": track['ReleaseID'],
|
"ReleaseID": track['ReleaseID'],
|
||||||
"TrackTitle": track['TrackTitle'],
|
"TrackTitle": track['TrackTitle'],
|
||||||
"TrackDuration": track['TrackDuration'],
|
"TrackDuration": track['TrackDuration'],
|
||||||
"TrackNumber": track['TrackNumber'],
|
"TrackNumber": track['TrackNumber'],
|
||||||
"CleanName": track['CleanName'],
|
"CleanName": track['CleanName'],
|
||||||
"Location": track['Location'],
|
"Location": track['Location'],
|
||||||
"Format": track['Format'],
|
"Format": track['Format'],
|
||||||
"BitRate": track['BitRate']
|
"BitRate": track['BitRate']
|
||||||
}
|
}
|
||||||
|
|
||||||
myDB.upsert("tracks", newValueDict, controlValueDict)
|
myDB.upsert("tracks", newValueDict, controlValueDict)
|
||||||
@@ -515,19 +515,19 @@ def finalize_update(artistid, artistname, errors=False):
|
|||||||
#havetracks = len(myDB.select('SELECT TrackTitle from tracks WHERE ArtistID=? AND Location IS NOT NULL', [artistid])) + len(myDB.select('SELECT TrackTitle from have WHERE ArtistName like ?', [artist['artist_name']]))
|
#havetracks = len(myDB.select('SELECT TrackTitle from tracks WHERE ArtistID=? AND Location IS NOT NULL', [artistid])) + len(myDB.select('SELECT TrackTitle from have WHERE ArtistName like ?', [artist['artist_name']]))
|
||||||
havetracks = len(myDB.select('SELECT TrackTitle from tracks WHERE ArtistID=? AND Location IS NOT NULL', [artistid])) + len(myDB.select('SELECT TrackTitle from have WHERE ArtistName like ? AND Matched = "Failed"', [artistname]))
|
havetracks = len(myDB.select('SELECT TrackTitle from tracks WHERE ArtistID=? AND Location IS NOT NULL', [artistid])) + len(myDB.select('SELECT TrackTitle from have WHERE ArtistName like ? AND Matched = "Failed"', [artistname]))
|
||||||
|
|
||||||
controlValueDict = {"ArtistID": artistid}
|
controlValueDict = {"ArtistID": artistid}
|
||||||
|
|
||||||
if latestalbum:
|
if latestalbum:
|
||||||
newValueDict = {"Status": "Active",
|
newValueDict = {"Status": "Active",
|
||||||
"LatestAlbum": latestalbum['AlbumTitle'],
|
"LatestAlbum": latestalbum['AlbumTitle'],
|
||||||
"ReleaseDate": latestalbum['ReleaseDate'],
|
"ReleaseDate": latestalbum['ReleaseDate'],
|
||||||
"AlbumID": latestalbum['AlbumID'],
|
"AlbumID": latestalbum['AlbumID'],
|
||||||
"TotalTracks": totaltracks,
|
"TotalTracks": totaltracks,
|
||||||
"HaveTracks": havetracks}
|
"HaveTracks": havetracks}
|
||||||
else:
|
else:
|
||||||
newValueDict = {"Status": "Active",
|
newValueDict = {"Status": "Active",
|
||||||
"TotalTracks": totaltracks,
|
"TotalTracks": totaltracks,
|
||||||
"HaveTracks": havetracks}
|
"HaveTracks": havetracks}
|
||||||
|
|
||||||
if not errors:
|
if not errors:
|
||||||
newValueDict['LastUpdated'] = helpers.now()
|
newValueDict['LastUpdated'] = helpers.now()
|
||||||
@@ -545,10 +545,10 @@ def addReleaseById(rid, rgid=None):
|
|||||||
dbalbum = myDB.select("SELECT * from albums WHERE AlbumID=?", [rgid])
|
dbalbum = myDB.select("SELECT * from albums WHERE AlbumID=?", [rgid])
|
||||||
if not dbalbum:
|
if not dbalbum:
|
||||||
status = 'Loading'
|
status = 'Loading'
|
||||||
controlValueDict = {"AlbumID": rgid}
|
controlValueDict = {"AlbumID": rgid}
|
||||||
newValueDict = {"AlbumTitle": rgid,
|
newValueDict = {"AlbumTitle": rgid,
|
||||||
"ArtistName": status,
|
"ArtistName": status,
|
||||||
"Status": status}
|
"Status": status}
|
||||||
myDB.upsert("albums", newValueDict, controlValueDict)
|
myDB.upsert("albums", newValueDict, controlValueDict)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
@@ -592,11 +592,11 @@ def addReleaseById(rid, rgid=None):
|
|||||||
sortname = release_dict['artist_name']
|
sortname = release_dict['artist_name']
|
||||||
|
|
||||||
logger.info(u"Now manually adding: " + release_dict['artist_name'] + " - with status Paused")
|
logger.info(u"Now manually adding: " + release_dict['artist_name'] + " - with status Paused")
|
||||||
controlValueDict = {"ArtistID": release_dict['artist_id']}
|
controlValueDict = {"ArtistID": release_dict['artist_id']}
|
||||||
newValueDict = {"ArtistName": release_dict['artist_name'],
|
newValueDict = {"ArtistName": release_dict['artist_name'],
|
||||||
"ArtistSortName": sortname,
|
"ArtistSortName": sortname,
|
||||||
"DateAdded": helpers.today(),
|
"DateAdded": helpers.today(),
|
||||||
"Status": "Paused"}
|
"Status": "Paused"}
|
||||||
|
|
||||||
if headphones.CONFIG.INCLUDE_EXTRAS:
|
if headphones.CONFIG.INCLUDE_EXTRAS:
|
||||||
newValueDict['IncludeExtras'] = 1
|
newValueDict['IncludeExtras'] = 1
|
||||||
@@ -613,20 +613,20 @@ def addReleaseById(rid, rgid=None):
|
|||||||
if not rg_exists and release_dict or status == 'Loading' and release_dict: #it should never be the case that we have an rg and not the artist
|
if not rg_exists and release_dict or status == 'Loading' and release_dict: #it should never be the case that we have an rg and not the artist
|
||||||
#but if it is this will fail
|
#but if it is this will fail
|
||||||
logger.info(u"Now adding-by-id album (" + release_dict['title'] + ") from id: " + rgid)
|
logger.info(u"Now adding-by-id album (" + release_dict['title'] + ") from id: " + rgid)
|
||||||
controlValueDict = {"AlbumID": rgid}
|
controlValueDict = {"AlbumID": rgid}
|
||||||
if status != 'Loading':
|
if status != 'Loading':
|
||||||
status = 'Wanted'
|
status = 'Wanted'
|
||||||
|
|
||||||
newValueDict = {"ArtistID": release_dict['artist_id'],
|
newValueDict = {"ArtistID": release_dict['artist_id'],
|
||||||
"ReleaseID": rgid,
|
"ReleaseID": rgid,
|
||||||
"ArtistName": release_dict['artist_name'],
|
"ArtistName": release_dict['artist_name'],
|
||||||
"AlbumTitle": release_dict['title'] if 'title' in release_dict else release_dict['rg_title'],
|
"AlbumTitle": release_dict['title'] if 'title' in release_dict else release_dict['rg_title'],
|
||||||
"AlbumASIN": release_dict['asin'],
|
"AlbumASIN": release_dict['asin'],
|
||||||
"ReleaseDate": release_dict['date'],
|
"ReleaseDate": release_dict['date'],
|
||||||
"DateAdded": helpers.today(),
|
"DateAdded": helpers.today(),
|
||||||
"Status": status,
|
"Status": status,
|
||||||
"Type": release_dict['rg_type'],
|
"Type": release_dict['rg_type'],
|
||||||
"ReleaseID": rid
|
"ReleaseID": rid
|
||||||
}
|
}
|
||||||
|
|
||||||
myDB.upsert("albums", newValueDict, controlValueDict)
|
myDB.upsert("albums", newValueDict, controlValueDict)
|
||||||
@@ -637,16 +637,16 @@ def addReleaseById(rid, rgid=None):
|
|||||||
for track in release_dict['tracks']:
|
for track in release_dict['tracks']:
|
||||||
cleanname = helpers.cleanName(release_dict['artist_name'] + ' ' + release_dict['rg_title'] + ' ' + track['title'])
|
cleanname = helpers.cleanName(release_dict['artist_name'] + ' ' + release_dict['rg_title'] + ' ' + track['title'])
|
||||||
|
|
||||||
controlValueDict = {"TrackID": track['id'],
|
controlValueDict = {"TrackID": track['id'],
|
||||||
"AlbumID": rgid}
|
"AlbumID": rgid}
|
||||||
newValueDict = {"ArtistID": release_dict['artist_id'],
|
newValueDict = {"ArtistID": release_dict['artist_id'],
|
||||||
"ArtistName": release_dict['artist_name'],
|
"ArtistName": release_dict['artist_name'],
|
||||||
"AlbumTitle": release_dict['rg_title'],
|
"AlbumTitle": release_dict['rg_title'],
|
||||||
"AlbumASIN": release_dict['asin'],
|
"AlbumASIN": release_dict['asin'],
|
||||||
"TrackTitle": track['title'],
|
"TrackTitle": track['title'],
|
||||||
"TrackDuration": track['duration'],
|
"TrackDuration": track['duration'],
|
||||||
"TrackNumber": track['number'],
|
"TrackNumber": track['number'],
|
||||||
"CleanName": cleanname
|
"CleanName": cleanname
|
||||||
}
|
}
|
||||||
|
|
||||||
match = myDB.action('SELECT Location, BitRate, Format, Matched from have WHERE CleanName=?', [cleanname]).fetchone()
|
match = myDB.action('SELECT Location, BitRate, Format, Matched from have WHERE CleanName=?', [cleanname]).fetchone()
|
||||||
@@ -671,11 +671,11 @@ def addReleaseById(rid, rgid=None):
|
|||||||
|
|
||||||
# Reset status
|
# Reset status
|
||||||
if status == 'Loading':
|
if status == 'Loading':
|
||||||
controlValueDict = {"AlbumID": rgid}
|
controlValueDict = {"AlbumID": rgid}
|
||||||
if headphones.CONFIG.AUTOWANT_MANUALLY_ADDED:
|
if headphones.CONFIG.AUTOWANT_MANUALLY_ADDED:
|
||||||
newValueDict = {"Status": "Wanted"}
|
newValueDict = {"Status": "Wanted"}
|
||||||
else:
|
else:
|
||||||
newValueDict = {"Status": "Skipped"}
|
newValueDict = {"Status": "Skipped"}
|
||||||
myDB.upsert("albums", newValueDict, controlValueDict)
|
myDB.upsert("albums", newValueDict, controlValueDict)
|
||||||
|
|
||||||
# Start a search for the album
|
# Start a search for the album
|
||||||
@@ -703,7 +703,7 @@ def updateFormat():
|
|||||||
except Exception, e:
|
except Exception, e:
|
||||||
logger.info("Exception from MediaFile for: " + track['Location'] + " : " + str(e))
|
logger.info("Exception from MediaFile for: " + track['Location'] + " : " + str(e))
|
||||||
continue
|
continue
|
||||||
controlValueDict = {"TrackID": track['TrackID']}
|
controlValueDict = {"TrackID": track['TrackID']}
|
||||||
newValueDict = {"Format": f.format}
|
newValueDict = {"Format": f.format}
|
||||||
myDB.upsert("tracks", newValueDict, controlValueDict)
|
myDB.upsert("tracks", newValueDict, controlValueDict)
|
||||||
logger.info('Finished finding media format for %s files' % len(tracks))
|
logger.info('Finished finding media format for %s files' % len(tracks))
|
||||||
@@ -716,7 +716,7 @@ def updateFormat():
|
|||||||
except Exception, e:
|
except Exception, e:
|
||||||
logger.info("Exception from MediaFile for: " + track['Location'] + " : " + str(e))
|
logger.info("Exception from MediaFile for: " + track['Location'] + " : " + str(e))
|
||||||
continue
|
continue
|
||||||
controlValueDict = {"TrackID": track['TrackID']}
|
controlValueDict = {"TrackID": track['TrackID']}
|
||||||
newValueDict = {"Format": f.format}
|
newValueDict = {"Format": f.format}
|
||||||
myDB.upsert("have", newValueDict, controlValueDict)
|
myDB.upsert("have", newValueDict, controlValueDict)
|
||||||
logger.info('Finished finding media format for %s files' % len(havetracks))
|
logger.info('Finished finding media format for %s files' % len(havetracks))
|
||||||
@@ -734,18 +734,18 @@ def getHybridRelease(fullreleaselist):
|
|||||||
sortable_release_list = []
|
sortable_release_list = []
|
||||||
|
|
||||||
formats = {
|
formats = {
|
||||||
'2xVinyl': '2',
|
'2xVinyl': '2',
|
||||||
'Vinyl': '2',
|
'Vinyl': '2',
|
||||||
'CD': '0',
|
'CD': '0',
|
||||||
'Cassette': '3',
|
'Cassette': '3',
|
||||||
'2xCD': '1',
|
'2xCD': '1',
|
||||||
'Digital Media': '0'
|
'Digital Media': '0'
|
||||||
}
|
}
|
||||||
|
|
||||||
countries = {
|
countries = {
|
||||||
'US': '0',
|
'US': '0',
|
||||||
'GB': '1',
|
'GB': '1',
|
||||||
'JP': '2',
|
'JP': '2',
|
||||||
}
|
}
|
||||||
|
|
||||||
for release in fullreleaselist:
|
for release in fullreleaselist:
|
||||||
@@ -762,14 +762,14 @@ def getHybridRelease(fullreleaselist):
|
|||||||
|
|
||||||
# Create record
|
# Create record
|
||||||
release_dict = {
|
release_dict = {
|
||||||
'hasasin': bool(release['AlbumASIN']),
|
'hasasin': bool(release['AlbumASIN']),
|
||||||
'asin': release['AlbumASIN'],
|
'asin': release['AlbumASIN'],
|
||||||
'trackscount': len(release['Tracks']),
|
'trackscount': len(release['Tracks']),
|
||||||
'releaseid': release['ReleaseID'],
|
'releaseid': release['ReleaseID'],
|
||||||
'releasedate': release['ReleaseDate'],
|
'releasedate': release['ReleaseDate'],
|
||||||
'format': format,
|
'format': format,
|
||||||
'country': country,
|
'country': country,
|
||||||
'tracks': release['Tracks']
|
'tracks': release['Tracks']
|
||||||
}
|
}
|
||||||
|
|
||||||
sortable_release_list.append(release_dict)
|
sortable_release_list.append(release_dict)
|
||||||
|
|||||||
+29
-29
@@ -136,7 +136,7 @@ def libraryScan(dir=None, append=False, ArtistID=None, ArtistName=None, cron=Fal
|
|||||||
|
|
||||||
controlValueDict = {'Location': unicode_song_path}
|
controlValueDict = {'Location': unicode_song_path}
|
||||||
|
|
||||||
newValueDict = { 'TrackID': f.mb_trackid,
|
newValueDict = {'TrackID': f.mb_trackid,
|
||||||
#'ReleaseID' : f.mb_albumid,
|
#'ReleaseID' : f.mb_albumid,
|
||||||
'ArtistName': f_artist,
|
'ArtistName': f_artist,
|
||||||
'AlbumTitle': f.album,
|
'AlbumTitle': f.album,
|
||||||
@@ -221,72 +221,72 @@ def libraryScan(dir=None, append=False, ArtistID=None, ArtistName=None, cron=Fal
|
|||||||
track = myDB.action('SELECT ArtistName, AlbumTitle, TrackTitle, AlbumID from tracks WHERE ArtistName LIKE ? AND AlbumTitle LIKE ? AND TrackTitle LIKE ?', [song['ArtistName'], song['AlbumTitle'], song['TrackTitle']]).fetchone()
|
track = myDB.action('SELECT ArtistName, AlbumTitle, TrackTitle, AlbumID from tracks WHERE ArtistName LIKE ? AND AlbumTitle LIKE ? AND TrackTitle LIKE ?', [song['ArtistName'], song['AlbumTitle'], song['TrackTitle']]).fetchone()
|
||||||
have_updated = False
|
have_updated = False
|
||||||
if track:
|
if track:
|
||||||
controlValueDict = { 'ArtistName': track['ArtistName'],
|
controlValueDict = {'ArtistName': track['ArtistName'],
|
||||||
'AlbumTitle': track['AlbumTitle'],
|
'AlbumTitle': track['AlbumTitle'],
|
||||||
'TrackTitle': track['TrackTitle'] }
|
'TrackTitle': track['TrackTitle']}
|
||||||
newValueDict = { 'Location': song['Location'],
|
newValueDict = {'Location': song['Location'],
|
||||||
'BitRate': song['BitRate'],
|
'BitRate': song['BitRate'],
|
||||||
'Format': song['Format'] }
|
'Format': song['Format']}
|
||||||
myDB.upsert("tracks", newValueDict, controlValueDict)
|
myDB.upsert("tracks", newValueDict, controlValueDict)
|
||||||
|
|
||||||
controlValueDict2 = { 'Location': song['Location']}
|
controlValueDict2 = {'Location': song['Location']}
|
||||||
newValueDict2 = { 'Matched': track['AlbumID']}
|
newValueDict2 = {'Matched': track['AlbumID']}
|
||||||
myDB.upsert("have", newValueDict2, controlValueDict2)
|
myDB.upsert("have", newValueDict2, controlValueDict2)
|
||||||
have_updated = True
|
have_updated = True
|
||||||
else:
|
else:
|
||||||
track = myDB.action('SELECT CleanName, AlbumID from tracks WHERE CleanName LIKE ?', [song['CleanName']]).fetchone()
|
track = myDB.action('SELECT CleanName, AlbumID from tracks WHERE CleanName LIKE ?', [song['CleanName']]).fetchone()
|
||||||
if track:
|
if track:
|
||||||
controlValueDict = { 'CleanName': track['CleanName']}
|
controlValueDict = {'CleanName': track['CleanName']}
|
||||||
newValueDict = { 'Location': song['Location'],
|
newValueDict = {'Location': song['Location'],
|
||||||
'BitRate': song['BitRate'],
|
'BitRate': song['BitRate'],
|
||||||
'Format': song['Format'] }
|
'Format': song['Format']}
|
||||||
myDB.upsert("tracks", newValueDict, controlValueDict)
|
myDB.upsert("tracks", newValueDict, controlValueDict)
|
||||||
|
|
||||||
controlValueDict2 = { 'Location': song['Location']}
|
controlValueDict2 = {'Location': song['Location']}
|
||||||
newValueDict2 = { 'Matched': track['AlbumID']}
|
newValueDict2 = {'Matched': track['AlbumID']}
|
||||||
myDB.upsert("have", newValueDict2, controlValueDict2)
|
myDB.upsert("have", newValueDict2, controlValueDict2)
|
||||||
have_updated = True
|
have_updated = True
|
||||||
else:
|
else:
|
||||||
controlValueDict2 = { 'Location': song['Location']}
|
controlValueDict2 = {'Location': song['Location']}
|
||||||
newValueDict2 = { 'Matched': "Failed"}
|
newValueDict2 = {'Matched': "Failed"}
|
||||||
myDB.upsert("have", newValueDict2, controlValueDict2)
|
myDB.upsert("have", newValueDict2, controlValueDict2)
|
||||||
have_updated = True
|
have_updated = True
|
||||||
|
|
||||||
alltrack = myDB.action('SELECT ArtistName, AlbumTitle, TrackTitle, AlbumID from alltracks WHERE ArtistName LIKE ? AND AlbumTitle LIKE ? AND TrackTitle LIKE ?', [song['ArtistName'], song['AlbumTitle'], song['TrackTitle']]).fetchone()
|
alltrack = myDB.action('SELECT ArtistName, AlbumTitle, TrackTitle, AlbumID from alltracks WHERE ArtistName LIKE ? AND AlbumTitle LIKE ? AND TrackTitle LIKE ?', [song['ArtistName'], song['AlbumTitle'], song['TrackTitle']]).fetchone()
|
||||||
if alltrack:
|
if alltrack:
|
||||||
controlValueDict = { 'ArtistName': alltrack['ArtistName'],
|
controlValueDict = {'ArtistName': alltrack['ArtistName'],
|
||||||
'AlbumTitle': alltrack['AlbumTitle'],
|
'AlbumTitle': alltrack['AlbumTitle'],
|
||||||
'TrackTitle': alltrack['TrackTitle'] }
|
'TrackTitle': alltrack['TrackTitle']}
|
||||||
newValueDict = { 'Location': song['Location'],
|
newValueDict = {'Location': song['Location'],
|
||||||
'BitRate': song['BitRate'],
|
'BitRate': song['BitRate'],
|
||||||
'Format': song['Format'] }
|
'Format': song['Format']}
|
||||||
myDB.upsert("alltracks", newValueDict, controlValueDict)
|
myDB.upsert("alltracks", newValueDict, controlValueDict)
|
||||||
|
|
||||||
controlValueDict2 = { 'Location': song['Location']}
|
controlValueDict2 = {'Location': song['Location']}
|
||||||
newValueDict2 = { 'Matched': alltrack['AlbumID']}
|
newValueDict2 = {'Matched': alltrack['AlbumID']}
|
||||||
myDB.upsert("have", newValueDict2, controlValueDict2)
|
myDB.upsert("have", newValueDict2, controlValueDict2)
|
||||||
else:
|
else:
|
||||||
alltrack = myDB.action('SELECT CleanName, AlbumID from alltracks WHERE CleanName LIKE ?', [song['CleanName']]).fetchone()
|
alltrack = myDB.action('SELECT CleanName, AlbumID from alltracks WHERE CleanName LIKE ?', [song['CleanName']]).fetchone()
|
||||||
if alltrack:
|
if alltrack:
|
||||||
controlValueDict = { 'CleanName': alltrack['CleanName']}
|
controlValueDict = {'CleanName': alltrack['CleanName']}
|
||||||
newValueDict = { 'Location': song['Location'],
|
newValueDict = {'Location': song['Location'],
|
||||||
'BitRate': song['BitRate'],
|
'BitRate': song['BitRate'],
|
||||||
'Format': song['Format'] }
|
'Format': song['Format']}
|
||||||
myDB.upsert("alltracks", newValueDict, controlValueDict)
|
myDB.upsert("alltracks", newValueDict, controlValueDict)
|
||||||
|
|
||||||
controlValueDict2 = { 'Location': song['Location']}
|
controlValueDict2 = {'Location': song['Location']}
|
||||||
newValueDict2 = { 'Matched': alltrack['AlbumID']}
|
newValueDict2 = {'Matched': alltrack['AlbumID']}
|
||||||
myDB.upsert("have", newValueDict2, controlValueDict2)
|
myDB.upsert("have", newValueDict2, controlValueDict2)
|
||||||
else:
|
else:
|
||||||
# alltracks may not exist if adding album manually, have should only be set to failed if not already updated in tracks
|
# alltracks may not exist if adding album manually, have should only be set to failed if not already updated in tracks
|
||||||
if not have_updated:
|
if not have_updated:
|
||||||
controlValueDict2 = { 'Location': song['Location']}
|
controlValueDict2 = {'Location': song['Location']}
|
||||||
newValueDict2 = { 'Matched': "Failed"}
|
newValueDict2 = {'Matched': "Failed"}
|
||||||
myDB.upsert("have", newValueDict2, controlValueDict2)
|
myDB.upsert("have", newValueDict2, controlValueDict2)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
controlValueDict2 = { 'Location': song['Location']}
|
controlValueDict2 = {'Location': song['Location']}
|
||||||
newValueDict2 = { 'Matched': "Failed"}
|
newValueDict2 = {'Matched': "Failed"}
|
||||||
myDB.upsert("have", newValueDict2, controlValueDict2)
|
myDB.upsert("have", newValueDict2, controlValueDict2)
|
||||||
|
|
||||||
#######myDB.action('INSERT INTO have (ArtistName, AlbumTitle, TrackNumber, TrackTitle, TrackLength, BitRate, Genre, Date, TrackID, Location, CleanName, Format) VALUES( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', [song['ArtistName'], song['AlbumTitle'], song['TrackNumber'], song['TrackTitle'], song['TrackLength'], song['BitRate'], song['Genre'], song['Date'], song['TrackID'], song['Location'], CleanName, song['Format']])
|
#######myDB.action('INSERT INTO have (ArtistName, AlbumTitle, TrackNumber, TrackTitle, TrackLength, BitRate, Genre, Date, TrackID, Location, CleanName, Format) VALUES( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', [song['ArtistName'], song['AlbumTitle'], song['TrackNumber'], song['TrackTitle'], song['TrackLength'], song['BitRate'], song['Genre'], song['Date'], song['TrackID'], song['Location'], CleanName, song['Format']])
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ from headphones import logger, request
|
|||||||
|
|
||||||
def getLyrics(artist, song):
|
def getLyrics(artist, song):
|
||||||
|
|
||||||
params = { "artist": artist.encode('utf-8'),
|
params = {"artist": artist.encode('utf-8'),
|
||||||
"song": song.encode('utf-8'),
|
"song": song.encode('utf-8'),
|
||||||
"fmt": 'xml'
|
"fmt": 'xml'
|
||||||
}
|
}
|
||||||
|
|||||||
+52
-52
@@ -110,7 +110,7 @@ def findArtist(name, limit=1):
|
|||||||
# Just need the artist id if the limit is 1
|
# Just need the artist id if the limit is 1
|
||||||
# 'name': unicode(result['sort-name']),
|
# 'name': unicode(result['sort-name']),
|
||||||
# 'uniquename': uniquename,
|
# 'uniquename': uniquename,
|
||||||
'id': unicode(result['id']),
|
'id': unicode(result['id']),
|
||||||
# 'url': unicode("http://musicbrainz.org/artist/" + result['id']),#probably needs to be changed
|
# 'url': unicode("http://musicbrainz.org/artist/" + result['id']),#probably needs to be changed
|
||||||
# 'score': int(result['ext:score'])
|
# 'score': int(result['ext:score'])
|
||||||
})
|
})
|
||||||
@@ -118,11 +118,11 @@ def findArtist(name, limit=1):
|
|||||||
artistlist.append(artistdict)
|
artistlist.append(artistdict)
|
||||||
else:
|
else:
|
||||||
artistlist.append({
|
artistlist.append({
|
||||||
'name': unicode(result['sort-name']),
|
'name': unicode(result['sort-name']),
|
||||||
'uniquename': uniquename,
|
'uniquename': uniquename,
|
||||||
'id': unicode(result['id']),
|
'id': unicode(result['id']),
|
||||||
'url': unicode("http://musicbrainz.org/artist/" + result['id']),#probably needs to be changed
|
'url': unicode("http://musicbrainz.org/artist/" + result['id']),#probably needs to be changed
|
||||||
'score': int(result['ext:score'])
|
'score': int(result['ext:score'])
|
||||||
})
|
})
|
||||||
return artistlist
|
return artistlist
|
||||||
|
|
||||||
@@ -189,19 +189,19 @@ def findRelease(name, limit=1, artist=None):
|
|||||||
rg_type = secondary_type
|
rg_type = secondary_type
|
||||||
|
|
||||||
releaselist.append({
|
releaselist.append({
|
||||||
'uniquename': unicode(result['artist-credit'][0]['artist']['name']),
|
'uniquename': unicode(result['artist-credit'][0]['artist']['name']),
|
||||||
'title': unicode(title),
|
'title': unicode(title),
|
||||||
'id': unicode(result['artist-credit'][0]['artist']['id']),
|
'id': unicode(result['artist-credit'][0]['artist']['id']),
|
||||||
'albumid': unicode(result['id']),
|
'albumid': unicode(result['id']),
|
||||||
'url': unicode("http://musicbrainz.org/artist/" + result['artist-credit'][0]['artist']['id']),#probably needs to be changed
|
'url': unicode("http://musicbrainz.org/artist/" + result['artist-credit'][0]['artist']['id']),#probably needs to be changed
|
||||||
'albumurl': unicode("http://musicbrainz.org/release/" + result['id']),#probably needs to be changed
|
'albumurl': unicode("http://musicbrainz.org/release/" + result['id']),#probably needs to be changed
|
||||||
'score': int(result['ext:score']),
|
'score': int(result['ext:score']),
|
||||||
'date': unicode(result['date']) if 'date' in result else '',
|
'date': unicode(result['date']) if 'date' in result else '',
|
||||||
'country': unicode(result['country']) if 'country' in result else '',
|
'country': unicode(result['country']) if 'country' in result else '',
|
||||||
'formats': unicode(formats),
|
'formats': unicode(formats),
|
||||||
'tracks': unicode(tracks),
|
'tracks': unicode(tracks),
|
||||||
'rgid': unicode(result['release-group']['id']),
|
'rgid': unicode(result['release-group']['id']),
|
||||||
'rgtype': unicode(rg_type)
|
'rgtype': unicode(rg_type)
|
||||||
})
|
})
|
||||||
return releaselist
|
return releaselist
|
||||||
|
|
||||||
@@ -259,10 +259,10 @@ def getArtist(artistid, extrasonly=False):
|
|||||||
if "secondary-type-list" in rg.keys(): #only add releases without a secondary type
|
if "secondary-type-list" in rg.keys(): #only add releases without a secondary type
|
||||||
continue
|
continue
|
||||||
releasegroups.append({
|
releasegroups.append({
|
||||||
'title': unicode(rg['title']),
|
'title': unicode(rg['title']),
|
||||||
'id': unicode(rg['id']),
|
'id': unicode(rg['id']),
|
||||||
'url': u"http://musicbrainz.org/release-group/" + rg['id'],
|
'url': u"http://musicbrainz.org/release-group/" + rg['id'],
|
||||||
'type': unicode(rg['type'])
|
'type': unicode(rg['type'])
|
||||||
})
|
})
|
||||||
|
|
||||||
# See if we need to grab extras. Artist specific extras take precedence over global option
|
# See if we need to grab extras. Artist specific extras take precedence over global option
|
||||||
@@ -315,10 +315,10 @@ def getArtist(artistid, extrasonly=False):
|
|||||||
rg_type = secondary_type
|
rg_type = secondary_type
|
||||||
|
|
||||||
releasegroups.append({
|
releasegroups.append({
|
||||||
'title': unicode(rg['title']),
|
'title': unicode(rg['title']),
|
||||||
'id': unicode(rg['id']),
|
'id': unicode(rg['id']),
|
||||||
'url': u"http://musicbrainz.org/release-group/" + rg['id'],
|
'url': u"http://musicbrainz.org/release-group/" + rg['id'],
|
||||||
'type': unicode(rg_type)
|
'type': unicode(rg_type)
|
||||||
})
|
})
|
||||||
|
|
||||||
artist_dict['releasegroups'] = releasegroups
|
artist_dict['releasegroups'] = releasegroups
|
||||||
@@ -517,15 +517,15 @@ def get_new_releases(rgid, includeExtras=False, forcefull=False):
|
|||||||
# tracks into the tracks table
|
# tracks into the tracks table
|
||||||
controlValueDict = {"ReleaseID": release['ReleaseID']}
|
controlValueDict = {"ReleaseID": release['ReleaseID']}
|
||||||
|
|
||||||
newValueDict = {"ArtistID": release['ArtistID'],
|
newValueDict = {"ArtistID": release['ArtistID'],
|
||||||
"ArtistName": release['ArtistName'],
|
"ArtistName": release['ArtistName'],
|
||||||
"AlbumTitle": release['AlbumTitle'],
|
"AlbumTitle": release['AlbumTitle'],
|
||||||
"AlbumID": release['AlbumID'],
|
"AlbumID": release['AlbumID'],
|
||||||
"AlbumASIN": release['AlbumASIN'],
|
"AlbumASIN": release['AlbumASIN'],
|
||||||
"ReleaseDate": release['ReleaseDate'],
|
"ReleaseDate": release['ReleaseDate'],
|
||||||
"Type": release['Type'],
|
"Type": release['Type'],
|
||||||
"ReleaseCountry": release['ReleaseCountry'],
|
"ReleaseCountry": release['ReleaseCountry'],
|
||||||
"ReleaseFormat": release['ReleaseFormat']
|
"ReleaseFormat": release['ReleaseFormat']
|
||||||
}
|
}
|
||||||
|
|
||||||
myDB.upsert("allalbums", newValueDict, controlValueDict)
|
myDB.upsert("allalbums", newValueDict, controlValueDict)
|
||||||
@@ -534,18 +534,18 @@ def get_new_releases(rgid, includeExtras=False, forcefull=False):
|
|||||||
|
|
||||||
cleanname = helpers.cleanName(release['ArtistName'] + ' ' + release['AlbumTitle'] + ' ' + track['title'])
|
cleanname = helpers.cleanName(release['ArtistName'] + ' ' + release['AlbumTitle'] + ' ' + track['title'])
|
||||||
|
|
||||||
controlValueDict = {"TrackID": track['id'],
|
controlValueDict = {"TrackID": track['id'],
|
||||||
"ReleaseID": release['ReleaseID']}
|
"ReleaseID": release['ReleaseID']}
|
||||||
|
|
||||||
newValueDict = {"ArtistID": release['ArtistID'],
|
newValueDict = {"ArtistID": release['ArtistID'],
|
||||||
"ArtistName": release['ArtistName'],
|
"ArtistName": release['ArtistName'],
|
||||||
"AlbumTitle": release['AlbumTitle'],
|
"AlbumTitle": release['AlbumTitle'],
|
||||||
"AlbumID": release['AlbumID'],
|
"AlbumID": release['AlbumID'],
|
||||||
"AlbumASIN": release['AlbumASIN'],
|
"AlbumASIN": release['AlbumASIN'],
|
||||||
"TrackTitle": track['title'],
|
"TrackTitle": track['title'],
|
||||||
"TrackDuration": track['duration'],
|
"TrackDuration": track['duration'],
|
||||||
"TrackNumber": track['number'],
|
"TrackNumber": track['number'],
|
||||||
"CleanName": cleanname
|
"CleanName": cleanname
|
||||||
}
|
}
|
||||||
|
|
||||||
match = myDB.action('SELECT Location, BitRate, Format from have WHERE CleanName=?', [cleanname]).fetchone()
|
match = myDB.action('SELECT Location, BitRate, Format from have WHERE CleanName=?', [cleanname]).fetchone()
|
||||||
@@ -586,11 +586,11 @@ def getTracksFromRelease(release):
|
|||||||
except:
|
except:
|
||||||
track_title = unicode(track['recording']['title'])
|
track_title = unicode(track['recording']['title'])
|
||||||
tracks.append({
|
tracks.append({
|
||||||
'number': totalTracks,
|
'number': totalTracks,
|
||||||
'title': track_title,
|
'title': track_title,
|
||||||
'id': unicode(track['recording']['id']),
|
'id': unicode(track['recording']['id']),
|
||||||
'url': u"http://musicbrainz.org/track/" + track['recording']['id'],
|
'url': u"http://musicbrainz.org/track/" + track['recording']['id'],
|
||||||
'duration': int(track['length']) if 'length' in track else 0
|
'duration': int(track['length']) if 'length' in track else 0
|
||||||
})
|
})
|
||||||
totalTracks += 1
|
totalTracks += 1
|
||||||
return tracks
|
return tracks
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ def encode(albumPath):
|
|||||||
else:
|
else:
|
||||||
encode = True
|
encode = True
|
||||||
elif (headphones.CONFIG.ENCODEROUTPUTFORMAT == 'mp3' or headphones.CONFIG.ENCODEROUTPUTFORMAT == 'm4a'):
|
elif (headphones.CONFIG.ENCODEROUTPUTFORMAT == 'mp3' or headphones.CONFIG.ENCODEROUTPUTFORMAT == 'm4a'):
|
||||||
if (music.decode(headphones.SYS_ENCODING, 'replace').lower().endswith('.'+headphones.CONFIG.ENCODEROUTPUTFORMAT) and (int(infoMusic.bitrate / 1000 ) <= headphones.CONFIG.BITRATE)):
|
if (music.decode(headphones.SYS_ENCODING, 'replace').lower().endswith('.'+headphones.CONFIG.ENCODEROUTPUTFORMAT) and (int(infoMusic.bitrate / 1000) <= headphones.CONFIG.BITRATE)):
|
||||||
logger.info('%s has bitrate <= %skb, will not be re-encoded', music, headphones.CONFIG.BITRATE)
|
logger.info('%s has bitrate <= %skb, will not be re-encoded', music, headphones.CONFIG.BITRATE)
|
||||||
else:
|
else:
|
||||||
encode = True
|
encode = True
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ class PROWL(object):
|
|||||||
'application': 'Headphones',
|
'application': 'Headphones',
|
||||||
'event': event,
|
'event': event,
|
||||||
'description': message.encode("utf-8"),
|
'description': message.encode("utf-8"),
|
||||||
'priority': headphones.CONFIG.PROWL_PRIORITY }
|
'priority': headphones.CONFIG.PROWL_PRIORITY}
|
||||||
|
|
||||||
http_handler.request("POST",
|
http_handler.request("POST",
|
||||||
"/publicapi/add",
|
"/publicapi/add",
|
||||||
@@ -189,8 +189,8 @@ class MPC(object):
|
|||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def notify( self ):
|
def notify(self):
|
||||||
subprocess.call( ["mpc", "update"] )
|
subprocess.call(["mpc", "update"])
|
||||||
|
|
||||||
|
|
||||||
class XBMC(object):
|
class XBMC(object):
|
||||||
@@ -452,12 +452,12 @@ class PUSHBULLET(object):
|
|||||||
data = {'device_iden': headphones.CONFIG.PUSHBULLET_DEVICEID,
|
data = {'device_iden': headphones.CONFIG.PUSHBULLET_DEVICEID,
|
||||||
'type': "note",
|
'type': "note",
|
||||||
'title': "Headphones",
|
'title': "Headphones",
|
||||||
'body': message.encode("utf-8") }
|
'body': message.encode("utf-8")}
|
||||||
|
|
||||||
http_handler.request("POST",
|
http_handler.request("POST",
|
||||||
"/api/pushes",
|
"/api/pushes",
|
||||||
headers={'Content-type': "application/x-www-form-urlencoded",
|
headers={'Content-type': "application/x-www-form-urlencoded",
|
||||||
'Authorization': 'Basic %s' % base64.b64encode(headphones.CONFIG.PUSHBULLET_APIKEY + ":") },
|
'Authorization': 'Basic %s' % base64.b64encode(headphones.CONFIG.PUSHBULLET_APIKEY + ":")},
|
||||||
body=urlencode(data))
|
body=urlencode(data))
|
||||||
response = http_handler.getresponse()
|
response = http_handler.getresponse()
|
||||||
request_status = response.status
|
request_status = response.status
|
||||||
@@ -504,7 +504,7 @@ class PUSHALOT(object):
|
|||||||
|
|
||||||
data = {'AuthorizationToken': pushalot_authorizationtoken,
|
data = {'AuthorizationToken': pushalot_authorizationtoken,
|
||||||
'Title': event.encode('utf-8'),
|
'Title': event.encode('utf-8'),
|
||||||
'Body': message.encode("utf-8") }
|
'Body': message.encode("utf-8")}
|
||||||
|
|
||||||
http_handler.request("POST",
|
http_handler.request("POST",
|
||||||
"/api/sendmessage",
|
"/api/sendmessage",
|
||||||
@@ -590,7 +590,7 @@ class PUSHOVER(object):
|
|||||||
'user': headphones.CONFIG.PUSHOVER_KEYS,
|
'user': headphones.CONFIG.PUSHOVER_KEYS,
|
||||||
'title': event,
|
'title': event,
|
||||||
'message': message.encode("utf-8"),
|
'message': message.encode("utf-8"),
|
||||||
'priority': headphones.CONFIG.PUSHOVER_PRIORITY }
|
'priority': headphones.CONFIG.PUSHOVER_PRIORITY}
|
||||||
|
|
||||||
http_handler.request("POST",
|
http_handler.request("POST",
|
||||||
"/1/messages.json",
|
"/1/messages.json",
|
||||||
|
|||||||
+56
-56
@@ -109,11 +109,11 @@ def verify(albumid, albumpath, Kind=None, forced=False):
|
|||||||
else:
|
else:
|
||||||
sortname = release_dict['artist_name']
|
sortname = release_dict['artist_name']
|
||||||
|
|
||||||
controlValueDict = {"ArtistID": release_dict['artist_id']}
|
controlValueDict = {"ArtistID": release_dict['artist_id']}
|
||||||
newValueDict = {"ArtistName": release_dict['artist_name'],
|
newValueDict = {"ArtistName": release_dict['artist_name'],
|
||||||
"ArtistSortName": sortname,
|
"ArtistSortName": sortname,
|
||||||
"DateAdded": helpers.today(),
|
"DateAdded": helpers.today(),
|
||||||
"Status": "Paused"}
|
"Status": "Paused"}
|
||||||
|
|
||||||
logger.info("ArtistID: " + release_dict['artist_id'] + " , ArtistName: " + release_dict['artist_name'])
|
logger.info("ArtistID: " + release_dict['artist_id'] + " , ArtistName: " + release_dict['artist_name'])
|
||||||
|
|
||||||
@@ -124,17 +124,17 @@ def verify(albumid, albumpath, Kind=None, forced=False):
|
|||||||
myDB.upsert("artists", newValueDict, controlValueDict)
|
myDB.upsert("artists", newValueDict, controlValueDict)
|
||||||
|
|
||||||
logger.info(u"Now adding album: " + release_dict['title'])
|
logger.info(u"Now adding album: " + release_dict['title'])
|
||||||
controlValueDict = {"AlbumID": albumid}
|
controlValueDict = {"AlbumID": albumid}
|
||||||
|
|
||||||
newValueDict = {"ArtistID": release_dict['artist_id'],
|
newValueDict = {"ArtistID": release_dict['artist_id'],
|
||||||
"ReleaseID": albumid,
|
"ReleaseID": albumid,
|
||||||
"ArtistName": release_dict['artist_name'],
|
"ArtistName": release_dict['artist_name'],
|
||||||
"AlbumTitle": release_dict['title'],
|
"AlbumTitle": release_dict['title'],
|
||||||
"AlbumASIN": release_dict['asin'],
|
"AlbumASIN": release_dict['asin'],
|
||||||
"ReleaseDate": release_dict['date'],
|
"ReleaseDate": release_dict['date'],
|
||||||
"DateAdded": helpers.today(),
|
"DateAdded": helpers.today(),
|
||||||
"Type": release_dict['rg_type'],
|
"Type": release_dict['rg_type'],
|
||||||
"Status": "Snatched"
|
"Status": "Snatched"
|
||||||
}
|
}
|
||||||
|
|
||||||
myDB.upsert("albums", newValueDict, controlValueDict)
|
myDB.upsert("albums", newValueDict, controlValueDict)
|
||||||
@@ -143,22 +143,22 @@ def verify(albumid, albumpath, Kind=None, forced=False):
|
|||||||
myDB.action('DELETE from tracks WHERE AlbumID=?', [albumid])
|
myDB.action('DELETE from tracks WHERE AlbumID=?', [albumid])
|
||||||
for track in release_dict['tracks']:
|
for track in release_dict['tracks']:
|
||||||
|
|
||||||
controlValueDict = {"TrackID": track['id'],
|
controlValueDict = {"TrackID": track['id'],
|
||||||
"AlbumID": albumid}
|
"AlbumID": albumid}
|
||||||
|
|
||||||
newValueDict = {"ArtistID": release_dict['artist_id'],
|
newValueDict = {"ArtistID": release_dict['artist_id'],
|
||||||
"ArtistName": release_dict['artist_name'],
|
"ArtistName": release_dict['artist_name'],
|
||||||
"AlbumTitle": release_dict['title'],
|
"AlbumTitle": release_dict['title'],
|
||||||
"AlbumASIN": release_dict['asin'],
|
"AlbumASIN": release_dict['asin'],
|
||||||
"TrackTitle": track['title'],
|
"TrackTitle": track['title'],
|
||||||
"TrackDuration": track['duration'],
|
"TrackDuration": track['duration'],
|
||||||
"TrackNumber": track['number']
|
"TrackNumber": track['number']
|
||||||
}
|
}
|
||||||
|
|
||||||
myDB.upsert("tracks", newValueDict, controlValueDict)
|
myDB.upsert("tracks", newValueDict, controlValueDict)
|
||||||
|
|
||||||
controlValueDict = {"ArtistID": release_dict['artist_id']}
|
controlValueDict = {"ArtistID": release_dict['artist_id']}
|
||||||
newValueDict = {"Status": "Paused"}
|
newValueDict = {"Status": "Paused"}
|
||||||
|
|
||||||
myDB.upsert("artists", newValueDict, controlValueDict)
|
myDB.upsert("artists", newValueDict, controlValueDict)
|
||||||
logger.info(u"Addition complete for: " + release_dict['title'] + " - " + release_dict['artist_name'])
|
logger.info(u"Addition complete for: " + release_dict['title'] + " - " + release_dict['artist_name'])
|
||||||
@@ -532,12 +532,12 @@ def addAlbumArt(artwork, albumpath, release):
|
|||||||
except TypeError:
|
except TypeError:
|
||||||
year = ''
|
year = ''
|
||||||
|
|
||||||
values = { '$Artist': release['ArtistName'],
|
values = {'$Artist': release['ArtistName'],
|
||||||
'$Album': release['AlbumTitle'],
|
'$Album': release['AlbumTitle'],
|
||||||
'$Year': year,
|
'$Year': year,
|
||||||
'$artist': release['ArtistName'].lower(),
|
'$artist': release['ArtistName'].lower(),
|
||||||
'$album': release['AlbumTitle'].lower(),
|
'$album': release['AlbumTitle'].lower(),
|
||||||
'$year': year
|
'$year': year
|
||||||
}
|
}
|
||||||
|
|
||||||
album_art_name = helpers.replace_all(headphones.CONFIG.ALBUM_ART_FORMAT.strip(), values) + ".jpg"
|
album_art_name = helpers.replace_all(headphones.CONFIG.ALBUM_ART_FORMAT.strip(), values) + ".jpg"
|
||||||
@@ -616,19 +616,19 @@ def moveFiles(albumpath, release, tracks):
|
|||||||
except:
|
except:
|
||||||
origfolder = u''
|
origfolder = u''
|
||||||
|
|
||||||
values = { '$Artist': artist,
|
values = {'$Artist': artist,
|
||||||
'$SortArtist': sortname,
|
'$SortArtist': sortname,
|
||||||
'$Album': album,
|
'$Album': album,
|
||||||
'$Year': year,
|
'$Year': year,
|
||||||
'$Type': releasetype,
|
'$Type': releasetype,
|
||||||
'$OriginalFolder': origfolder,
|
'$OriginalFolder': origfolder,
|
||||||
'$First': firstchar.upper(),
|
'$First': firstchar.upper(),
|
||||||
'$artist': artist.lower(),
|
'$artist': artist.lower(),
|
||||||
'$sortartist': sortname.lower(),
|
'$sortartist': sortname.lower(),
|
||||||
'$album': album.lower(),
|
'$album': album.lower(),
|
||||||
'$year': year,
|
'$year': year,
|
||||||
'$type': releasetype.lower(),
|
'$type': releasetype.lower(),
|
||||||
'$first': firstchar.lower(),
|
'$first': firstchar.lower(),
|
||||||
'$originalfolder': origfolder.lower()
|
'$originalfolder': origfolder.lower()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -966,20 +966,20 @@ def renameFiles(albumpath, downloaded_track_list, release):
|
|||||||
else:
|
else:
|
||||||
sortname = artistname
|
sortname = artistname
|
||||||
|
|
||||||
values = { '$Disc': discnumber,
|
values = {'$Disc': discnumber,
|
||||||
'$Track': tracknumber,
|
'$Track': tracknumber,
|
||||||
'$Title': title,
|
'$Title': title,
|
||||||
'$Artist': artistname,
|
'$Artist': artistname,
|
||||||
'$SortArtist': sortname,
|
'$SortArtist': sortname,
|
||||||
'$Album': release['AlbumTitle'],
|
'$Album': release['AlbumTitle'],
|
||||||
'$Year': year,
|
'$Year': year,
|
||||||
'$disc': discnumber,
|
'$disc': discnumber,
|
||||||
'$track': tracknumber,
|
'$track': tracknumber,
|
||||||
'$title': title.lower(),
|
'$title': title.lower(),
|
||||||
'$artist': artistname.lower(),
|
'$artist': artistname.lower(),
|
||||||
'$sortartist': sortname.lower(),
|
'$sortartist': sortname.lower(),
|
||||||
'$album': release['AlbumTitle'].lower(),
|
'$album': release['AlbumTitle'].lower(),
|
||||||
'$year': year
|
'$year': year
|
||||||
}
|
}
|
||||||
|
|
||||||
ext = os.path.splitext(downloaded_track)[1]
|
ext = os.path.splitext(downloaded_track)[1]
|
||||||
|
|||||||
+1
-1
@@ -131,7 +131,7 @@ def sendNZB(nzb):
|
|||||||
|
|
||||||
def checkConfig():
|
def checkConfig():
|
||||||
|
|
||||||
params = { 'mode': 'get_config',
|
params = {'mode': 'get_config',
|
||||||
'section': 'misc'
|
'section': 'misc'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -477,7 +477,7 @@ def searchNZB(album, new=False, losslessOnly=False, albumlength=None):
|
|||||||
# Request results
|
# Request results
|
||||||
logger.info('Parsing results from Headphones Indexer')
|
logger.info('Parsing results from Headphones Indexer')
|
||||||
|
|
||||||
headers = { 'User-Agent': USER_AGENT }
|
headers = {'User-Agent': USER_AGENT}
|
||||||
params = {
|
params = {
|
||||||
"t": "search",
|
"t": "search",
|
||||||
"cat": categories,
|
"cat": categories,
|
||||||
@@ -549,7 +549,7 @@ def searchNZB(album, new=False, losslessOnly=False, albumlength=None):
|
|||||||
# Request results
|
# Request results
|
||||||
logger.info('Parsing results from %s', newznab_host[0])
|
logger.info('Parsing results from %s', newznab_host[0])
|
||||||
|
|
||||||
headers = { 'User-Agent': USER_AGENT }
|
headers = {'User-Agent': USER_AGENT}
|
||||||
params = {
|
params = {
|
||||||
"t": "search",
|
"t": "search",
|
||||||
"apikey": newznab_host[1],
|
"apikey": newznab_host[1],
|
||||||
@@ -598,7 +598,7 @@ def searchNZB(album, new=False, losslessOnly=False, albumlength=None):
|
|||||||
# Request results
|
# Request results
|
||||||
logger.info('Parsing results from nzbs.org')
|
logger.info('Parsing results from nzbs.org')
|
||||||
|
|
||||||
headers = { 'User-Agent': USER_AGENT }
|
headers = {'User-Agent': USER_AGENT}
|
||||||
params = {
|
params = {
|
||||||
"t": "search",
|
"t": "search",
|
||||||
"apikey": headphones.CONFIG.NZBSORG_HASH,
|
"apikey": headphones.CONFIG.NZBSORG_HASH,
|
||||||
@@ -645,7 +645,7 @@ def searchNZB(album, new=False, losslessOnly=False, albumlength=None):
|
|||||||
# Request results
|
# Request results
|
||||||
logger.info('Parsing results from omgwtfnzbs')
|
logger.info('Parsing results from omgwtfnzbs')
|
||||||
|
|
||||||
headers = { 'User-Agent': USER_AGENT }
|
headers = {'User-Agent': USER_AGENT}
|
||||||
params = {
|
params = {
|
||||||
"user": headphones.CONFIG.OMGWTFNZBS_UID,
|
"user": headphones.CONFIG.OMGWTFNZBS_UID,
|
||||||
"api": headphones.CONFIG.OMGWTFNZBS_APIKEY,
|
"api": headphones.CONFIG.OMGWTFNZBS_APIKEY,
|
||||||
@@ -1288,8 +1288,8 @@ def searchTorrent(album, new=False, losslessOnly=False, albumlength=None):
|
|||||||
|
|
||||||
# filter on format, size, and num seeders
|
# filter on format, size, and num seeders
|
||||||
logger.info(u"Filtering torrents by format, maximum size, and minimum seeders...")
|
logger.info(u"Filtering torrents by format, maximum size, and minimum seeders...")
|
||||||
match_torrents = [ torrent for torrent in all_torrents if torrent.size <= maxsize ]
|
match_torrents = [torrent for torrent in all_torrents if torrent.size <= maxsize]
|
||||||
match_torrents = [ torrent for torrent in match_torrents if torrent.seeders >= minimumseeders ]
|
match_torrents = [torrent for torrent in match_torrents if torrent.seeders >= minimumseeders]
|
||||||
|
|
||||||
logger.info(u"Remaining torrents: %s" % ", ".join(repr(torrent) for torrent in match_torrents))
|
logger.info(u"Remaining torrents: %s" % ", ".join(repr(torrent) for torrent in match_torrents))
|
||||||
|
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ class Rutracker():
|
|||||||
if torrent:
|
if torrent:
|
||||||
decoded = bdecode(torrent)
|
decoded = bdecode(torrent)
|
||||||
metainfo = decoded['info']
|
metainfo = decoded['info']
|
||||||
page.close ()
|
page.close()
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
logger.error('Error getting torrent: %s' % e)
|
logger.error('Error getting torrent: %s' % e)
|
||||||
return False
|
return False
|
||||||
@@ -216,9 +216,9 @@ class Rutracker():
|
|||||||
cuecount += 1
|
cuecount += 1
|
||||||
|
|
||||||
title = returntitle.lower()
|
title = returntitle.lower()
|
||||||
logger.debug ('torrent title: %s' % title)
|
logger.debug('torrent title: %s' % title)
|
||||||
logger.debug ('headphones trackcount: %s' % hptrackcount)
|
logger.debug('headphones trackcount: %s' % hptrackcount)
|
||||||
logger.debug ('rutracker trackcount: %s' % trackcount)
|
logger.debug('rutracker trackcount: %s' % trackcount)
|
||||||
|
|
||||||
# If torrent track count less than headphones track count, and there's a cue, then attempt to get track count from log(s)
|
# If torrent track count less than headphones track count, and there's a cue, then attempt to get track count from log(s)
|
||||||
# This is for the case where we have a single .flac/.wav which can be split by cue
|
# This is for the case where we have a single .flac/.wav which can be split by cue
|
||||||
@@ -246,7 +246,7 @@ class Rutracker():
|
|||||||
|
|
||||||
if totallogcount > 0:
|
if totallogcount > 0:
|
||||||
trackcount = totallogcount
|
trackcount = totallogcount
|
||||||
logger.debug ('rutracker logtrackcount: %s' % totallogcount)
|
logger.debug('rutracker logtrackcount: %s' % totallogcount)
|
||||||
|
|
||||||
# If torrent track count = hp track count then return torrent,
|
# If torrent track count = hp track count then return torrent,
|
||||||
# if greater, check for deluxe/special/foreign editions
|
# if greater, check for deluxe/special/foreign editions
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ def addTorrent(link):
|
|||||||
|
|
||||||
def getTorrentFolder(torrentid):
|
def getTorrentFolder(torrentid):
|
||||||
method = 'torrent-get'
|
method = 'torrent-get'
|
||||||
arguments = { 'ids': torrentid, 'fields': ['name', 'percentDone']}
|
arguments = {'ids': torrentid, 'fields': ['name', 'percentDone']}
|
||||||
|
|
||||||
response = torrentAction(method, arguments)
|
response = torrentAction(method, arguments)
|
||||||
percentdone = response['arguments']['torrents'][0]['percentDone']
|
percentdone = response['arguments']['torrents'][0]['percentDone']
|
||||||
@@ -98,7 +98,7 @@ def setSeedRatio(torrentid, ratio):
|
|||||||
def removeTorrent(torrentid, remove_data=False):
|
def removeTorrent(torrentid, remove_data=False):
|
||||||
|
|
||||||
method = 'torrent-get'
|
method = 'torrent-get'
|
||||||
arguments = { 'ids': torrentid, 'fields': ['isFinished', 'name']}
|
arguments = {'ids': torrentid, 'fields': ['isFinished', 'name']}
|
||||||
|
|
||||||
response = torrentAction(method, arguments)
|
response = torrentAction(method, arguments)
|
||||||
if not response:
|
if not response:
|
||||||
@@ -181,8 +181,8 @@ def torrentAction(method, arguments):
|
|||||||
return
|
return
|
||||||
|
|
||||||
# Prepare next request
|
# Prepare next request
|
||||||
headers = { 'x-transmission-session-id': sessionid }
|
headers = {'x-transmission-session-id': sessionid}
|
||||||
data = { 'method': method, 'arguments': arguments }
|
data = {'method': method, 'arguments': arguments}
|
||||||
|
|
||||||
response = request.request_json(host, method="post", data=json.dumps(data), headers=headers, auth=auth)
|
response = request.request_json(host, method="post", data=json.dumps(data), headers=headers, auth=auth)
|
||||||
|
|
||||||
|
|||||||
+14
-15
@@ -167,7 +167,7 @@ class WebInterface(object):
|
|||||||
myDB = db.DBConnection()
|
myDB = db.DBConnection()
|
||||||
controlValueDict = {'ArtistID': ArtistID}
|
controlValueDict = {'ArtistID': ArtistID}
|
||||||
newValueDict = {'IncludeExtras': 1,
|
newValueDict = {'IncludeExtras': 1,
|
||||||
'Extras': extras}
|
'Extras': extras}
|
||||||
myDB.upsert("artists", newValueDict, controlValueDict)
|
myDB.upsert("artists", newValueDict, controlValueDict)
|
||||||
threading.Thread(target=importer.addArtisttoDB, args=[ArtistID, True, False]).start()
|
threading.Thread(target=importer.addArtisttoDB, args=[ArtistID, True, False]).start()
|
||||||
raise cherrypy.HTTPRedirect("artistPage?ArtistID=%s" % ArtistID)
|
raise cherrypy.HTTPRedirect("artistPage?ArtistID=%s" % ArtistID)
|
||||||
@@ -460,12 +460,12 @@ class WebInterface(object):
|
|||||||
# else:
|
# else:
|
||||||
# original_clean = None
|
# original_clean = None
|
||||||
if original_clean == albums['CleanName']:
|
if original_clean == albums['CleanName']:
|
||||||
have_dict = { 'ArtistName': albums['ArtistName'], 'AlbumTitle': albums['AlbumTitle'] }
|
have_dict = {'ArtistName': albums['ArtistName'], 'AlbumTitle': albums['AlbumTitle']}
|
||||||
have_album_dictionary.append(have_dict)
|
have_album_dictionary.append(have_dict)
|
||||||
headphones_albums = myDB.select('SELECT ArtistName, AlbumTitle from albums ORDER BY ArtistName')
|
headphones_albums = myDB.select('SELECT ArtistName, AlbumTitle from albums ORDER BY ArtistName')
|
||||||
for albums in headphones_albums:
|
for albums in headphones_albums:
|
||||||
if albums['ArtistName'] and albums['AlbumTitle']:
|
if albums['ArtistName'] and albums['AlbumTitle']:
|
||||||
headphones_dict = { 'ArtistName': albums['ArtistName'], 'AlbumTitle': albums['AlbumTitle'] }
|
headphones_dict = {'ArtistName': albums['ArtistName'], 'AlbumTitle': albums['AlbumTitle']}
|
||||||
headphones_album_dictionary.append(headphones_dict)
|
headphones_album_dictionary.append(headphones_dict)
|
||||||
#unmatchedalbums = [f for f in have_album_dictionary if f not in [x for x in headphones_album_dictionary]]
|
#unmatchedalbums = [f for f in have_album_dictionary if f not in [x for x in headphones_album_dictionary]]
|
||||||
|
|
||||||
@@ -574,7 +574,7 @@ class WebInterface(object):
|
|||||||
album_status = "Ignored"
|
album_status = "Ignored"
|
||||||
elif albums['Matched'] == "Manual" or albums['CleanName'] != original_clean:
|
elif albums['Matched'] == "Manual" or albums['CleanName'] != original_clean:
|
||||||
album_status = "Matched"
|
album_status = "Matched"
|
||||||
manual_dict = { 'ArtistName': albums['ArtistName'], 'AlbumTitle': albums['AlbumTitle'], 'AlbumStatus': album_status }
|
manual_dict = {'ArtistName': albums['ArtistName'], 'AlbumTitle': albums['AlbumTitle'], 'AlbumStatus': album_status}
|
||||||
if manual_dict not in manual_albums:
|
if manual_dict not in manual_albums:
|
||||||
manual_albums.append(manual_dict)
|
manual_albums.append(manual_dict)
|
||||||
manual_albums_sorted = sorted(manual_albums, key=itemgetter('ArtistName', 'AlbumTitle'))
|
manual_albums_sorted = sorted(manual_albums, key=itemgetter('ArtistName', 'AlbumTitle'))
|
||||||
@@ -865,7 +865,7 @@ class WebInterface(object):
|
|||||||
artist = myDB.action('SELECT * FROM artists WHERE ArtistID=?', [ArtistID]).fetchone()
|
artist = myDB.action('SELECT * FROM artists WHERE ArtistID=?', [ArtistID]).fetchone()
|
||||||
artist_json = json.dumps({
|
artist_json = json.dumps({
|
||||||
'ArtistName': artist['ArtistName'],
|
'ArtistName': artist['ArtistName'],
|
||||||
'Status': artist['Status']
|
'Status': artist['Status']
|
||||||
})
|
})
|
||||||
return artist_json
|
return artist_json
|
||||||
getArtistjson.exposed = True
|
getArtistjson.exposed = True
|
||||||
@@ -876,7 +876,7 @@ class WebInterface(object):
|
|||||||
album_json = json.dumps({
|
album_json = json.dumps({
|
||||||
'AlbumTitle': album['AlbumTitle'],
|
'AlbumTitle': album['AlbumTitle'],
|
||||||
'ArtistName': album['ArtistName'],
|
'ArtistName': album['ArtistName'],
|
||||||
'Status': album['Status']
|
'Status': album['Status']
|
||||||
})
|
})
|
||||||
return album_json
|
return album_json
|
||||||
getAlbumjson.exposed = True
|
getAlbumjson.exposed = True
|
||||||
@@ -900,7 +900,7 @@ class WebInterface(object):
|
|||||||
|
|
||||||
import hashlib, random
|
import hashlib, random
|
||||||
|
|
||||||
apikey = hashlib.sha224( str(random.getrandbits(256)) ).hexdigest()[0:32]
|
apikey = hashlib.sha224(str(random.getrandbits(256))).hexdigest()[0:32]
|
||||||
logger.info("New API generated")
|
logger.info("New API generated")
|
||||||
return apikey
|
return apikey
|
||||||
|
|
||||||
@@ -929,7 +929,7 @@ class WebInterface(object):
|
|||||||
def config(self):
|
def config(self):
|
||||||
|
|
||||||
interface_dir = os.path.join(headphones.PROG_DIR, 'data/interfaces/')
|
interface_dir = os.path.join(headphones.PROG_DIR, 'data/interfaces/')
|
||||||
interface_list = [ name for name in os.listdir(interface_dir) if os.path.isdir(os.path.join(interface_dir, name)) ]
|
interface_list = [name for name in os.listdir(interface_dir) if os.path.isdir(os.path.join(interface_dir, name))]
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
"http_host": headphones.CONFIG.HTTP_HOST,
|
"http_host": headphones.CONFIG.HTTP_HOST,
|
||||||
@@ -1053,12 +1053,12 @@ class WebInterface(object):
|
|||||||
"log_dir": headphones.CONFIG.LOG_DIR,
|
"log_dir": headphones.CONFIG.LOG_DIR,
|
||||||
"cache_dir": headphones.CONFIG.CACHE_DIR,
|
"cache_dir": headphones.CONFIG.CACHE_DIR,
|
||||||
"interface_list": interface_list,
|
"interface_list": interface_list,
|
||||||
"music_encoder": checked(headphones.CONFIG.MUSIC_ENCODER),
|
"music_encoder": checked(headphones.CONFIG.MUSIC_ENCODER),
|
||||||
"encoder": headphones.CONFIG.ENCODER,
|
"encoder": headphones.CONFIG.ENCODER,
|
||||||
"xldprofile": headphones.CONFIG.XLDPROFILE,
|
"xldprofile": headphones.CONFIG.XLDPROFILE,
|
||||||
"bitrate": int(headphones.CONFIG.BITRATE),
|
"bitrate": int(headphones.CONFIG.BITRATE),
|
||||||
"encoder_path": headphones.CONFIG.ENCODER_PATH,
|
"encoder_path": headphones.CONFIG.ENCODER_PATH,
|
||||||
"advancedencoder": headphones.CONFIG.ADVANCEDENCODER,
|
"advancedencoder": headphones.CONFIG.ADVANCEDENCODER,
|
||||||
"encoderoutputformat": headphones.CONFIG.ENCODEROUTPUTFORMAT,
|
"encoderoutputformat": headphones.CONFIG.ENCODEROUTPUTFORMAT,
|
||||||
"samplingfrequency": headphones.CONFIG.SAMPLINGFREQUENCY,
|
"samplingfrequency": headphones.CONFIG.SAMPLINGFREQUENCY,
|
||||||
"encodervbrcbr": headphones.CONFIG.ENCODERVBRCBR,
|
"encodervbrcbr": headphones.CONFIG.ENCODERVBRCBR,
|
||||||
@@ -1205,7 +1205,6 @@ class WebInterface(object):
|
|||||||
del kwargs[key]
|
del kwargs[key]
|
||||||
extra_newznabs.append((newznab_host, newznab_api, newznab_enabled))
|
extra_newznabs.append((newznab_host, newznab_api, newznab_enabled))
|
||||||
|
|
||||||
|
|
||||||
# Convert the extras to list then string. Coming in as 0 or 1 (append new extras to the end)
|
# Convert the extras to list then string. Coming in as 0 or 1 (append new extras to the end)
|
||||||
temp_extras_list = []
|
temp_extras_list = []
|
||||||
|
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ def initialize(options=None):
|
|||||||
options['http_username']: options['http_password']
|
options['http_username']: options['http_password']
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
conf['/api'] = { 'tools.auth_basic.on': False }
|
conf['/api'] = {'tools.auth_basic.on': False}
|
||||||
|
|
||||||
# Prevent time-outs
|
# Prevent time-outs
|
||||||
cherrypy.engine.timeout_monitor.unsubscribe()
|
cherrypy.engine.timeout_monitor.unsubscribe()
|
||||||
|
|||||||
Reference in New Issue
Block a user