Handling remastered track titles (with dashes) in Lyrics

This commit is contained in:
James Barnsley
2019-11-18 14:54:54 +13:00
parent 0206fb7c69
commit 899294baf5
4 changed files with 23 additions and 23 deletions

View File

@ -47629,7 +47629,7 @@ module.exports = hoistNonReactStatics;
/*!***************************************************************!*\
!*** ./node_modules/react-router-dom/esm/react-router-dom.js ***!
\***************************************************************/
/*! exports provided: MemoryRouter, Prompt, Redirect, Route, Router, StaticRouter, Switch, __RouterContext, generatePath, matchPath, useHistory, useLocation, useParams, useRouteMatch, withRouter, BrowserRouter, HashRouter, Link, NavLink */
/*! exports provided: BrowserRouter, HashRouter, Link, NavLink, MemoryRouter, Prompt, Redirect, Route, Router, StaticRouter, Switch, __RouterContext, generatePath, matchPath, useHistory, useLocation, useParams, useRouteMatch, withRouter */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
@ -76489,6 +76489,8 @@ 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,
@ -76508,14 +76510,13 @@ function getTrackLyrics(uri, path) {
$.ajax(config).then(function (response, status, xhr) {
dispatch(uiActions.stopLoading(loader_key));
if (response && response.result) {
var html = $(response.result);
var lyrics = html.find('.lyrics');
if (lyrics.length > 0) {
lyrics = lyrics.first();
lyrics.find('a').replaceWith(function () {
return this.innerHTML;
return _this.innerHTML;
});
var lyrics_html = lyrics.html();
@ -76546,6 +76547,7 @@ function findTrackLyrics(track) {
query = query.toLowerCase();
query = query.replace(/\([^)]*\) */g, ''); // anything in circle-braces
query = query.replace(/\([^[]*\] */g, ''); // anything in square-braces
query = query.replace(/(?= - ).*$/g, ''); // remove anything after and including " - "
sendRequest(dispatch, getState, 'search', 'GET', 'q=' + encodeURIComponent(query)).then(function (response) {
if (response.hits && response.hits.length > 0) {

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 = "1573778425";
var build = "1574041941";
var version = "3.42.2";
// Construct the script tag

View File

@ -156,31 +156,28 @@ export function getTrackLyrics(uri, path) {
.then(
(response, status, xhr) => {
dispatch(uiActions.stopLoading(loader_key));
if (response && response.result) {
const html = $(response.result);
let lyrics = html.find('.lyrics');
if (lyrics.length > 0) {
lyrics = lyrics.first();
lyrics.find('a').replaceWith(() => this.innerHTML);
if (response && response.result) {
const html = $(response.result);
let lyrics = html.find('.lyrics');
if (lyrics.length > 0) {
lyrics = lyrics.first();
lyrics.find('a').replaceWith(function () {
return this.innerHTML;
});
let lyrics_html = lyrics.html();
lyrics_html = lyrics_html.replace(/(\[)/g, '<span class="mid_grey-text">[');
lyrics_html = lyrics_html.replace(/(\])/g, ']</span>');
let lyrics_html = lyrics.html();
lyrics_html = lyrics_html.replace(/(\[)/g, '<span class="mid_grey-text">[');
lyrics_html = lyrics_html.replace(/(\])/g, ']</span>');
dispatch(coreActions.trackLoaded({
dispatch(coreActions.trackLoaded({
uri,
lyrics: lyrics_html,
lyrics_path: path,
}));
}
}
} else {
dispatch(coreActions.handleException(
'Could not get track lyrics',
response.error,
));
dispatch(coreActions.handleException(
'Could not get track lyrics',
response.error,
));
}
},
(xhr, status, error) => {
@ -202,6 +199,7 @@ export function findTrackLyrics(track) {
query = query.toLowerCase();
query = query.replace(/\([^)]*\) */g, ''); // anything in circle-braces
query = query.replace(/\([^[]*\] */g, ''); // anything in square-braces
query = query.replace(/(?= - ).*$/g, ''); // remove anything after and including " - "
sendRequest(dispatch, getState, 'search', 'GET', `q=${encodeURIComponent(query)}`)
.then(