Skip to content

Commit 517d0eb

Browse files
committed
Merge branch 'develop'
2 parents 3a9b749 + 2bacd5a commit 517d0eb

10 files changed

+55
-52
lines changed

headphones/albumart.py

+15-8
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def getAlbumArt(albumid):
2828

2929
# CAA
3030
logger.info("Searching for artwork at CAA")
31-
artwork_path = 'http://coverartarchive.org/release-group/%s/front' % albumid
31+
artwork_path = 'https://coverartarchive.org/release-group/%s/front' % albumid
3232
artwork = getartwork(artwork_path)
3333
if artwork:
3434
logger.info("Artwork found at CAA")
@@ -41,7 +41,7 @@ def getAlbumArt(albumid):
4141
'SELECT ArtistName, AlbumTitle, ReleaseID, AlbumASIN FROM albums WHERE AlbumID=?',
4242
[albumid]).fetchone()
4343
if dbalbum['AlbumASIN']:
44-
artwork_path = 'http://ec1.images-amazon.com/images/P/%s.01.LZZZZZZZ.jpg' % dbalbum['AlbumASIN']
44+
artwork_path = 'https://ec1.images-amazon.com/images/P/%s.01.LZZZZZZZ.jpg' % dbalbum['AlbumASIN']
4545
artwork = getartwork(artwork_path)
4646
if artwork:
4747
logger.info("Artwork found at Amazon")
@@ -156,12 +156,19 @@ def getartwork(artwork_path):
156156
break
157157
elif maxwidth and img_width > maxwidth:
158158
# Downsize using proxy service to max width
159-
artwork_path = '{0}?{1}'.format('http://images.weserv.nl/', urlencode({
160-
'url': artwork_path.replace('http://', ''),
161-
'w': maxwidth,
162-
}))
163159
artwork = bytes()
164-
r = request.request_response(artwork_path, timeout=20, stream=True, whitelist_status_code=404)
160+
url = "https://images.weserv.nl"
161+
params = {
162+
"url": artwork_path,
163+
"w": maxwidth
164+
}
165+
r = request.request_response(
166+
url,
167+
params=params,
168+
timeout=20,
169+
stream=True,
170+
whitelist_status_code=404
171+
)
165172
if r:
166173
for chunk in r.iter_content(chunk_size=1024):
167174
artwork += chunk
@@ -182,7 +189,7 @@ def getCachedArt(albumid):
182189
if not artwork_path:
183190
return
184191

185-
if artwork_path.startswith('http://'):
192+
if artwork_path.startswith("http"):
186193
artwork = request.request_content(artwork_path, timeout=20)
187194

188195
if not artwork:

headphones/cache.py

+11-6
Original file line numberDiff line numberDiff line change
@@ -540,12 +540,17 @@ def _update_cache(self):
540540
artwork_thumb = None
541541
if 'fanart' in thumb_url:
542542
# Create thumb using image resizing service
543-
artwork_path = '{0}?{1}'.format('http://images.weserv.nl/', urlencode({
544-
'url': thumb_url.replace('http://', ''),
545-
'w': 300,
546-
}))
547-
artwork_thumb = request.request_content(artwork_path, timeout=20, whitelist_status_code=404)
548-
543+
url = "https://images.weserv.nl"
544+
params = {
545+
"url": thumb_url,
546+
"w": 300
547+
}
548+
artwork_thumb = request.request_content(
549+
url,
550+
params=params,
551+
timeout=20,
552+
whitelist_status_code=404
553+
)
549554
if artwork_thumb:
550555
with open(thumb_path, 'wb') as f:
551556
f.write(artwork_thumb)

headphones/helpers.py

+3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import re
3333
import os
3434
from mediafile import MediaFile, FileTypeError, UnreadableFileError
35+
from unidecode import unidecode
3536
import headphones
3637

3738

@@ -952,6 +953,8 @@ def sab_sanitize_foldername(name):
952953
if not name:
953954
return
954955

956+
name = unidecode(name)
957+
955958
lst = []
956959
for ch in name.strip():
957960
if ch in FL_ILLEGAL:

headphones/lastfm.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
TIMEOUT = 60.0 # seconds
2424
REQUEST_LIMIT = 1.0 / 5 # seconds
25-
ENTRY_POINT = "http://ws.audioscrobbler.com/2.0/"
25+
ENTRY_POINT = "https://ws.audioscrobbler.com/2.0/"
2626
API_KEY = "395e6ec6bb557382fc41fde867bce66f"
2727

2828
# Required for API request limit

headphones/lyrics.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def getLyrics(artist, song):
2525
"fmt": 'xml'
2626
}
2727

28-
url = 'http://lyrics.wikia.com/api.php'
28+
url = 'https://lyrics.wikia.com/api.php'
2929
data = request.request_minidom(url, params=params)
3030

3131
if not data:

headphones/mb.py

+7-19
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,7 @@ def findArtist(name, limit=1):
124124
'Cannot determine the best match from an artist/album search. Using top match instead')
125125
artistlist.append({
126126
# Just need the artist id if the limit is 1
127-
# 'name': unicode(result['sort-name']),
128-
# 'uniquename': uniquename,
129127
'id': str(result['id']),
130-
# 'url': unicode("http://musicbrainz.org/artist/" + result['id']),#probably needs to be changed
131-
# 'score': int(result['ext:score'])
132128
})
133129
else:
134130
artistlist.append(artistdict)
@@ -137,7 +133,7 @@ def findArtist(name, limit=1):
137133
'name': str(result['sort-name']),
138134
'uniquename': uniquename,
139135
'id': str(result['id']),
140-
'url': str("http://musicbrainz.org/artist/" + result['id']),
136+
'url': str("https://musicbrainz.org/artist/" + result['id']),
141137
# probably needs to be changed
142138
'score': int(result['ext:score'])
143139
})
@@ -208,9 +204,9 @@ def findRelease(name, limit=1, artist=None):
208204
'id': str(result['artist-credit'][0]['artist']['id']),
209205
'albumid': str(result['id']),
210206
'url': str(
211-
"http://musicbrainz.org/artist/" + result['artist-credit'][0]['artist']['id']),
207+
"https://musicbrainz.org/artist/" + result['artist-credit'][0]['artist']['id']),
212208
# probably needs to be changed
213-
'albumurl': str("http://musicbrainz.org/release/" + result['id']),
209+
'albumurl': str("https://musicbrainz.org/release/" + result['id']),
214210
# probably needs to be changed
215211
'score': int(result['ext:score']),
216212
'date': str(result['date']) if 'date' in result else '',
@@ -248,7 +244,7 @@ def findSeries(name, limit=1):
248244
'name': str(result['name']),
249245
'type': str(result['type']),
250246
'id': str(result['id']),
251-
'url': str("http://musicbrainz.org/series/" + result['id']),
247+
'url': str("https://musicbrainz.org/series/" + result['id']),
252248
# probably needs to be changed
253249
'score': int(result['ext:score'])
254250
})
@@ -295,7 +291,7 @@ def getArtist(artistid, extrasonly=False):
295291
releasegroups.append({
296292
'title': str(rg['title']),
297293
'id': str(rg['id']),
298-
'url': "http://musicbrainz.org/release-group/" + rg['id'],
294+
'url': "https://musicbrainz.org/release-group/" + rg['id'],
299295
'type': str(rg['type'])
300296
})
301297

@@ -356,7 +352,7 @@ def getArtist(artistid, extrasonly=False):
356352
releasegroups.append({
357353
'title': str(rg['title']),
358354
'id': str(rg['id']),
359-
'url': "http://musicbrainz.org/release-group/" + rg['id'],
355+
'url': "https://musicbrainz.org/release-group/" + rg['id'],
360356
'type': str(rg_type)
361357
})
362358
artist_dict['releasegroups'] = releasegroups
@@ -691,7 +687,7 @@ def getTracksFromRelease(release):
691687
'number': totalTracks,
692688
'title': track_title,
693689
'id': str(track['recording']['id']),
694-
'url': "http://musicbrainz.org/track/" + track['recording']['id'],
690+
'url': "https://musicbrainz.org/track/" + track['recording']['id'],
695691
'duration': int(track['length']) if 'length' in track else 0
696692
})
697693
totalTracks += 1
@@ -733,15 +729,7 @@ def findArtistbyAlbum(name):
733729
for releaseGroup in results:
734730
newArtist = releaseGroup['artist-credit'][0]['artist']
735731
# Only need the artist ID if we're doing an artist+album lookup
736-
# if 'disambiguation' in newArtist:
737-
# uniquename = unicode(newArtist['sort-name'] + " (" + newArtist['disambiguation'] + ")")
738-
# else:
739-
# uniquename = unicode(newArtist['sort-name'])
740-
# artist_dict['name'] = unicode(newArtist['sort-name'])
741-
# artist_dict['uniquename'] = uniquename
742732
artist_dict['id'] = str(newArtist['id'])
743-
# artist_dict['url'] = u'http://musicbrainz.org/artist/' + newArtist['id']
744-
# artist_dict['score'] = int(releaseGroup['ext:score'])
745733

746734
return artist_dict
747735

headphones/notifiers.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,7 @@ def __init__(self):
920920
def notify(self, title, message, rgid=None):
921921
try:
922922
if rgid:
923-
message += '<br></br><a href="http://musicbrainz.org/' \
923+
message += '<br></br><a href="https://musicbrainz.org/' \
924924
'release-group/%s">MusicBrainz</a>' % rgid
925925

926926
data = urllib.parse.urlencode({
@@ -1019,7 +1019,7 @@ def notify(self, message, status, rgid=None, image=None):
10191019

10201020
# MusicBrainz link
10211021
if rgid:
1022-
message += '\n\n <a href="http://musicbrainz.org/' \
1022+
message += '\n\n <a href="https://musicbrainz.org/' \
10231023
'release-group/%s">MusicBrainz</a>' % rgid
10241024

10251025
# Send image

headphones/rutracker.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ def __init__(self):
1919
self.timeout = 60
2020
self.loggedin = False
2121
self.maxsize = 0
22-
self.search_referer = 'http://rutracker.org/forum/tracker.php'
22+
self.search_referer = 'https://rutracker.org/forum/tracker.php'
2323

2424
def logged_in(self):
2525
return self.loggedin
2626

2727
def still_logged_in(self, html):
28-
if not html or "action=\"http://rutracker.org/forum/login.php\">" in html:
28+
if not html or "action=\"https://rutracker.org/forum/login.php\">" in html:
2929
return False
3030
else:
3131
return True
@@ -35,7 +35,7 @@ def login(self):
3535
Logs in user
3636
"""
3737

38-
loginpage = 'http://rutracker.org/forum/login.php'
38+
loginpage = 'https://rutracker.org/forum/login.php'
3939
post_params = {
4040
'login_username': headphones.CONFIG.RUTRACKER_USER,
4141
'login_password': headphones.CONFIG.RUTRACKER_PASSWORD,
@@ -159,7 +159,7 @@ def search(self, searchurl):
159159
# Torrent topic page
160160
torrent_id = dict([part.split('=') for part in urlparse(url)[4].split('&')])[
161161
't']
162-
topicurl = 'http://rutracker.org/forum/viewtopic.php?t=' + torrent_id
162+
topicurl = 'https://rutracker.org/forum/viewtopic.php?t=' + torrent_id
163163
rulist.append((title, size, topicurl, 'rutracker.org', 'torrent', True))
164164
else:
165165
logger.info("%s is larger than the maxsize or has too little seeders for this category, "
@@ -179,7 +179,7 @@ def get_torrent_data(self, url):
179179
return the .torrent data
180180
"""
181181
torrent_id = dict([part.split('=') for part in urlparse(url)[4].split('&')])['t']
182-
downloadurl = 'http://rutracker.org/forum/dl.php?t=' + torrent_id
182+
downloadurl = 'https://rutracker.org/forum/dl.php?t=' + torrent_id
183183
cookie = {'bb_dl': torrent_id}
184184
try:
185185
headers = {'Referer': url}

headphones/searcher.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
# Magnet to torrent services, for Black hole. Stolen from CouchPotato.
4242
TORRENT_TO_MAGNET_SERVICES = [
43-
'http://itorrents.org/torrent/%s.torrent',
43+
'https://itorrents.org/torrent/%s.torrent',
4444
'https://cache.torrentgalaxy.org/get/%s',
4545
'https://www.seedpeer.me/torrent/%s'
4646
]
@@ -611,7 +611,7 @@ def searchNZB(album, new=False, losslessOnly=False, albumlength=None,
611611
provider = newznab_host[0]
612612

613613
# Add a little mod for kere.ws
614-
if newznab_host[0] == "http://kere.ws":
614+
if newznab_host[0] == "https://kere.ws":
615615
if categories == "3040":
616616
categories = categories + ",4070"
617617
elif categories == "3040,3010":
@@ -682,7 +682,7 @@ def searchNZB(album, new=False, losslessOnly=False, albumlength=None,
682682
}
683683

684684
data = request.request_feed(
685-
url='http://beta.nzbs.org/api',
685+
url='https://beta.nzbs.org/api',
686686
params=params, headers=headers,
687687
timeout=5
688688
)
@@ -731,7 +731,7 @@ def searchNZB(album, new=False, losslessOnly=False, albumlength=None,
731731
}
732732

733733
data = request.request_json(
734-
url='http://api.omgwtfnzbs.me/json/',
734+
url='https://api.omgwtfnzbs.me/json/',
735735
params=params, headers=headers
736736
)
737737

@@ -1261,7 +1261,7 @@ def searchTorrent(album, new=False, losslessOnly=False, albumlength=None,
12611261

12621262
def set_proxy(proxy_url):
12631263
if not proxy_url.startswith('http'):
1264-
proxy_url = 'http://' + proxy_url
1264+
proxy_url = 'https://' + proxy_url
12651265
if proxy_url.endswith('/'):
12661266
proxy_url = proxy_url[:-1]
12671267

@@ -1467,7 +1467,7 @@ def set_proxy(proxy_url):
14671467

14681468
if headphones.CONFIG.ORPHEUS:
14691469
provider = "Orpheus.network"
1470-
providerurl = "http://orpheus.network/"
1470+
providerurl = "https://orpheus.network/"
14711471

14721472
bitrate = None
14731473
bitrate_string = bitrate

headphones/webserve.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1677,16 +1677,16 @@ def getImageLinks(self, ArtistID=None, AlbumID=None):
16771677

16781678
# Return the Cover Art Archive urls if not found on last.fm
16791679
if AlbumID and not image_dict:
1680-
image_url = "http://coverartarchive.org/release/%s/front-500.jpg" % AlbumID
1681-
thumb_url = "http://coverartarchive.org/release/%s/front-250.jpg" % AlbumID
1680+
image_url = "https://coverartarchive.org/release/%s/front-500.jpg" % AlbumID
1681+
thumb_url = "https://coverartarchive.org/release/%s/front-250.jpg" % AlbumID
16821682
image_dict = {'artwork': image_url, 'thumbnail': thumb_url}
16831683
elif AlbumID and (not image_dict['artwork'] or not image_dict['thumbnail']):
16841684
if not image_dict['artwork']:
16851685
image_dict[
1686-
'artwork'] = "http://coverartarchive.org/release/%s/front-500.jpg" % AlbumID
1686+
'artwork'] = "https://coverartarchive.org/release/%s/front-500.jpg" % AlbumID
16871687
if not image_dict['thumbnail']:
16881688
image_dict[
1689-
'thumbnail'] = "http://coverartarchive.org/release/%s/front-250.jpg" % AlbumID
1689+
'thumbnail'] = "https://coverartarchive.org/release/%s/front-250.jpg" % AlbumID
16901690

16911691
return image_dict
16921692

0 commit comments

Comments
 (0)