Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
rembo10 committed Feb 1, 2022
2 parents 3a9b749 + 2bacd5a commit 517d0eb
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 52 deletions.
23 changes: 15 additions & 8 deletions headphones/albumart.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def getAlbumArt(albumid):

# CAA
logger.info("Searching for artwork at CAA")
artwork_path = 'http://coverartarchive.org/release-group/%s/front' % albumid
artwork_path = 'https://coverartarchive.org/release-group/%s/front' % albumid
artwork = getartwork(artwork_path)
if artwork:
logger.info("Artwork found at CAA")
Expand All @@ -41,7 +41,7 @@ def getAlbumArt(albumid):
'SELECT ArtistName, AlbumTitle, ReleaseID, AlbumASIN FROM albums WHERE AlbumID=?',
[albumid]).fetchone()
if dbalbum['AlbumASIN']:
artwork_path = 'http://ec1.images-amazon.com/images/P/%s.01.LZZZZZZZ.jpg' % dbalbum['AlbumASIN']
artwork_path = 'https://ec1.images-amazon.com/images/P/%s.01.LZZZZZZZ.jpg' % dbalbum['AlbumASIN']
artwork = getartwork(artwork_path)
if artwork:
logger.info("Artwork found at Amazon")
Expand Down Expand Up @@ -156,12 +156,19 @@ def getartwork(artwork_path):
break
elif maxwidth and img_width > maxwidth:
# Downsize using proxy service to max width
artwork_path = '{0}?{1}'.format('http://images.weserv.nl/', urlencode({
'url': artwork_path.replace('http://', ''),
'w': maxwidth,
}))
artwork = bytes()
r = request.request_response(artwork_path, timeout=20, stream=True, whitelist_status_code=404)
url = "https://images.weserv.nl"
params = {
"url": artwork_path,
"w": maxwidth
}
r = request.request_response(
url,
params=params,
timeout=20,
stream=True,
whitelist_status_code=404
)
if r:
for chunk in r.iter_content(chunk_size=1024):
artwork += chunk
Expand All @@ -182,7 +189,7 @@ def getCachedArt(albumid):
if not artwork_path:
return

if artwork_path.startswith('http://'):
if artwork_path.startswith("http"):
artwork = request.request_content(artwork_path, timeout=20)

if not artwork:
Expand Down
17 changes: 11 additions & 6 deletions headphones/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,12 +540,17 @@ def _update_cache(self):
artwork_thumb = None
if 'fanart' in thumb_url:
# Create thumb using image resizing service
artwork_path = '{0}?{1}'.format('http://images.weserv.nl/', urlencode({
'url': thumb_url.replace('http://', ''),
'w': 300,
}))
artwork_thumb = request.request_content(artwork_path, timeout=20, whitelist_status_code=404)

url = "https://images.weserv.nl"
params = {
"url": thumb_url,
"w": 300
}
artwork_thumb = request.request_content(
url,
params=params,
timeout=20,
whitelist_status_code=404
)
if artwork_thumb:
with open(thumb_path, 'wb') as f:
f.write(artwork_thumb)
Expand Down
3 changes: 3 additions & 0 deletions headphones/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import re
import os
from mediafile import MediaFile, FileTypeError, UnreadableFileError
from unidecode import unidecode
import headphones


Expand Down Expand Up @@ -952,6 +953,8 @@ def sab_sanitize_foldername(name):
if not name:
return

name = unidecode(name)

lst = []
for ch in name.strip():
if ch in FL_ILLEGAL:
Expand Down
2 changes: 1 addition & 1 deletion headphones/lastfm.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

TIMEOUT = 60.0 # seconds
REQUEST_LIMIT = 1.0 / 5 # seconds
ENTRY_POINT = "http://ws.audioscrobbler.com/2.0/"
ENTRY_POINT = "https://ws.audioscrobbler.com/2.0/"
API_KEY = "395e6ec6bb557382fc41fde867bce66f"

# Required for API request limit
Expand Down
2 changes: 1 addition & 1 deletion headphones/lyrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def getLyrics(artist, song):
"fmt": 'xml'
}

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

if not data:
Expand Down
26 changes: 7 additions & 19 deletions headphones/mb.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,7 @@ def findArtist(name, limit=1):
'Cannot determine the best match from an artist/album search. Using top match instead')
artistlist.append({
# Just need the artist id if the limit is 1
# 'name': unicode(result['sort-name']),
# 'uniquename': uniquename,
'id': str(result['id']),
# 'url': unicode("http://musicbrainz.org/artist/" + result['id']),#probably needs to be changed
# 'score': int(result['ext:score'])
})
else:
artistlist.append(artistdict)
Expand All @@ -137,7 +133,7 @@ def findArtist(name, limit=1):
'name': str(result['sort-name']),
'uniquename': uniquename,
'id': str(result['id']),
'url': str("http://musicbrainz.org/artist/" + result['id']),
'url': str("https://musicbrainz.org/artist/" + result['id']),
# probably needs to be changed
'score': int(result['ext:score'])
})
Expand Down Expand Up @@ -208,9 +204,9 @@ def findRelease(name, limit=1, artist=None):
'id': str(result['artist-credit'][0]['artist']['id']),
'albumid': str(result['id']),
'url': str(
"http://musicbrainz.org/artist/" + result['artist-credit'][0]['artist']['id']),
"https://musicbrainz.org/artist/" + result['artist-credit'][0]['artist']['id']),
# probably needs to be changed
'albumurl': str("http://musicbrainz.org/release/" + result['id']),
'albumurl': str("https://musicbrainz.org/release/" + result['id']),
# probably needs to be changed
'score': int(result['ext:score']),
'date': str(result['date']) if 'date' in result else '',
Expand Down Expand Up @@ -248,7 +244,7 @@ def findSeries(name, limit=1):
'name': str(result['name']),
'type': str(result['type']),
'id': str(result['id']),
'url': str("http://musicbrainz.org/series/" + result['id']),
'url': str("https://musicbrainz.org/series/" + result['id']),
# probably needs to be changed
'score': int(result['ext:score'])
})
Expand Down Expand Up @@ -295,7 +291,7 @@ def getArtist(artistid, extrasonly=False):
releasegroups.append({
'title': str(rg['title']),
'id': str(rg['id']),
'url': "http://musicbrainz.org/release-group/" + rg['id'],
'url': "https://musicbrainz.org/release-group/" + rg['id'],
'type': str(rg['type'])
})

Expand Down Expand Up @@ -356,7 +352,7 @@ def getArtist(artistid, extrasonly=False):
releasegroups.append({
'title': str(rg['title']),
'id': str(rg['id']),
'url': "http://musicbrainz.org/release-group/" + rg['id'],
'url': "https://musicbrainz.org/release-group/" + rg['id'],
'type': str(rg_type)
})
artist_dict['releasegroups'] = releasegroups
Expand Down Expand Up @@ -691,7 +687,7 @@ def getTracksFromRelease(release):
'number': totalTracks,
'title': track_title,
'id': str(track['recording']['id']),
'url': "http://musicbrainz.org/track/" + track['recording']['id'],
'url': "https://musicbrainz.org/track/" + track['recording']['id'],
'duration': int(track['length']) if 'length' in track else 0
})
totalTracks += 1
Expand Down Expand Up @@ -733,15 +729,7 @@ def findArtistbyAlbum(name):
for releaseGroup in results:
newArtist = releaseGroup['artist-credit'][0]['artist']
# Only need the artist ID if we're doing an artist+album lookup
# if 'disambiguation' in newArtist:
# uniquename = unicode(newArtist['sort-name'] + " (" + newArtist['disambiguation'] + ")")
# else:
# uniquename = unicode(newArtist['sort-name'])
# artist_dict['name'] = unicode(newArtist['sort-name'])
# artist_dict['uniquename'] = uniquename
artist_dict['id'] = str(newArtist['id'])
# artist_dict['url'] = u'http://musicbrainz.org/artist/' + newArtist['id']
# artist_dict['score'] = int(releaseGroup['ext:score'])

return artist_dict

Expand Down
4 changes: 2 additions & 2 deletions headphones/notifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ def __init__(self):
def notify(self, title, message, rgid=None):
try:
if rgid:
message += '<br></br><a href="http://musicbrainz.org/' \
message += '<br></br><a href="https://musicbrainz.org/' \
'release-group/%s">MusicBrainz</a>' % rgid

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

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

# Send image
Expand Down
10 changes: 5 additions & 5 deletions headphones/rutracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ def __init__(self):
self.timeout = 60
self.loggedin = False
self.maxsize = 0
self.search_referer = 'http://rutracker.org/forum/tracker.php'
self.search_referer = 'https://rutracker.org/forum/tracker.php'

def logged_in(self):
return self.loggedin

def still_logged_in(self, html):
if not html or "action=\"http://rutracker.org/forum/login.php\">" in html:
if not html or "action=\"https://rutracker.org/forum/login.php\">" in html:
return False
else:
return True
Expand All @@ -35,7 +35,7 @@ def login(self):
Logs in user
"""

loginpage = 'http://rutracker.org/forum/login.php'
loginpage = 'https://rutracker.org/forum/login.php'
post_params = {
'login_username': headphones.CONFIG.RUTRACKER_USER,
'login_password': headphones.CONFIG.RUTRACKER_PASSWORD,
Expand Down Expand Up @@ -159,7 +159,7 @@ def search(self, searchurl):
# Torrent topic page
torrent_id = dict([part.split('=') for part in urlparse(url)[4].split('&')])[
't']
topicurl = 'http://rutracker.org/forum/viewtopic.php?t=' + torrent_id
topicurl = 'https://rutracker.org/forum/viewtopic.php?t=' + torrent_id
rulist.append((title, size, topicurl, 'rutracker.org', 'torrent', True))
else:
logger.info("%s is larger than the maxsize or has too little seeders for this category, "
Expand All @@ -179,7 +179,7 @@ def get_torrent_data(self, url):
return the .torrent data
"""
torrent_id = dict([part.split('=') for part in urlparse(url)[4].split('&')])['t']
downloadurl = 'http://rutracker.org/forum/dl.php?t=' + torrent_id
downloadurl = 'https://rutracker.org/forum/dl.php?t=' + torrent_id
cookie = {'bb_dl': torrent_id}
try:
headers = {'Referer': url}
Expand Down
12 changes: 6 additions & 6 deletions headphones/searcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

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

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

data = request.request_feed(
url='http://beta.nzbs.org/api',
url='https://beta.nzbs.org/api',
params=params, headers=headers,
timeout=5
)
Expand Down Expand Up @@ -731,7 +731,7 @@ def searchNZB(album, new=False, losslessOnly=False, albumlength=None,
}

data = request.request_json(
url='http://api.omgwtfnzbs.me/json/',
url='https://api.omgwtfnzbs.me/json/',
params=params, headers=headers
)

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

def set_proxy(proxy_url):
if not proxy_url.startswith('http'):
proxy_url = 'http://' + proxy_url
proxy_url = 'https://' + proxy_url
if proxy_url.endswith('/'):
proxy_url = proxy_url[:-1]

Expand Down Expand Up @@ -1467,7 +1467,7 @@ def set_proxy(proxy_url):

if headphones.CONFIG.ORPHEUS:
provider = "Orpheus.network"
providerurl = "http://orpheus.network/"
providerurl = "https://orpheus.network/"

bitrate = None
bitrate_string = bitrate
Expand Down
8 changes: 4 additions & 4 deletions headphones/webserve.py
Original file line number Diff line number Diff line change
Expand Up @@ -1677,16 +1677,16 @@ def getImageLinks(self, ArtistID=None, AlbumID=None):

# Return the Cover Art Archive urls if not found on last.fm
if AlbumID and not image_dict:
image_url = "http://coverartarchive.org/release/%s/front-500.jpg" % AlbumID
thumb_url = "http://coverartarchive.org/release/%s/front-250.jpg" % AlbumID
image_url = "https://coverartarchive.org/release/%s/front-500.jpg" % AlbumID
thumb_url = "https://coverartarchive.org/release/%s/front-250.jpg" % AlbumID
image_dict = {'artwork': image_url, 'thumbnail': thumb_url}
elif AlbumID and (not image_dict['artwork'] or not image_dict['thumbnail']):
if not image_dict['artwork']:
image_dict[
'artwork'] = "http://coverartarchive.org/release/%s/front-500.jpg" % AlbumID
'artwork'] = "https://coverartarchive.org/release/%s/front-500.jpg" % AlbumID
if not image_dict['thumbnail']:
image_dict[
'thumbnail'] = "http://coverartarchive.org/release/%s/front-250.jpg" % AlbumID
'thumbnail'] = "https://coverartarchive.org/release/%s/front-250.jpg" % AlbumID

return image_dict

Expand Down

0 comments on commit 517d0eb

Please sign in to comment.