Skip to content

Commit 81f6d9e

Browse files
committed
Added general maximum bitrate setting
1 parent 489c6cb commit 81f6d9e

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

data/interfaces/default/config.html

+5
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,11 @@ <h1 class="clearfix"><i class="fa fa-gear"></i> Settings</h1>
831831
<td>
832832
<legend>Quality</legend>
833833
<fieldset>
834+
<div class="row">
835+
<label>Absolute maximum bitrate</label>
836+
<input type="text" name="maximum_bitrate" value="${config['maximum_bitrate']}" size="20">
837+
<small>0 for unlimited</small>
838+
</div>
834839
<div class="row checkbox left clearfix nopad">
835840
<label title="Snatch the highest quality available, excluding lossless.">
836841
<input type="radio" name="preferred_quality" id="preferred_quality0" value="0" ${config['pref_qual_0']}>

headphones/config.py

+1
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ def __repr__(self):
165165
'LOSSLESS_BITRATE_FROM': (int, 'General', 0),
166166
'LOSSLESS_BITRATE_TO': (int, 'General', 0),
167167
'LOSSLESS_DESTINATION_DIR': (path, 'General', ''),
168+
'MAXIMUM_BITRATE': (int, 'General', 0),
168169
'MB_IGNORE_AGE': (int, 'General', 365),
169170
'MB_IGNORE_AGE_MISSING': (int, 'General', 0),
170171
'MIRROR': (str, 'General', 'musicbrainz.org'),

headphones/searcher.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,12 @@ def sort_search_results(resultlist, album, new, albumlength):
435435
logger.info(
436436
'No more results found for: %s - %s' % (album['ArtistName'], album['AlbumTitle']))
437437
return None
438-
438+
print(headphones.CONFIG.MAXIMUM_BITRATE)
439+
if headphones.CONFIG.MAXIMUM_BITRATE > 0:
440+
resultlist = [
441+
result for result in resultlist
442+
if ((result.size * 8) / albumlength) <= headphones.CONFIG.MAXIMUM_BITRATE
443+
]
439444
# Add a priority if it has any of the preferred words
440445
results_with_priority = []
441446
preferred_words = helpers.split_string(headphones.CONFIG.PREFERRED_WORDS)

headphones/webserve.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1421,7 +1421,8 @@ def config(self):
14211421
"bandcamp_dir": headphones.CONFIG.BANDCAMP_DIR,
14221422
'soulseek_api_url': headphones.CONFIG.SOULSEEK_API_URL,
14231423
'soulseek_api_key': headphones.CONFIG.SOULSEEK_API_KEY,
1424-
'use_soulseek': checked(headphones.CONFIG.SOULSEEK)
1424+
'use_soulseek': checked(headphones.CONFIG.SOULSEEK),
1425+
'maximum_bitrate': headphones.CONFIG.MAXIMUM_BITRATE
14251426
}
14261427

14271428
for k, v in config.items():

0 commit comments

Comments
 (0)