Adding catcher for refresh_spotify_token when not enabled; fixes #565; Starting translation key migration for exceptions
This commit is contained in:
@ -1020,6 +1020,7 @@ class IrisCore(pykka.ThreadingActor):
|
||||
async def refresh_spotify_token(self, *args, **kwargs):
|
||||
callback = kwargs.get("callback", None)
|
||||
|
||||
try:
|
||||
# Use client_id and client_secret from config
|
||||
# This was introduced in Mopidy-Spotify 3.1.0
|
||||
url = "https://auth.mopidy.com/spotify/token"
|
||||
@ -1028,6 +1029,15 @@ class IrisCore(pykka.ThreadingActor):
|
||||
"client_secret": self.config["spotify"]["client_secret"],
|
||||
"grant_type": "client_credentials",
|
||||
}
|
||||
except (Exception) as e:
|
||||
error = {
|
||||
"message": "Could not refresh Spotify token: invalid configuration"
|
||||
}
|
||||
|
||||
if callback:
|
||||
callback(False, error)
|
||||
else:
|
||||
return error
|
||||
|
||||
try:
|
||||
http_client = tornado.httpclient.AsyncHTTPClient()
|
||||
@ -1056,7 +1066,7 @@ class IrisCore(pykka.ThreadingActor):
|
||||
except (urllib.error.HTTPError, urllib.error.URLError) as e:
|
||||
error = json.loads(e.read())
|
||||
error = {
|
||||
"message": "Could not refresh token: "
|
||||
"message": "Could not refresh Spotify token: "
|
||||
+ error["error_description"]
|
||||
}
|
||||
|
||||
@ -1127,11 +1137,11 @@ class IrisCore(pykka.ThreadingActor):
|
||||
except (urllib.error.HTTPError, urllib.error.URLError) as e:
|
||||
error = json.loads(e.read())
|
||||
error = {
|
||||
"message": "Could not fetch Spotify recommendations: "
|
||||
"message": "Could not fetch Genius lyrics: "
|
||||
+ error["error_description"]
|
||||
}
|
||||
logger.error(
|
||||
"Could not fetch Spotify recommendations: "
|
||||
"Could not fetch Genius lyrics: "
|
||||
+ error["error_description"]
|
||||
)
|
||||
logger.debug(error)
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
16
mopidy_iris/static/app.min.js
vendored
16
mopidy_iris/static/app.min.js
vendored
File diff suppressed because one or more lines are too long
@ -106,7 +106,7 @@
|
||||
|
||||
// Release details
|
||||
// These are automatically injected to built HTML
|
||||
var build = "1598145259";
|
||||
var build = "1598260330";
|
||||
var version = "3.52.2";
|
||||
|
||||
// Construct the script tag
|
||||
|
||||
@ -5,7 +5,8 @@ name: English
|
||||
##
|
||||
errors:
|
||||
uri_not_found: 'Could not find anything with URI %{uri}'
|
||||
could_not_load: Could not load
|
||||
could_not_load: 'Could not load %{name}'
|
||||
could_not_load_library: 'Could not load %{name} from %{provider}'
|
||||
no_results: No results found
|
||||
authorization_required: 'You must authorize %{provider} first'
|
||||
enable_first: 'Enable %{provider} first'
|
||||
|
||||
@ -17,6 +17,7 @@ import {
|
||||
formatAlbum,
|
||||
} from '../../util/format';
|
||||
import URILink from '../../components/URILink';
|
||||
import { i18n } from '../../locale';
|
||||
|
||||
const coreActions = require('../../services/core/actions');
|
||||
const uiActions = require('../../services/ui/actions');
|
||||
@ -1604,10 +1605,13 @@ export function getLibraryTracksAndPlayProcessor(data) {
|
||||
dispatch(uiActions.processFinished('SPOTIFY_GET_LIBRARY_TRACKS_AND_PLAY_PROCESSOR'));
|
||||
}
|
||||
},
|
||||
(error) => {
|
||||
dispatch(coreActions.handleException(
|
||||
'Could not load library tracks',
|
||||
error,
|
||||
() => {
|
||||
dispatch(uiActions.processFinished(
|
||||
'SPOTIFY_GET_LIBRARY_TRACKS_AND_PLAY_PROCESSOR',
|
||||
{
|
||||
content: 'Could not load library tracks',
|
||||
level: 'error',
|
||||
},
|
||||
));
|
||||
},
|
||||
);
|
||||
@ -1818,11 +1822,11 @@ export function getLibraryPlaylists() {
|
||||
|
||||
if (!last_run) {
|
||||
dispatch(uiActions.startProcess('SPOTIFY_GET_LIBRARY_PLAYLISTS_PROCESSOR', 'Loading Spotify playlists', { next: 'me/playlists?limit=50' }));
|
||||
} else if (last_run.status == 'cancelled') {
|
||||
} else if (last_run.status === 'cancelled') {
|
||||
dispatch(uiActions.resumeProcess('SPOTIFY_GET_LIBRARY_PLAYLISTS_PROCESSOR'));
|
||||
|
||||
// We've already finished, but the status has been flushed
|
||||
} else if (last_run.status == 'finished' && !getState().spotify.library_playlists_loaded_all) {
|
||||
} else if (last_run.status === 'finished' && !getState().spotify.library_playlists_loaded_all) {
|
||||
dispatch(uiActions.startProcess('SPOTIFY_GET_LIBRARY_PLAYLISTS_PROCESSOR', 'Loading Spotify playlists', { next: 'me/playlists?limit=50' }));
|
||||
}
|
||||
};
|
||||
@ -1868,10 +1872,19 @@ export function getLibraryPlaylistsProcessor(data) {
|
||||
dispatch({ type: 'SPOTIFY_LIBRARY_PLAYLISTS_LOADED_ALL' });
|
||||
}
|
||||
},
|
||||
(error) => {
|
||||
dispatch(coreActions.handleException(
|
||||
'Could not load library playlists',
|
||||
error,
|
||||
() => {
|
||||
dispatch(uiActions.processFinished(
|
||||
'SPOTIFY_GET_LIBRARY_PLAYLISTS_PROCESSOR',
|
||||
{
|
||||
content: i18n(
|
||||
'errors.could_not_load_library',
|
||||
{
|
||||
name: i18n('library.playlists.title'),
|
||||
provider: i18n('services.spotify.title'),
|
||||
},
|
||||
),
|
||||
level: 'error',
|
||||
},
|
||||
));
|
||||
},
|
||||
);
|
||||
@ -1889,11 +1902,11 @@ export function getLibraryArtists() {
|
||||
|
||||
if (!last_run) {
|
||||
dispatch(uiActions.startProcess('SPOTIFY_GET_LIBRARY_ARTISTS_PROCESSOR', 'Loading Spotify artists', { next: 'me/following?type=artist&limit=50' }));
|
||||
} else if (last_run.status == 'cancelled') {
|
||||
} else if (last_run.status === 'cancelled') {
|
||||
dispatch(uiActions.resumeProcess('SPOTIFY_GET_LIBRARY_ARTISTS_PROCESSOR'));
|
||||
|
||||
// We've already finished, but the status has been flushed
|
||||
} else if (last_run.status == 'finished' && !getState().spotify.library_artists_loaded_all) {
|
||||
} else if (last_run.status === 'finished' && !getState().spotify.library_artists_loaded_all) {
|
||||
dispatch(uiActions.startProcess('SPOTIFY_GET_LIBRARY_ARTISTS_PROCESSOR', 'Loading Spotify artists', { next: 'me/following?type=artist&limit=50' }));
|
||||
}
|
||||
};
|
||||
@ -1927,10 +1940,19 @@ export function getLibraryArtistsProcessor(data) {
|
||||
dispatch(uiActions.processFinished('SPOTIFY_GET_LIBRARY_ARTISTS_PROCESSOR'));
|
||||
}
|
||||
},
|
||||
(error) => {
|
||||
dispatch(coreActions.handleException(
|
||||
'Could not load library artists',
|
||||
error,
|
||||
() => {
|
||||
dispatch(uiActions.processFinished(
|
||||
'SPOTIFY_GET_LIBRARY_ARTISTS_PROCESSOR',
|
||||
{
|
||||
content: i18n(
|
||||
'errors.could_not_load_library',
|
||||
{
|
||||
name: i18n('library.artists.title'),
|
||||
provider: i18n('services.spotify.title'),
|
||||
},
|
||||
),
|
||||
level: 'error',
|
||||
},
|
||||
));
|
||||
},
|
||||
);
|
||||
@ -1948,11 +1970,11 @@ export function getLibraryAlbums() {
|
||||
|
||||
if (!last_run) {
|
||||
dispatch(uiActions.startProcess('SPOTIFY_GET_LIBRARY_ALBUMS_PROCESSOR', 'Loading Spotify albums', { next: 'me/albums?limit=50' }));
|
||||
} else if (last_run.status == 'cancelled') {
|
||||
} else if (last_run.status === 'cancelled') {
|
||||
dispatch(uiActions.updateProcess('SPOTIFY_GET_LIBRARY_ALBUMS_PROCESSOR', 'Loading Spotify albums', { next: 'me/albums?limit=50' }));
|
||||
|
||||
// We've already finished, but the status has been flushed
|
||||
} else if (last_run.status == 'finished' && !getState().spotify.library_albums_loaded_all) {
|
||||
} else if (last_run.status === 'finished' && !getState().spotify.library_albums_loaded_all) {
|
||||
dispatch(uiActions.startProcess('SPOTIFY_GET_LIBRARY_ALBUMS_PROCESSOR', 'Loading Spotify albums', { next: 'me/albums?limit=50' }));
|
||||
}
|
||||
};
|
||||
@ -1997,10 +2019,19 @@ export function getLibraryAlbumsProcessor(data) {
|
||||
dispatch(uiActions.processFinished('SPOTIFY_GET_LIBRARY_ALBUMS_PROCESSOR'));
|
||||
}
|
||||
},
|
||||
(error) => {
|
||||
dispatch(coreActions.handleException(
|
||||
'Could not load library albums',
|
||||
error,
|
||||
() => {
|
||||
dispatch(uiActions.processFinished(
|
||||
'SPOTIFY_GET_LIBRARY_ALBUMS_PROCESSOR',
|
||||
{
|
||||
content: i18n(
|
||||
'errors.could_not_load_library',
|
||||
{
|
||||
name: i18n('library.albums.title'),
|
||||
provider: i18n('services.spotify.title'),
|
||||
},
|
||||
),
|
||||
level: 'error',
|
||||
},
|
||||
));
|
||||
},
|
||||
);
|
||||
|
||||
@ -61,12 +61,14 @@ class LibraryPlaylists extends React.Component {
|
||||
getSpotifyLibrary = () => {
|
||||
const {
|
||||
source,
|
||||
spotify_available,
|
||||
spotify_library_playlists_status,
|
||||
spotifyActions: {
|
||||
getLibraryPlaylists,
|
||||
},
|
||||
} = this.props;
|
||||
|
||||
if (!spotify_available) return;
|
||||
if (source !== 'spotify' && source !== 'all') return;
|
||||
if (spotify_library_playlists_status === 'finished') return;
|
||||
if (spotify_library_playlists_status === 'started') return;
|
||||
|
||||
Reference in New Issue
Block a user