From 095cee9368a433b992b53a38ea567be9996ced3e Mon Sep 17 00:00:00 2001 From: rembo10 Date: Sun, 23 Jan 2022 14:08:36 +0530 Subject: [PATCH] http -> https for internet calls --- headphones/lastfm.py | 2 +- headphones/lyrics.py | 2 +- headphones/mb.py | 26 +++++++------------------- headphones/notifiers.py | 4 ++-- headphones/rutracker.py | 10 +++++----- headphones/searcher.py | 12 ++++++------ headphones/webserve.py | 8 ++++---- 7 files changed, 26 insertions(+), 38 deletions(-) diff --git a/headphones/lastfm.py b/headphones/lastfm.py index 5b23e447..a0eb70a4 100644 --- a/headphones/lastfm.py +++ b/headphones/lastfm.py @@ -22,7 +22,7 @@ from headphones import db, logger, request 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 diff --git a/headphones/lyrics.py b/headphones/lyrics.py index 93b59cf3..f582ce43 100644 --- a/headphones/lyrics.py +++ b/headphones/lyrics.py @@ -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: diff --git a/headphones/mb.py b/headphones/mb.py index 45d35122..7030c2bf 100644 --- a/headphones/mb.py +++ b/headphones/mb.py @@ -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) @@ -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']) }) @@ -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 '', @@ -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']) }) @@ -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']) }) @@ -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 @@ -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 @@ -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 diff --git a/headphones/notifiers.py b/headphones/notifiers.py index 79b7f596..95ac9cc9 100644 --- a/headphones/notifiers.py +++ b/headphones/notifiers.py @@ -920,7 +920,7 @@ class BOXCAR(object): def notify(self, title, message, rgid=None): try: if rgid: - message += '

MusicBrainz' % rgid data = urllib.parse.urlencode({ @@ -1019,7 +1019,7 @@ class TELEGRAM(object): # MusicBrainz link if rgid: - message += '\n\n MusicBrainz' % rgid # Send image diff --git a/headphones/rutracker.py b/headphones/rutracker.py index 8c04d33f..a2985981 100644 --- a/headphones/rutracker.py +++ b/headphones/rutracker.py @@ -19,13 +19,13 @@ class Rutracker(object): 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 @@ -35,7 +35,7 @@ class Rutracker(object): 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, @@ -159,7 +159,7 @@ class Rutracker(object): # 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, " @@ -179,7 +179,7 @@ class Rutracker(object): 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} diff --git a/headphones/searcher.py b/headphones/searcher.py index fbb4826d..5a7ff973 100644 --- a/headphones/searcher.py +++ b/headphones/searcher.py @@ -40,7 +40,7 @@ from bencode import decode as bdecode # 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' ] @@ -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": @@ -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 ) @@ -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 ) @@ -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] @@ -1467,7 +1467,7 @@ def searchTorrent(album, new=False, losslessOnly=False, albumlength=None, if headphones.CONFIG.ORPHEUS: provider = "Orpheus.network" - providerurl = "http://orpheus.network/" + providerurl = "https://orpheus.network/" bitrate = None bitrate_string = bitrate diff --git a/headphones/webserve.py b/headphones/webserve.py index 3f678da2..458da435 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -1677,16 +1677,16 @@ class WebInterface(object): # 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