Genius scraping working again

This commit is contained in:
James Barnsley
2020-01-22 16:19:57 +13:00
parent f33e37a1d1
commit f581d683bc
6 changed files with 13 additions and 15 deletions

View File

@ -718,7 +718,7 @@ class IrisCore(pykka.ThreadingActor):
url = url+'&seed_tracks='+(",".join(self.radio['seed_tracks'])).replace('spotify:track:','')
url = url+'&limit=50'
http_client = AsyncHTTPClient()
try:
http_response = await http_client.fetch(
url,
@ -1002,7 +1002,7 @@ class IrisCore(pykka.ThreadingActor):
'client_id': self.config['spotify']['client_id'],
'client_secret': self.config['spotify']['client_secret'],
'grant_type': 'client_credentials'
}
}
try:
http_client = tornado.httpclient.AsyncHTTPClient()
@ -1090,11 +1090,11 @@ class IrisCore(pykka.ThreadingActor):
if error:
return error
try:
http_client = AsyncHTTPClient()
http_response = await http_client.fetch(url)
callback(http_response, False)
callback(http_response.body.decode("utf-8"), False)
except (urllib.error.HTTPError, urllib.error.URLError) as e:
error = json.loads(e.read())

View File

@ -214,11 +214,11 @@ class HttpHandler(tornado.web.RequestHandler):
# Digest JSON responses into JSON
content_type = response.headers.get('Content-Type')
if content_type.startswith('application/json') or content_type.startswith('text/json'):
body = json.loads(response.body.decode("utf-8") )
body = json.loads(response.body)
# Non-JSON so just copy as-is
else:
body = json_encode(response.body.decode("utf-8") )
body = json_encode(response.body)
request_response['result'] = body

View File

@ -76541,8 +76541,6 @@ function getMe() {
* @param path = String, the relative API path for the HTML lyrics
* */
function getTrackLyrics(uri, path) {
var _this = this;
return function (dispatch, getState) {
dispatch(coreActions.trackLoaded({
uri: uri,
@ -76563,12 +76561,12 @@ function getTrackLyrics(uri, path) {
$.ajax(config).then(function (response, status, xhr) {
dispatch(uiActions.stopLoading(loader_key));
if (response && response.result) {
var html = $('<div/>').html(response.result).contents();
var html = $(response.result);
var lyrics = html.find('.lyrics');
if (lyrics.length > 0) {
lyrics = lyrics.first();
lyrics.find('a').replaceWith(function () {
return _this.innerHTML;
lyrics.find('a').replaceWith(function (item) {
return item.innerHTML;
});
var lyrics_html = lyrics.html();

File diff suppressed because one or more lines are too long

View File

@ -100,7 +100,7 @@
// Release details
// These are automatically injected to built HTML
var build = "1579657760";
var build = "1579662333";
var version = "3.44.0";
// Construct the script tag