mirror of
https://github.com/rembo10/headphones.git
synced 2026-03-22 20:59:27 +00:00
autopep8 E221,E222,E225,E227,E228,E251 spaces around operators and in parameters
This commit is contained in:
@@ -48,14 +48,14 @@ SNATCHED_PROPER = 9 # qualified with quality
|
||||
class Quality:
|
||||
|
||||
NONE = 0
|
||||
B192 = 1<<1 # 2
|
||||
VBR = 1<<2 # 4
|
||||
B256 = 1<<3 # 8
|
||||
B320 = 1<<4 #16
|
||||
FLAC = 1<<5 #32
|
||||
B192 = 1 << 1 # 2
|
||||
VBR = 1 << 2 # 4
|
||||
B256 = 1 << 3 # 8
|
||||
B320 = 1 << 4 #16
|
||||
FLAC = 1 << 5 #32
|
||||
|
||||
# put these bits at the other end of the spectrum, far enough out that they shouldn't interfere
|
||||
UNKNOWN = 1<<15
|
||||
UNKNOWN = 1 << 15
|
||||
|
||||
qualityStrings = {NONE: "N/A",
|
||||
UNKNOWN: "Unknown",
|
||||
@@ -83,7 +83,7 @@ class Quality:
|
||||
anyQuality = reduce(operator.or_, anyQualities)
|
||||
if bestQualities:
|
||||
bestQuality = reduce(operator.or_, bestQualities)
|
||||
return anyQuality | (bestQuality<<16)
|
||||
return anyQuality | (bestQuality << 16)
|
||||
|
||||
@staticmethod
|
||||
def splitQuality(quality):
|
||||
@@ -92,7 +92,7 @@ class Quality:
|
||||
for curQual in Quality.qualityStrings.keys():
|
||||
if curQual & quality:
|
||||
anyQualities.append(curQual)
|
||||
if curQual<<16 & quality:
|
||||
if curQual << 16 & quality:
|
||||
bestQualities.append(curQual)
|
||||
|
||||
return (anyQualities, bestQualities)
|
||||
|
||||
@@ -492,7 +492,7 @@ class MetaFile(File):
|
||||
|
||||
def folders(self):
|
||||
artist = self.content['artist']
|
||||
album = self.content['date'] + ' - ' + self.content['title'] + ' (' + self.content['label'] + ' - ' + self.content['catalog'] + ')'
|
||||
album = self.content['date'] + ' - ' + self.content['title'] + ' (' + self.content['label'] + ' - ' + self.content['catalog'] + ')'
|
||||
return artist, album
|
||||
|
||||
def complete(self):
|
||||
|
||||
@@ -628,22 +628,22 @@ def sab_sanitize_foldername(name):
|
||||
Remove any leading and trailing dot and space characters
|
||||
"""
|
||||
CH_ILLEGAL = r'\/<>?*|"'
|
||||
CH_LEGAL = r'++{}!@#`'
|
||||
CH_LEGAL = r'++{}!@#`'
|
||||
|
||||
FL_ILLEGAL = CH_ILLEGAL + ':\x92"'
|
||||
FL_LEGAL = CH_LEGAL + "-''"
|
||||
FL_LEGAL = CH_LEGAL + "-''"
|
||||
|
||||
uFL_ILLEGAL = FL_ILLEGAL.decode('latin-1')
|
||||
uFL_LEGAL = FL_LEGAL.decode('latin-1')
|
||||
uFL_LEGAL = FL_LEGAL.decode('latin-1')
|
||||
|
||||
if not name:
|
||||
return name
|
||||
if isinstance(name, unicode):
|
||||
illegal = uFL_ILLEGAL
|
||||
legal = uFL_LEGAL
|
||||
legal = uFL_LEGAL
|
||||
else:
|
||||
illegal = FL_ILLEGAL
|
||||
legal = FL_LEGAL
|
||||
legal = FL_LEGAL
|
||||
|
||||
lst = []
|
||||
for ch in name.strip():
|
||||
|
||||
@@ -407,7 +407,7 @@ def addArtisttoDB(artistid, extrasonly=False, forcefull=False):
|
||||
|
||||
if rg_exists:
|
||||
newValueDict['DateAdded'] = rg_exists['DateAdded']
|
||||
newValueDict['Status'] = rg_exists['Status']
|
||||
newValueDict['Status'] = rg_exists['Status']
|
||||
|
||||
else:
|
||||
today = helpers.today()
|
||||
|
||||
@@ -94,9 +94,9 @@ def libraryScan(dir=None, append=False, ArtistID=None, ArtistName=None, cron=Fal
|
||||
|
||||
subdirectory = r.replace(dir, '')
|
||||
latest_subdirectory.append(subdirectory)
|
||||
if file_count == 0 and r.replace(dir, '') !='':
|
||||
if file_count == 0 and r.replace(dir, '') != '':
|
||||
logger.info("[%s] Now scanning subdirectory %s" % (dir.decode(headphones.SYS_ENCODING, 'replace'), subdirectory.decode(headphones.SYS_ENCODING, 'replace')))
|
||||
elif latest_subdirectory[file_count] != latest_subdirectory[file_count-1] and file_count !=0:
|
||||
elif latest_subdirectory[file_count] != latest_subdirectory[file_count-1] and file_count != 0:
|
||||
logger.info("[%s] Now scanning subdirectory %s" % (dir.decode(headphones.SYS_ENCODING, 'replace'), subdirectory.decode(headphones.SYS_ENCODING, 'replace')))
|
||||
|
||||
song = os.path.join(r, files)
|
||||
@@ -130,7 +130,7 @@ def libraryScan(dir=None, append=False, ArtistID=None, ArtistName=None, cron=Fal
|
||||
# TODO: skip adding songs without the minimum requisite information (just a matter of putting together the right if statements)
|
||||
|
||||
if f_artist and f.album and f.title:
|
||||
CleanName = helpers.cleanName(f_artist +' '+ f.album +' '+ f.title)
|
||||
CleanName = helpers.cleanName(f_artist + ' ' + f.album + ' ' + f.title)
|
||||
else:
|
||||
CleanName = None
|
||||
|
||||
@@ -158,7 +158,7 @@ def libraryScan(dir=None, append=False, ArtistID=None, ArtistName=None, cron=Fal
|
||||
if f_artist:
|
||||
new_artists.append(f_artist)
|
||||
myDB.upsert("have", newValueDict, controlValueDict)
|
||||
new_song_count+=1
|
||||
new_song_count += 1
|
||||
else:
|
||||
if check_exist_song['ArtistName'] != f_artist or check_exist_song['AlbumTitle'] != f.album or check_exist_song['TrackTitle'] != f.title:
|
||||
#Important track metadata has been modified, need to run matcher again
|
||||
@@ -173,13 +173,13 @@ def libraryScan(dir=None, append=False, ArtistID=None, ArtistName=None, cron=Fal
|
||||
myDB.upsert("have", newValueDict, controlValueDict)
|
||||
myDB.action('UPDATE tracks SET Location=?, BitRate=?, Format=? WHERE Location=?', [None, None, None, unicode_song_path])
|
||||
myDB.action('UPDATE alltracks SET Location=?, BitRate=?, Format=? WHERE Location=?', [None, None, None, unicode_song_path])
|
||||
new_song_count+=1
|
||||
new_song_count += 1
|
||||
else:
|
||||
#This track information hasn't changed
|
||||
if f_artist and check_exist_song['Matched'] != "Ignored":
|
||||
new_artists.append(f_artist)
|
||||
|
||||
file_count+=1
|
||||
file_count += 1
|
||||
|
||||
# Now we start track matching
|
||||
logger.info("%s new/modified songs found and added to the database" % new_song_count)
|
||||
@@ -202,13 +202,13 @@ def libraryScan(dir=None, append=False, ArtistID=None, ArtistName=None, cron=Fal
|
||||
latest_artist.append(song['ArtistName'])
|
||||
if song_count == 0:
|
||||
logger.info("Now matching songs by %s" % song['ArtistName'])
|
||||
elif latest_artist[song_count] != latest_artist[song_count-1] and song_count !=0:
|
||||
elif latest_artist[song_count] != latest_artist[song_count-1] and song_count != 0:
|
||||
logger.info("Now matching songs by %s" % song['ArtistName'])
|
||||
|
||||
song_count += 1
|
||||
completion_percentage = float(song_count)/total_number_of_songs * 100
|
||||
|
||||
if completion_percentage%10 == 0:
|
||||
if completion_percentage % 10 == 0:
|
||||
logger.info("Track matching is " + str(completion_percentage) + "% complete")
|
||||
|
||||
#THE "MORE-SPECIFIC" CLAUSES HERE HAVE ALL BEEN REMOVED. WHEN RUNNING A LIBRARY SCAN, THE ONLY CLAUSES THAT
|
||||
@@ -356,9 +356,9 @@ def update_album_status(AlbumID=None):
|
||||
total_tracks = 0
|
||||
have_tracks = 0
|
||||
for track in track_counter:
|
||||
total_tracks+=1
|
||||
total_tracks += 1
|
||||
if track['Location']:
|
||||
have_tracks+=1
|
||||
have_tracks += 1
|
||||
if total_tracks != 0:
|
||||
album_completion = float(float(have_tracks) / float(total_tracks)) * 100
|
||||
else:
|
||||
|
||||
@@ -495,7 +495,7 @@ def get_new_releases(rgid, includeExtras=False, forcefull=False):
|
||||
release['ReleaseCountry'] = unicode(releasedata['country']) if 'country' in releasedata else u'Unknown'
|
||||
#assuming that the list will contain media and that the format will be consistent
|
||||
try:
|
||||
additional_medium=''
|
||||
additional_medium = ''
|
||||
for position in releasedata['medium-list']:
|
||||
if position['format'] == releasedata['medium-list'][0]['format']:
|
||||
medium_count = int(position['position'])
|
||||
|
||||
@@ -41,10 +41,10 @@ def encode(albumPath):
|
||||
logger.error('Details for xld profile \'%s\' not found, files will not be re-encoded', xldProfile)
|
||||
return None
|
||||
|
||||
tempDirEncode=os.path.join(albumPath, "temp")
|
||||
musicFiles=[]
|
||||
musicFinalFiles=[]
|
||||
musicTempFiles=[]
|
||||
tempDirEncode = os.path.join(albumPath, "temp")
|
||||
musicFiles = []
|
||||
musicFinalFiles = []
|
||||
musicTempFiles = []
|
||||
encoder = ""
|
||||
|
||||
# Create temporary directory, but remove the old one first.
|
||||
@@ -86,24 +86,24 @@ def encode(albumPath):
|
||||
else:
|
||||
if XLD:
|
||||
encoder = os.path.join('/Applications', 'xld')
|
||||
elif headphones.CONFIG.ENCODER =='lame':
|
||||
elif headphones.CONFIG.ENCODER == 'lame':
|
||||
if headphones.SYS_PLATFORM == "win32":
|
||||
## NEED THE DEFAULT LAME INSTALL ON WIN!
|
||||
encoder = "C:/Program Files/lame/lame.exe"
|
||||
else:
|
||||
encoder="lame"
|
||||
elif headphones.CONFIG.ENCODER =='ffmpeg':
|
||||
encoder = "lame"
|
||||
elif headphones.CONFIG.ENCODER == 'ffmpeg':
|
||||
if headphones.SYS_PLATFORM == "win32":
|
||||
encoder = "C:/Program Files/ffmpeg/bin/ffmpeg.exe"
|
||||
else:
|
||||
encoder="ffmpeg"
|
||||
encoder = "ffmpeg"
|
||||
elif headphones.CONFIG.ENCODER == 'libav':
|
||||
if headphones.SYS_PLATFORM == "win32":
|
||||
encoder = "C:/Program Files/libav/bin/avconv.exe"
|
||||
else:
|
||||
encoder="avconv"
|
||||
encoder = "avconv"
|
||||
|
||||
i=0
|
||||
i = 0
|
||||
encoder_failed = False
|
||||
jobs = []
|
||||
|
||||
@@ -125,12 +125,12 @@ def encode(albumPath):
|
||||
else:
|
||||
encode = True
|
||||
else:
|
||||
if headphones.CONFIG.ENCODEROUTPUTFORMAT=='ogg':
|
||||
if headphones.CONFIG.ENCODEROUTPUTFORMAT == 'ogg':
|
||||
if music.decode(headphones.SYS_ENCODING, 'replace').lower().endswith('.ogg'):
|
||||
logger.warn('Cannot re-encode .ogg %s', music.decode(headphones.SYS_ENCODING, 'replace'))
|
||||
else:
|
||||
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)):
|
||||
logger.info('%s has bitrate <= %skb, will not be re-encoded', music, headphones.CONFIG.BITRATE)
|
||||
else:
|
||||
@@ -143,7 +143,7 @@ def encode(albumPath):
|
||||
musicFiles[i] = None
|
||||
musicTempFiles[i] = None
|
||||
|
||||
i=i+1
|
||||
i = i+1
|
||||
|
||||
# Encode music files
|
||||
if len(jobs) > 0:
|
||||
@@ -271,9 +271,9 @@ def command(encoder, musicSource, musicDest, albumPath):
|
||||
opts = []
|
||||
if not headphones.CONFIG.ADVANCEDENCODER:
|
||||
opts.extend(['-h'])
|
||||
if headphones.CONFIG.ENCODERVBRCBR=='cbr':
|
||||
if headphones.CONFIG.ENCODERVBRCBR == 'cbr':
|
||||
opts.extend(['--resample', str(headphones.CONFIG.SAMPLINGFREQUENCY), '-b', str(headphones.CONFIG.BITRATE)])
|
||||
elif headphones.CONFIG.ENCODERVBRCBR=='vbr':
|
||||
elif headphones.CONFIG.ENCODERVBRCBR == 'vbr':
|
||||
opts.extend(['-v', str(headphones.CONFIG.ENCODERQUALITY)])
|
||||
else:
|
||||
advanced = (headphones.CONFIG.ADVANCEDENCODER.split())
|
||||
@@ -288,13 +288,13 @@ def command(encoder, musicSource, musicDest, albumPath):
|
||||
cmd = [encoder, '-i', musicSource]
|
||||
opts = []
|
||||
if not headphones.CONFIG.ADVANCEDENCODER:
|
||||
if headphones.CONFIG.ENCODEROUTPUTFORMAT=='ogg':
|
||||
if headphones.CONFIG.ENCODEROUTPUTFORMAT == 'ogg':
|
||||
opts.extend(['-acodec', 'libvorbis'])
|
||||
if headphones.CONFIG.ENCODEROUTPUTFORMAT=='m4a':
|
||||
if headphones.CONFIG.ENCODEROUTPUTFORMAT == 'm4a':
|
||||
opts.extend(['-strict', 'experimental'])
|
||||
if headphones.CONFIG.ENCODERVBRCBR=='cbr':
|
||||
if headphones.CONFIG.ENCODERVBRCBR == 'cbr':
|
||||
opts.extend(['-ar', str(headphones.CONFIG.SAMPLINGFREQUENCY), '-ab', str(headphones.CONFIG.BITRATE) + 'k'])
|
||||
elif headphones.CONFIG.ENCODERVBRCBR=='vbr':
|
||||
elif headphones.CONFIG.ENCODERVBRCBR == 'vbr':
|
||||
opts.extend(['-aq', str(headphones.CONFIG.ENCODERQUALITY)])
|
||||
opts.extend(['-y', '-ac', '2', '-vn'])
|
||||
else:
|
||||
@@ -309,13 +309,13 @@ def command(encoder, musicSource, musicDest, albumPath):
|
||||
cmd = [encoder, '-i', musicSource]
|
||||
opts = []
|
||||
if not headphones.CONFIG.ADVANCEDENCODER:
|
||||
if headphones.CONFIG.ENCODEROUTPUTFORMAT=='ogg':
|
||||
if headphones.CONFIG.ENCODEROUTPUTFORMAT == 'ogg':
|
||||
opts.extend(['-acodec', 'libvorbis'])
|
||||
if headphones.CONFIG.ENCODEROUTPUTFORMAT=='m4a':
|
||||
if headphones.CONFIG.ENCODEROUTPUTFORMAT == 'm4a':
|
||||
opts.extend(['-strict', 'experimental'])
|
||||
if headphones.CONFIG.ENCODERVBRCBR=='cbr':
|
||||
if headphones.CONFIG.ENCODERVBRCBR == 'cbr':
|
||||
opts.extend(['-ar', str(headphones.CONFIG.SAMPLINGFREQUENCY), '-ab', str(headphones.CONFIG.BITRATE) + 'k'])
|
||||
elif headphones.CONFIG.ENCODERVBRCBR=='vbr':
|
||||
elif headphones.CONFIG.ENCODERVBRCBR == 'vbr':
|
||||
opts.extend(['-aq', str(headphones.CONFIG.ENCODERQUALITY)])
|
||||
opts.extend(['-y', '-ac', '2', '-vn'])
|
||||
else:
|
||||
@@ -362,7 +362,7 @@ def command(encoder, musicSource, musicDest, albumPath):
|
||||
|
||||
|
||||
def getTimeEncode(start):
|
||||
seconds =int(time.time()-start)
|
||||
seconds = int(time.time()-start)
|
||||
hours = seconds / 3600
|
||||
seconds -= 3600*hours
|
||||
minutes = seconds / 60
|
||||
|
||||
@@ -153,8 +153,8 @@ class PROWL(object):
|
||||
|
||||
http_handler.request("POST",
|
||||
"/publicapi/add",
|
||||
headers = {'Content-type': "application/x-www-form-urlencoded"},
|
||||
body = urlencode(data))
|
||||
headers={'Content-type': "application/x-www-form-urlencoded"},
|
||||
body=urlencode(data))
|
||||
response = http_handler.getresponse()
|
||||
request_status = response.status
|
||||
|
||||
@@ -456,9 +456,9 @@ class PUSHBULLET(object):
|
||||
|
||||
http_handler.request("POST",
|
||||
"/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 + ":") },
|
||||
body = urlencode(data))
|
||||
body=urlencode(data))
|
||||
response = http_handler.getresponse()
|
||||
request_status = response.status
|
||||
logger.debug(u"PushBullet response status: %r" % request_status)
|
||||
@@ -508,8 +508,8 @@ class PUSHALOT(object):
|
||||
|
||||
http_handler.request("POST",
|
||||
"/api/sendmessage",
|
||||
headers = {'Content-type': "application/x-www-form-urlencoded"},
|
||||
body = urlencode(data))
|
||||
headers={'Content-type': "application/x-www-form-urlencoded"},
|
||||
body=urlencode(data))
|
||||
response = http_handler.getresponse()
|
||||
request_status = response.status
|
||||
|
||||
@@ -594,8 +594,8 @@ class PUSHOVER(object):
|
||||
|
||||
http_handler.request("POST",
|
||||
"/1/messages.json",
|
||||
headers = {'Content-type': "application/x-www-form-urlencoded"},
|
||||
body = urlencode(data))
|
||||
headers={'Content-type': "application/x-www-form-urlencoded"},
|
||||
body=urlencode(data))
|
||||
response = http_handler.getresponse()
|
||||
request_status = response.status
|
||||
logger.debug(u"Pushover response status: %r" % request_status)
|
||||
@@ -627,9 +627,9 @@ class PUSHOVER(object):
|
||||
class TwitterNotifier(object):
|
||||
|
||||
REQUEST_TOKEN_URL = 'https://api.twitter.com/oauth/request_token'
|
||||
ACCESS_TOKEN_URL = 'https://api.twitter.com/oauth/access_token'
|
||||
ACCESS_TOKEN_URL = 'https://api.twitter.com/oauth/access_token'
|
||||
AUTHORIZATION_URL = 'https://api.twitter.com/oauth/authorize'
|
||||
SIGNIN_URL = 'https://api.twitter.com/oauth/authenticate'
|
||||
SIGNIN_URL = 'https://api.twitter.com/oauth/authenticate'
|
||||
|
||||
def __init__(self):
|
||||
self.consumer_key = "oYKnp2ddX5gbARjqX8ZAAg"
|
||||
@@ -649,8 +649,8 @@ class TwitterNotifier(object):
|
||||
def _get_authorization(self):
|
||||
|
||||
signature_method_hmac_sha1 = oauth.SignatureMethod_HMAC_SHA1() #@UnusedVariable
|
||||
oauth_consumer = oauth.Consumer(key=self.consumer_key, secret=self.consumer_secret)
|
||||
oauth_client = oauth.Client(oauth_consumer)
|
||||
oauth_consumer = oauth.Consumer(key=self.consumer_key, secret=self.consumer_secret)
|
||||
oauth_client = oauth.Client(oauth_consumer)
|
||||
|
||||
logger.info('Requesting temp token from Twitter')
|
||||
|
||||
@@ -664,7 +664,7 @@ class TwitterNotifier(object):
|
||||
headphones.CONFIG.TWITTER_USERNAME = request_token['oauth_token']
|
||||
headphones.CONFIG.TWITTER_PASSWORD = request_token['oauth_token_secret']
|
||||
|
||||
return self.AUTHORIZATION_URL+"?oauth_token="+ request_token['oauth_token']
|
||||
return self.AUTHORIZATION_URL+"?oauth_token=" + request_token['oauth_token']
|
||||
|
||||
def _get_credentials(self, key):
|
||||
request_token = {}
|
||||
@@ -679,14 +679,14 @@ class TwitterNotifier(object):
|
||||
logger.info('Generating and signing request for an access token using key '+key)
|
||||
|
||||
signature_method_hmac_sha1 = oauth.SignatureMethod_HMAC_SHA1() #@UnusedVariable
|
||||
oauth_consumer = oauth.Consumer(key=self.consumer_key, secret=self.consumer_secret)
|
||||
oauth_consumer = oauth.Consumer(key=self.consumer_key, secret=self.consumer_secret)
|
||||
logger.info('oauth_consumer: '+str(oauth_consumer))
|
||||
oauth_client = oauth.Client(oauth_consumer, token)
|
||||
oauth_client = oauth.Client(oauth_consumer, token)
|
||||
logger.info('oauth_client: '+str(oauth_client))
|
||||
resp, content = oauth_client.request(self.ACCESS_TOKEN_URL, method='POST', body='oauth_verifier=%s' % key)
|
||||
logger.info('resp, content: '+str(resp)+','+str(content))
|
||||
|
||||
access_token = dict(parse_qsl(content))
|
||||
access_token = dict(parse_qsl(content))
|
||||
logger.info('access_token: '+str(access_token))
|
||||
|
||||
logger.info('resp[status] = '+str(resp['status']))
|
||||
@@ -702,10 +702,10 @@ class TwitterNotifier(object):
|
||||
|
||||
def _send_tweet(self, message=None):
|
||||
|
||||
username=self.consumer_key
|
||||
password=self.consumer_secret
|
||||
access_token_key=headphones.CONFIG.TWITTER_USERNAME
|
||||
access_token_secret=headphones.CONFIG.TWITTER_PASSWORD
|
||||
username = self.consumer_key
|
||||
password = self.consumer_secret
|
||||
access_token_key = headphones.CONFIG.TWITTER_USERNAME
|
||||
access_token_secret = headphones.CONFIG.TWITTER_PASSWORD
|
||||
|
||||
logger.info(u"Sending tweet: "+message)
|
||||
|
||||
|
||||
@@ -182,7 +182,7 @@ def verify(albumid, albumpath, Kind=None, forced=False):
|
||||
|
||||
# Split cue
|
||||
if downloaded_cuecount and downloaded_cuecount >= len(downloaded_track_list):
|
||||
if headphones.CONFIG.KEEP_TORRENT_FILES and Kind=="torrent":
|
||||
if headphones.CONFIG.KEEP_TORRENT_FILES and Kind == "torrent":
|
||||
albumpath = helpers.preserve_torrent_direcory(albumpath)
|
||||
if albumpath and helpers.cue_split(albumpath):
|
||||
downloaded_track_list = helpers.get_downloaded_track_list(albumpath)
|
||||
@@ -283,7 +283,7 @@ def doPostProcessing(albumid, albumpath, release, tracks, downloaded_track_list,
|
||||
|
||||
logger.info('Starting post-processing for: %s - %s' % (release['ArtistName'], release['AlbumTitle']))
|
||||
# Check to see if we're preserving the torrent dir
|
||||
if headphones.CONFIG.KEEP_TORRENT_FILES and Kind=="torrent" and 'headphones-modified' not in albumpath:
|
||||
if headphones.CONFIG.KEEP_TORRENT_FILES and Kind == "torrent" and 'headphones-modified' not in albumpath:
|
||||
new_folder = os.path.join(albumpath, 'headphones-modified'.encode(headphones.SYS_ENCODING, 'replace'))
|
||||
logger.info("Copying files to 'headphones-modified' subfolder to preserve downloaded files for seeding")
|
||||
try:
|
||||
@@ -337,7 +337,7 @@ def doPostProcessing(albumid, albumpath, release, tracks, downloaded_track_list,
|
||||
|
||||
#start encoding
|
||||
if headphones.CONFIG.MUSIC_ENCODER:
|
||||
downloaded_track_list=music_encoder.encode(albumpath)
|
||||
downloaded_track_list = music_encoder.encode(albumpath)
|
||||
|
||||
if not downloaded_track_list:
|
||||
return
|
||||
|
||||
@@ -1049,7 +1049,7 @@ def searchTorrent(album, new=False, losslessOnly=False, albumlength=None):
|
||||
# Replace bad characters in the term and unicode it
|
||||
term = re.sub('[\.\-\/]', ' ', term).encode('utf-8')
|
||||
artistterm = re.sub('[\.\-\/]', ' ', cleanartist).encode('utf-8', 'replace')
|
||||
albumterm = re.sub('[\.\-\/]', ' ', cleanalbum).encode('utf-8', 'replace')
|
||||
albumterm = re.sub('[\.\-\/]', ' ', cleanalbum).encode('utf-8', 'replace')
|
||||
|
||||
# If Preferred Bitrate and High Limit and Allow Lossless then get both lossy and lossless
|
||||
if headphones.CONFIG.PREFERRED_QUALITY == 2 and headphones.CONFIG.PREFERRED_BITRATE and headphones.CONFIG.PREFERRED_BITRATE_HIGH_BUFFER and headphones.CONFIG.PREFERRED_BITRATE_ALLOW_LOSSLESS:
|
||||
|
||||
@@ -72,8 +72,8 @@ def getTorrentFolder(torrentid):
|
||||
|
||||
tries = 1
|
||||
|
||||
while percentdone == 0 and tries <10:
|
||||
tries+=1
|
||||
while percentdone == 0 and tries < 10:
|
||||
tries += 1
|
||||
time.sleep(5)
|
||||
response = torrentAction(method, arguments)
|
||||
percentdone = response['arguments']['torrents'][0]['percentDone']
|
||||
@@ -95,7 +95,7 @@ def setSeedRatio(torrentid, ratio):
|
||||
return False
|
||||
|
||||
|
||||
def removeTorrent(torrentid, remove_data = False):
|
||||
def removeTorrent(torrentid, remove_data=False):
|
||||
|
||||
method = 'torrent-get'
|
||||
arguments = { 'ids': torrentid, 'fields': ['isFinished', 'name']}
|
||||
|
||||
@@ -27,7 +27,7 @@ class utorrentclient(object):
|
||||
TOKEN_REGEX = "<div id='token' style='display:none;'>([^<>]+)</div>"
|
||||
UTSetting = namedtuple("UTSetting", ["name", "int", "str", "access"])
|
||||
|
||||
def __init__(self, base_url = None, username = None, password = None,):
|
||||
def __init__(self, base_url=None, username=None, password=None,):
|
||||
|
||||
host = headphones.CONFIG.UTORRENT_HOST
|
||||
if not host.startswith('http'):
|
||||
@@ -133,7 +133,7 @@ class utorrentclient(object):
|
||||
return settings[key]
|
||||
return settings
|
||||
|
||||
def remove(self, hash, remove_data = False):
|
||||
def remove(self, hash, remove_data=False):
|
||||
if remove_data:
|
||||
params = [('action', 'removedata'), ('hash', hash)]
|
||||
else:
|
||||
@@ -165,7 +165,7 @@ def labelTorrent(hash):
|
||||
uTorrentClient.setprops(hash, 'label', label)
|
||||
|
||||
|
||||
def removeTorrent(hash, remove_data = False):
|
||||
def removeTorrent(hash, remove_data=False):
|
||||
uTorrentClient = utorrentclient()
|
||||
status, torrentList = uTorrentClient.list()
|
||||
torrents = torrentList['torrents']
|
||||
|
||||
@@ -189,7 +189,7 @@ def update():
|
||||
update_dir = os.path.join(headphones.PROG_DIR, 'update')
|
||||
version_path = os.path.join(headphones.PROG_DIR, 'version.txt')
|
||||
|
||||
logger.info('Downloading update from: '+ tar_download_url)
|
||||
logger.info('Downloading update from: ' + tar_download_url)
|
||||
data = request.request_content(tar_download_url)
|
||||
|
||||
if not data:
|
||||
|
||||
@@ -56,7 +56,7 @@ class WebInterface(object):
|
||||
|
||||
def index(self):
|
||||
raise cherrypy.HTTPRedirect("home")
|
||||
index.exposed=True
|
||||
index.exposed = True
|
||||
|
||||
def home(self):
|
||||
myDB = db.DBConnection()
|
||||
@@ -99,7 +99,7 @@ class WebInterface(object):
|
||||
extras_dict[extra] = "checked"
|
||||
else:
|
||||
extras_dict[extra] = ""
|
||||
i+=1
|
||||
i += 1
|
||||
|
||||
return serve_template(templatename="artist.html", title=artist['ArtistName'], artist=artist, albums=albums, extras=extras_dict)
|
||||
artistPage.exposed = True
|
||||
@@ -123,7 +123,7 @@ class WebInterface(object):
|
||||
raise cherrypy.HTTPRedirect("home")
|
||||
|
||||
if not album['ArtistName']:
|
||||
title = ' - '
|
||||
title = ' - '
|
||||
else:
|
||||
title = album['ArtistName'] + ' - '
|
||||
if not album['AlbumTitle']:
|
||||
@@ -215,7 +215,7 @@ class WebInterface(object):
|
||||
myDB = db.DBConnection()
|
||||
namecheck = myDB.select('SELECT ArtistName from artists where ArtistID=?', [ArtistID])
|
||||
for name in namecheck:
|
||||
artistname=name['ArtistName']
|
||||
artistname = name['ArtistName']
|
||||
myDB.action('DELETE from artists WHERE ArtistID=?', [ArtistID])
|
||||
|
||||
from headphones import cache
|
||||
@@ -255,7 +255,7 @@ class WebInterface(object):
|
||||
def refreshArtist(self, ArtistID):
|
||||
threading.Thread(target=importer.addArtisttoDB, args=[ArtistID, False, True]).start()
|
||||
raise cherrypy.HTTPRedirect("artistPage?ArtistID=%s" % ArtistID)
|
||||
refreshArtist.exposed=True
|
||||
refreshArtist.exposed = True
|
||||
|
||||
def markAlbums(self, ArtistID=None, action=None, **args):
|
||||
myDB = db.DBConnection()
|
||||
@@ -511,7 +511,7 @@ class WebInterface(object):
|
||||
if match_tracks:
|
||||
myDB.upsert("tracks", newValueDict, controlValueDict)
|
||||
myDB.action('UPDATE have SET Matched="Manual" WHERE CleanName=?', [new_clean_filename])
|
||||
update_count+=1
|
||||
update_count += 1
|
||||
#This was throwing errors and I don't know why, but it seems to be working fine.
|
||||
#else:
|
||||
#logger.info("There was an error modifying Artist %s. This should not have happened" % existing_artist)
|
||||
@@ -550,7 +550,7 @@ class WebInterface(object):
|
||||
myDB.upsert("tracks", newValueDict, controlValueDict)
|
||||
myDB.action('UPDATE have SET Matched="Manual" WHERE CleanName=?', [new_clean_filename])
|
||||
album_id = match_tracks['AlbumID']
|
||||
update_count+=1
|
||||
update_count += 1
|
||||
#This was throwing errors and I don't know why, but it seems to be working fine.
|
||||
#else:
|
||||
#logger.info("There was an error modifying Artist %s / Album %s with clean name %s" % (existing_artist, existing_album, existing_clean_string))
|
||||
@@ -607,7 +607,7 @@ class WebInterface(object):
|
||||
myDB.action('UPDATE tracks SET Location=?, BitRate=?, Format=? WHERE CleanName=?', [None, None, None, tracks['CleanName']])
|
||||
myDB.action('UPDATE alltracks SET Location=?, BitRate=?, Format=? WHERE CleanName=?', [None, None, None, tracks['CleanName']])
|
||||
myDB.action('UPDATE have SET CleanName=?, Matched="Failed" WHERE ArtistName=? AND AlbumTitle=? AND TrackTitle=?', (original_clean, artist, album, track_title))
|
||||
update_count+=1
|
||||
update_count += 1
|
||||
if update_count > 0:
|
||||
librarysync.update_album_status()
|
||||
logger.info("Artist: %s successfully restored to unmatched list" % artist)
|
||||
@@ -627,7 +627,7 @@ class WebInterface(object):
|
||||
myDB.action('UPDATE tracks SET Location=?, BitRate=?, Format=? WHERE CleanName=?', [None, None, None, tracks['CleanName']])
|
||||
myDB.action('UPDATE alltracks SET Location=?, BitRate=?, Format=? WHERE CleanName=?', [None, None, None, tracks['CleanName']])
|
||||
myDB.action('UPDATE have SET CleanName=?, Matched="Failed" WHERE ArtistName=? AND AlbumTitle=? AND TrackTitle=?', (original_clean, artist, album, track_title))
|
||||
update_count+=1
|
||||
update_count += 1
|
||||
if update_count > 0:
|
||||
librarysync.update_album_status(album_id)
|
||||
logger.info("Album: %s successfully restored to unmatched list" % album)
|
||||
@@ -795,7 +795,7 @@ class WebInterface(object):
|
||||
filtered = myDB.select(query)
|
||||
totalcount = len(filtered)
|
||||
else:
|
||||
query = 'SELECT * from artists WHERE ArtistSortName LIKE "%' + sSearch + '%" OR LatestAlbum LIKE "%' + sSearch +'%"' + 'ORDER BY %s COLLATE NOCASE %s' % (sortcolumn, sSortDir_0)
|
||||
query = 'SELECT * from artists WHERE ArtistSortName LIKE "%' + sSearch + '%" OR LatestAlbum LIKE "%' + sSearch + '%"' + 'ORDER BY %s COLLATE NOCASE %s' % (sortcolumn, sSortDir_0)
|
||||
filtered = myDB.select(query)
|
||||
totalcount = myDB.select('SELECT COUNT(*) from artists')[0][0]
|
||||
|
||||
@@ -844,7 +844,7 @@ class WebInterface(object):
|
||||
s = json.dumps(dict)
|
||||
cherrypy.response.headers['Content-type'] = 'application/json'
|
||||
return s
|
||||
getArtists_json.exposed=True
|
||||
getArtists_json.exposed = True
|
||||
|
||||
def getAlbumsByArtist_json(self, artist=None):
|
||||
myDB = db.DBConnection()
|
||||
@@ -853,12 +853,12 @@ class WebInterface(object):
|
||||
album_list = myDB.select("SELECT AlbumTitle from albums WHERE ArtistName=?", [artist])
|
||||
for album in album_list:
|
||||
album_json[counter] = album['AlbumTitle']
|
||||
counter+=1
|
||||
counter += 1
|
||||
json_albums = json.dumps(album_json)
|
||||
|
||||
cherrypy.response.headers['Content-type'] = 'application/json'
|
||||
return json_albums
|
||||
getAlbumsByArtist_json.exposed=True
|
||||
getAlbumsByArtist_json.exposed = True
|
||||
|
||||
def getArtistjson(self, ArtistID, **kwargs):
|
||||
myDB = db.DBConnection()
|
||||
@@ -868,7 +868,7 @@ class WebInterface(object):
|
||||
'Status': artist['Status']
|
||||
})
|
||||
return artist_json
|
||||
getArtistjson.exposed=True
|
||||
getArtistjson.exposed = True
|
||||
|
||||
def getAlbumjson(self, AlbumID, **kwargs):
|
||||
myDB = db.DBConnection()
|
||||
@@ -879,7 +879,7 @@ class WebInterface(object):
|
||||
'Status': album['Status']
|
||||
})
|
||||
return album_json
|
||||
getAlbumjson.exposed=True
|
||||
getAlbumjson.exposed = True
|
||||
|
||||
def clearhistory(self, type=None, date_added=None, title=None):
|
||||
myDB = db.DBConnection()
|
||||
@@ -1156,7 +1156,7 @@ class WebInterface(object):
|
||||
extras_dict[extra] = "checked"
|
||||
else:
|
||||
extras_dict[extra] = ""
|
||||
i+=1
|
||||
i += 1
|
||||
|
||||
config["extras"] = extras_dict
|
||||
|
||||
@@ -1193,7 +1193,7 @@ class WebInterface(object):
|
||||
for extra in extras_list:
|
||||
if extra:
|
||||
temp_extras_list.append(i)
|
||||
i+=1
|
||||
i += 1
|
||||
|
||||
for extra in expected_extras:
|
||||
temp = '%s_temp' % extra
|
||||
@@ -1373,7 +1373,7 @@ class Artwork(object):
|
||||
elif ArtistOrAlbum == "album":
|
||||
AlbumID = ID
|
||||
|
||||
relpath = cache.getArtwork(ArtistID, AlbumID)
|
||||
relpath = cache.getArtwork(ArtistID, AlbumID)
|
||||
|
||||
if not relpath:
|
||||
relpath = "data/interfaces/default/images/no-cover-art.png"
|
||||
@@ -1407,7 +1407,7 @@ class Artwork(object):
|
||||
elif ArtistOrAlbum == "album":
|
||||
AlbumID = ID
|
||||
|
||||
relpath = cache.getThumb(ArtistID, AlbumID)
|
||||
relpath = cache.getThumb(ArtistID, AlbumID)
|
||||
|
||||
if not relpath:
|
||||
relpath = "data/interfaces/default/images/no-cover-artist.png"
|
||||
|
||||
Reference in New Issue
Block a user