Skip to content

Commit 79d508f

Browse files
committedMar 27, 2018
Merge branch 'develop'
2 parents da9287d + 5d7fdc7 commit 79d508f

File tree

8 files changed

+42
-15
lines changed

8 files changed

+42
-15
lines changed
 

‎Headphones.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ def main():
5454

5555
try:
5656
locale.setlocale(locale.LC_ALL, "")
57-
headphones.SYS_ENCODING = locale.getpreferredencoding()
57+
if headphones.SYS_PLATFORM == 'win32':
58+
headphones.SYS_ENCODING = sys.getdefaultencoding().upper()
59+
else:
60+
headphones.SYS_ENCODING = locale.getpreferredencoding()
5861
except (locale.Error, IOError):
5962
pass
6063

‎data/interfaces/default/config.html

+7-1
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,12 @@ <h1 class="clearfix"><i class="fa fa-gear"></i> Settings</h1>
133133
</label>
134134
<input type="text" name="mb_ignore_age" value="${config['mb_ignore_age']}" size="4">days
135135
</div>
136+
<div class="row checkbox">
137+
<label title="Ignore MusicBrainz album updates missing a release date.">
138+
Ignore Undated Releases
139+
</label>
140+
<input type="checkbox" name="mb_ignore_age_missing" id="mb_ignore_age_missing" value="${config['mb_ignore_age_missing']}">
141+
</div>
136142
</fieldset>
137143
</td>
138144
</tr>
@@ -2601,9 +2607,9 @@ <h1 class="clearfix"><i class="fa fa-gear"></i> Settings</h1>
26012607
initConfigCheckbox("#api_enabled");
26022608
initConfigCheckbox("#enable_https");
26032609
initConfigCheckbox("#customauth");
2610+
initConfigCheckbox("#mb_ignore_age_missing");
26042611
initConfigCheckbox("#use_tquattrecentonze");
26052612

2606-
26072613
$('#twitterStep1').click(function () {
26082614
$.get("/twitterStep1", function (data) {window.open(data); })
26092615
.done(function () { $('#ajaxMsg').html("<div class='msg'><span class='ui-icon ui-icon-check'></span>Confirm Authorization. Check pop-up blocker if no response.</div>"); });

‎headphones/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,8 @@ def dbcheck():
417417
'CREATE INDEX IF NOT EXISTS tracks_Location ON tracks(Location ASC)')
418418
c.execute(
419419
'CREATE INDEX IF NOT EXISTS alltracks_Location ON alltracks(Location ASC)')
420+
c.execute(
421+
'CREATE INDEX IF NOT EXISTS tracks_artistid ON tracks(ArtistID ASC)')
420422

421423
try:
422424
c.execute('SELECT IncludeExtras from artists')

‎headphones/albumswitcher.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ def switch(AlbumID, ReleaseID):
8585

8686
# Update have track counts on index
8787
totaltracks = len(myDB.select(
88-
'SELECT TrackTitle from tracks WHERE ArtistID=? AND AlbumID IN (SELECT AlbumID FROM albums WHERE Status != "Ignored")',
89-
[newalbumdata['ArtistID']]))
88+
'SELECT TrackTitle from tracks AS tr INNER JOIN albums AS al ON al.AlbumID = tr.AlbumID WHERE al.ArtistID=? '
89+
'AND al.Status != "Ignored"', [newalbumdata['ArtistID']]))
9090
havetracks = len(myDB.select(
9191
'SELECT TrackTitle from tracks WHERE ArtistID=? AND Location IS NOT NULL',
9292
[newalbumdata['ArtistID']]))

‎headphones/config.py

+1
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ def __repr__(self):
167167
'LOSSLESS_BITRATE_TO': (int, 'General', 0),
168168
'LOSSLESS_DESTINATION_DIR': (path, 'General', ''),
169169
'MB_IGNORE_AGE': (int, 'General', 365),
170+
'MB_IGNORE_AGE_MISSING': (int, 'General', 0),
170171
'MININOVA': (int, 'Mininova', 0),
171172
'MININOVA_RATIO': (str, 'Mininova', ''),
172173
'MIRROR': (str, 'General', 'musicbrainz.org'),

‎headphones/importer.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,12 @@ def addArtisttoDB(artistid, extrasonly=False, forcefull=False, type="artist"):
262262

263263
else:
264264
if check_release_date is None or check_release_date == u"None":
265-
logger.info("[%s] Now updating: %s (No Release Date)" % (artist['artist_name'], rg['title']))
266-
new_releases = mb.get_new_releases(rgid, includeExtras, True)
265+
if headphones.CONFIG.MB_IGNORE_AGE_MISSING is not 1:
266+
logger.info("[%s] Now updating: %s (No Release Date)" % (artist['artist_name'], rg['title']))
267+
new_releases = mb.get_new_releases(rgid, includeExtras, True)
268+
else:
269+
logger.info("[%s] Skipping update of: %s (No Release Date)" % (artist['artist_name'], rg['title']))
270+
new_releases = 0
267271
else:
268272
if len(check_release_date) == 10:
269273
release_date = check_release_date

‎headphones/searcher.py

+19-9
Original file line numberDiff line numberDiff line change
@@ -1292,10 +1292,13 @@ def set_proxy(proxy_url):
12921292

12931293
if headphones.CONFIG.PREFERRED_QUALITY == 3 or losslessOnly:
12941294
categories = "3040"
1295+
maxsize = 10000000000
12951296
elif headphones.CONFIG.PREFERRED_QUALITY == 1 or allow_lossless:
12961297
categories = "3040,3010,3050"
1298+
maxsize = 10000000000
12971299
else:
12981300
categories = "3010,3050"
1301+
maxsize = 300000000
12991302

13001303
if album['Type'] == 'Other':
13011304
categories = "3030"
@@ -1321,20 +1324,22 @@ def set_proxy(proxy_url):
13211324
"q": term
13221325
}
13231326

1324-
data = request.request_feed(
1327+
data = request.request_soup(
13251328
url=torznab_host[0],
13261329
params=params, headers=headers
13271330
)
13281331

13291332
# Process feed
13301333
if data:
1331-
if not len(data.entries):
1334+
items = data.find_all('item')
1335+
if not items:
13321336
logger.info(u"No results found from %s for %s", provider, term)
13331337
else:
1334-
for item in data.entries:
1338+
for item in items:
13351339
try:
1336-
url = item.link
1337-
title = item.title
1340+
title = item.title.get_text()
1341+
url = item.find("link").next_sibling.strip()
1342+
seeders = int(item.find("torznab:attr", attrs={"name": "seeders"}).get('value'))
13381343

13391344
# Torrentech hack - size currently not returned, make it up
13401345
if 'torrentech' in torznab_host[0]:
@@ -1349,12 +1354,17 @@ def set_proxy(proxy_url):
13491354
logger.info('Skipping %s, could not determine size' % title)
13501355
continue
13511356
else:
1352-
size = int(item.links[1]['length'])
1357+
size = int(item.size.string)
13531358

13541359
if all(word.lower() in title.lower() for word in term.split()):
1355-
logger.info(
1356-
'Found %s. Size: %s' % (title, helpers.bytes_to_mb(size)))
1357-
resultlist.append((title, size, url, provider, 'torrent', True))
1360+
if size < maxsize and minimumseeders < seeders:
1361+
logger.info('Found %s. Size: %s' % (title, helpers.bytes_to_mb(size)))
1362+
resultlist.append((title, size, url, provider, 'torrent', True))
1363+
else:
1364+
logger.info(
1365+
'%s is larger than the maxsize or has too little seeders for this category, '
1366+
'skipping. (Size: %i bytes, Seeders: %d)',
1367+
title, size, seeders)
13581368
else:
13591369
logger.info('Skipping %s, not all search term words found' % title)
13601370

‎headphones/webserve.py

+1
Original file line numberDiff line numberDiff line change
@@ -1160,6 +1160,7 @@ def config(self):
11601160
"download_scan_interval": headphones.CONFIG.DOWNLOAD_SCAN_INTERVAL,
11611161
"update_db_interval": headphones.CONFIG.UPDATE_DB_INTERVAL,
11621162
"mb_ignore_age": headphones.CONFIG.MB_IGNORE_AGE,
1163+
"mb_ignore_age_missing": headphones.CONFIG.MB_IGNORE_AGE_MISSING,
11631164
"search_interval": headphones.CONFIG.SEARCH_INTERVAL,
11641165
"libraryscan_interval": headphones.CONFIG.LIBRARYSCAN_INTERVAL,
11651166
"sab_host": headphones.CONFIG.SAB_HOST,

0 commit comments

Comments
 (0)