Compare commits

..
Author SHA1 Message Date
rembo10 517d0eb327 Merge branch 'develop' 2022-02-01 20:11:24 +05:30
rembo10 2bacd5a0fc Merge branch 'https' into develop 2022-01-23 14:23:42 +05:30
rembo10 5a559c526d http -> https for album art with small refactor 2022-01-23 14:23:27 +05:30
rembo10 095cee9368 http -> https for internet calls 2022-01-23 14:08:36 +05:30
rembo10 79cb133d1d Remove non-ascii chars in nzb folder name 2022-01-22 08:34:47 +05:30
rembo10 3a9b749017 Merge branch 'develop' 2022-01-22 08:11:01 +05:30
rembo10 0182be2f27 Merge pull request #3284 from hypsometric/py3
Fixes for Python 3.10
2022-01-22 08:01:58 +05:30
hypsometric b6388f7daa Fixes for Python 3.10
- deluge: b64encode returns bytes, transform into string before
  serializing to JSON.
- deluge: no more need to try different encodings for the torrent
  filename or the base64-encoded content, should all be unicode strings
  with Python 3
- collections.abc: Iterable, Mapping, MutableMapping, MutableSequence
  moved from collections to collections.abc since Python 3.3
- pygazelle: html.parser.HTMLParser().unescape() moved to
  html.unescape() in Python 3.4
2022-01-19 18:21:16 +01:00
rembo10 b3199605be v0.5.20 2021-10-15 09:56:59 +05:30
AdeHub 58edc604b3 Merge branch 'develop' 2021-07-08 19:57:08 +12:00
AdeHub 379fd3d0b8 Merge branch 'develop' 2020-10-17 11:06:38 +13:00
AdeHub bf74f57535 Merge branch 'develop' 2020-05-28 10:49:51 +12:00
AdeHub f18334d87c Merge branch 'develop' 2020-03-07 10:30:57 +13:00
AdeHub 5283b48736 Merge branch 'develop' 2019-09-08 17:38:17 +12:00
Ade dc22bb006d Hotfix index creation from develop
Fixes #3175
2019-01-08 21:09:41 +13:00
16 changed files with 65 additions and 81 deletions
+15 -8
View File
@@ -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")
@@ -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")
@@ -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
@@ -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:
+11 -6
View File
@@ -540,12 +540,17 @@ class Cache(object):
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)
+1 -20
View File
@@ -472,32 +472,13 @@ def _add_torrent_file(result):
# content is torrent file contents that needs to be encoded to base64
post_data = json.dumps({"method": "core.add_torrent_file",
"params": [result['name'] + '.torrent',
b64encode(result['content'].encode('utf8')), {}],
b64encode(result['content']).decode(), {}],
"id": 2})
response = requests.post(delugeweb_url, data=post_data.encode('utf-8'), cookies=delugeweb_auth,
verify=deluge_verify_cert, headers=headers)
result['hash'] = json.loads(response.text)['result']
logger.debug('Deluge: Response was %s' % str(json.loads(response.text)))
return json.loads(response.text)['result']
except UnicodeDecodeError:
try:
# content is torrent file contents that needs to be encoded to base64
# this time let's try leaving the encoding as is
logger.debug('Deluge: There was a decoding issue, let\'s try again')
post_data = json.dumps({"method": "core.add_torrent_file",
"params": [result['name'].decode('utf8') + '.torrent',
b64encode(result['content']), {}],
"id": 22})
response = requests.post(delugeweb_url, data=post_data.encode('utf-8'), cookies=delugeweb_auth,
verify=deluge_verify_cert, headers=headers)
result['hash'] = json.loads(response.text)['result']
logger.debug('Deluge: Response was %s' % str(json.loads(response.text)))
return json.loads(response.text)['result']
except Exception as e:
logger.error('Deluge: Adding torrent file failed after decode: %s' % str(e))
formatted_lines = traceback.format_exc().splitlines()
logger.error('; '.join(formatted_lines))
return False
except Exception as e:
logger.error('Deluge: Adding torrent file failed: %s' % str(e))
formatted_lines = traceback.format_exc().splitlines()
+3
View File
@@ -32,6 +32,7 @@ import functools
import re
import os
from mediafile import MediaFile, FileTypeError, UnreadableFileError
from unidecode import unidecode
import headphones
@@ -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:
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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:
+7 -19
View File
@@ -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
+2 -2
View File
@@ -920,7 +920,7 @@ class BOXCAR(object):
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({
@@ -1019,7 +1019,7 @@ class TELEGRAM(object):
# 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
+5 -5
View File
@@ -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}
+6 -6
View File
@@ -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
+4 -4
View File
@@ -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
+1 -1
View File
@@ -1,4 +1,4 @@
from collections import Iterable, Mapping
from collections.abc import Iterable, Mapping
from uuid import uuid4
import six
+1 -1
View File
@@ -1,6 +1,6 @@
from abc import ABCMeta, abstractmethod
from collections import MutableMapping
from collections.abc import MutableMapping
from threading import RLock
from datetime import datetime
from logging import getLogger
+1 -1
View File
@@ -32,7 +32,7 @@ __all__ = ["APEv2", "APEv2File", "Open", "delete"]
import sys
import struct
from collections import MutableSequence
from collections.abc import MutableSequence
from ._compat import (cBytesIO, PY3, text_type, PY2, reraise, swap_to_string,
xrange)
+3 -3
View File
@@ -5,7 +5,7 @@
#
# Loosely based on the API implementation from 'whatbetter', by Zachary Denton
# See https://github.com/zacharydenton/whatbetter
from html.parser import HTMLParser
import html
import sys
import json
@@ -219,10 +219,10 @@ class GazelleAPI(object):
else:
artist = Artist(id, self)
if name:
artist.name = HTMLParser().unescape(name)
artist.name = html.unescape(name)
elif name:
artist = Artist(-1, self)
artist.name = HTMLParser().unescape(name)
artist.name = html.unescape(name)
else:
raise Exception("You must specify either an ID or a Name to get an artist.")
+3 -3
View File
@@ -1,4 +1,4 @@
from html.parser import HTMLParser
import html
class InvalidArtistException(Exception):
pass
@@ -29,7 +29,7 @@ class Artist(object):
if self.id > 0:
response = self.parent_api.request(action='artist', id=self.id)
elif self.name:
self.name = HTMLParser().unescape(self.name)
self.name = html.unescape(self.name)
try:
response = self.parent_api.request(action='artist', artistname=self.name)
except Exception:
@@ -47,7 +47,7 @@ class Artist(object):
self.id = artist_json_response['id']
self.parent_api.cached_artists[self.id] = self
self.name = HTMLParser().unescape(artist_json_response['name'])
self.name = html.unescape(artist_json_response['name'])
self.notifications_enabled = artist_json_response['notificationsEnabled']
self.has_bookmarked = artist_json_response['hasBookmarked']
self.image = artist_json_response['image']