Skip to content

Commit f6594d1

Browse files
authored
yfquotes@thegli: Auto-refresh expired authentication parameters (#1319)
- Detect and replace expired authorization parameters - Correct documentation for automatic refresh after import - Update DOW 30 component symbols
1 parent e3e7d91 commit f6594d1

File tree

18 files changed

+215
-125
lines changed

18 files changed

+215
-125
lines changed

yfquotes@thegli/CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
### 0.15.2 - November 20, 2024
2+
3+
Features:
4+
5+
- update Hungarian translation (courtesy of [bossbob88](https://github.com/bossbob88))
6+
- update Finnish translation (courtesy of [MahtiAnkka](https://github.com/MahtiAnkka))
7+
8+
Bugfixes:
9+
10+
- correct documentation for automatic refresh after import
11+
- detect and replace expired authorization parameters
12+
- update DOW 30 component symbols
13+
114
### 0.15.1 - September 12, 2024
215

316
Features:

yfquotes@thegli/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Either follow the installation instructions on [Cinnamon spices](https://cinnamo
2323

2424
Check out the desklet configuration settings, and choose the data refresh period, the list of quotes to show, and quote details to display. The default list contains the Dow 30 companies.
2525

26-
> Note that **any changes in the quotes list are not applied immediately** (anymore). This is true for manual changes as well as for import settings from a file.
26+
> Note that **manual changes in the quotes list are not immediately applied** (anymore).
2727
Press the "Refresh quotes data" button to execute an immediate data update, or wait until the next automatic refresh is triggered (depending on the configured interval).
2828

2929
### Individual Quote Design

yfquotes@thegli/files/yfquotes@thegli/desklet.js

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,18 @@ YahooFinanceQuoteUtils.prototype = {
183183
return false;
184184
},
185185

186+
isUnauthorizedStatus: function(soupMessage) {
187+
if (soupMessage) {
188+
if (IS_SOUP_2) {
189+
return soupMessage.status_code === Soup.KnownStatusCode.UNAUTHORIZED;
190+
} else {
191+
// get_status() throws exception on any value missing in enum SoupStatus, so better check reason_phrase
192+
return soupMessage.get_reason_phrase() === "Unauthorized";
193+
}
194+
}
195+
return false;
196+
},
197+
186198
getMessageStatusInfo: function(soupMessage) {
187199
if (soupMessage) {
188200
if (IS_SOUP_2) {
@@ -432,6 +444,10 @@ YahooFinanceQuoteReader.prototype = {
432444
} catch (e) {
433445
logError(e);
434446
}
447+
} else if (_that.quoteUtils.isUnauthorizedStatus(message)) {
448+
logDebug("Current authorization parameters have expired. Discarding them.");
449+
_crumb = null;
450+
callback.call(_that, _that.buildErrorResponse(_("Authorization parameters have expired")), true);
435451
} else {
436452
logWarning("Error retrieving url " + requestUrl + ". Status: " + _that.quoteUtils.getMessageStatusInfo(message));
437453
callback.call(_that, _that.buildErrorResponse(_("Yahoo Finance service not available!\\nStatus: ") + _that.quoteUtils.getMessageStatusInfo(message)));
@@ -451,6 +467,10 @@ YahooFinanceQuoteReader.prototype = {
451467
} catch (e) {
452468
logError(e);
453469
}
470+
} else if (_that.quoteUtils.isUnauthorizedStatus(message)) {
471+
logDebug("Current authorization parameters have expired. Discarding them.");
472+
_crumb = null;
473+
callback.call(_that, _that.buildErrorResponse(_("Authorization parameters have expired")), true);
454474
} else {
455475
logWarning("Error retrieving url " + requestUrl + ". Status: " + _that.quoteUtils.getMessageStatusInfo(message));
456476
callback.call(_that, _that.buildErrorResponse(_("Yahoo Finance service not available!\\nStatus: ") + _that.quoteUtils.getMessageStatusInfo(message)));
@@ -922,7 +942,7 @@ StockQuoteDesklet.prototype = {
922942
logDebug("fetchFinanceDataAndRender. quotes=" + quoteSymbolsArg + ", custom User-Agent: " + customUserAgent);
923943
const _that = this;
924944

925-
this.quoteReader.getFinanceData(quoteSymbolsArg, customUserAgent, function(response) {
945+
this.quoteReader.getFinanceData(quoteSymbolsArg, customUserAgent, function(response, instantTimer = false) {
926946
logDebug("YF query response: " + response);
927947
let parsedResponse = JSON.parse(response);
928948
_lastResponses.set(_that.id, {
@@ -931,7 +951,7 @@ StockQuoteDesklet.prototype = {
931951
responseError: parsedResponse.quoteResponse.error,
932952
lastUpdated: new Date()
933953
});
934-
_that.setUpdateTimer();
954+
_that.setUpdateTimer(instantTimer);
935955
_that.render();
936956
});
937957
},
@@ -1032,10 +1052,15 @@ StockQuoteDesklet.prototype = {
10321052
this.render();
10331053
},
10341054

1035-
setUpdateTimer: function() {
1055+
setUpdateTimer: function(instantTimer = false) {
10361056
logDebug("setUpdateTimer");
10371057
if (this.updateInProgress) {
1038-
this.updateId = Mainloop.timeout_add(this.delayMinutes * 60000, Lang.bind(this, this.onQuotesListChanged));
1058+
let delaySeconds = this.delayMinutes * 60;
1059+
if (instantTimer) {
1060+
logDebug("add instant timer");
1061+
delaySeconds = 1;
1062+
}
1063+
this.updateId = Mainloop.timeout_add_seconds(delaySeconds, Lang.bind(this, this.onQuotesListChanged));
10391064
logDebug("new updateId " + this.updateId);
10401065
this.updateInProgress = false;
10411066
}

yfquotes@thegli/files/yfquotes@thegli/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
"name": "Yahoo Finance Quotes",
44
"prevent-decorations": true,
55
"max-instances": "10",
6-
"version": "0.15.1",
6+
"version": "0.15.2",
77
"uuid": "yfquotes@thegli"
88
}

yfquotes@thegli/files/yfquotes@thegli/po/ca.po

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgstr ""
88
"Project-Id-Version: yfquotes@thegli 0.13.0\n"
99
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-desklets/"
1010
"issues\n"
11-
"POT-Creation-Date: 2024-09-12 23:49+0200\n"
11+
"POT-Creation-Date: 2024-11-20 20:33+0100\n"
1212
"PO-Revision-Date: 2024-09-10 20:15+0200\n"
1313
"Last-Translator: Odyssey <[email protected]>\n"
1414
"Language-Team: \n"
@@ -22,46 +22,50 @@ msgstr ""
2222
msgid "No quotes data to display"
2323
msgstr "No hi ha dades de cotitzacions per mostrar"
2424

25-
#. desklet.js:415
25+
#. desklet.js:427
2626
msgid "Empty quotes list. Open settings and add some symbols."
2727
msgstr ""
2828
"Llista de cotitzacions buida. Obriu la configuració i afegiu-hi alguns "
2929
"símbols."
3030

31-
#. desklet.js:437 desklet.js:456
31+
#. desklet.js:450 desklet.js:473
32+
msgid "Authorization parameters have expired"
33+
msgstr ""
34+
35+
#. desklet.js:453 desklet.js:476
3236
msgid "Yahoo Finance service not available!\\nStatus: "
3337
msgstr "El servei de Yahoo finances no està disponible!\\nEstat: "
3438

35-
#. desklet.js:815
39+
#. desklet.js:835
3640
msgid "Updated at "
3741
msgstr "Actualitzat a les "
3842

39-
#. desklet.js:848
43+
#. desklet.js:868
4044
msgid "Error: "
4145
msgstr "Error: "
4246

43-
#. desklet.js:963
47+
#. desklet.js:983
4448
msgid ""
4549
"Failed to retrieve authorization parameter! Unable to fetch quotes data."
4650
"\\nStatus: "
4751
msgstr ""
4852
"Error en recuperar el paràmetre d'autorització. No s'han pogut obtenir les "
4953
"dades de les cotitzacions.\\nEstat: "
5054

51-
#. desklet.js:989
55+
#. desklet.js:1009
5256
msgid "Consent processing failed! Unable to fetch quotes data.\\nStatus: "
5357
msgstr ""
5458
"No s'ha pogut processar el consentiment! No s'han pogut obtenir les dades de "
5559
"les cotitzacions.\\nEstat: "
5660

57-
#. desklet.js:994
61+
#. desklet.js:1014
5862
msgid ""
5963
"Consent processing not completed! Unable to fetch quotes data.\\nStatus: "
6064
msgstr ""
6165
"No s'ha completat el processament del consentiment. No s'han pogut obtenir "
6266
"les dades de les cotitzacions.\\nEstat: "
6367

64-
#. desklet.js:1017
68+
#. desklet.js:1037
6569
msgid ""
6670
"Failed to retrieve authorization crumb! Unable to fetch quotes data."
6771
"\\nStatus: "

yfquotes@thegli/files/yfquotes@thegli/po/da.po

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ msgstr ""
77
"Project-Id-Version: \n"
88
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-desklets/"
99
"issues\n"
10-
"POT-Creation-Date: 2024-09-12 23:49+0200\n"
10+
"POT-Creation-Date: 2024-11-20 20:33+0100\n"
1111
"PO-Revision-Date: 2023-12-08 08:06+0100\n"
1212
"Last-Translator: Alan Mortensen <[email protected]>\n"
1313
"Language-Team: \n"
@@ -22,41 +22,45 @@ msgstr ""
2222
msgid "No quotes data to display"
2323
msgstr ""
2424

25-
#. desklet.js:415
25+
#. desklet.js:427
2626
msgid "Empty quotes list. Open settings and add some symbols."
2727
msgstr ""
2828

29-
#. desklet.js:437 desklet.js:456
29+
#. desklet.js:450 desklet.js:473
30+
msgid "Authorization parameters have expired"
31+
msgstr ""
32+
33+
#. desklet.js:453 desklet.js:476
3034
msgid "Yahoo Finance service not available!\\nStatus: "
3135
msgstr "Yahoo Finance er ikke tilgængelig!\\nStatus: "
3236

33-
#. desklet.js:815
37+
#. desklet.js:835
3438
msgid "Updated at "
3539
msgstr "Opdateret "
3640

37-
#. desklet.js:848
41+
#. desklet.js:868
3842
msgid "Error: "
3943
msgstr "Fejl: "
4044

41-
#. desklet.js:963
45+
#. desklet.js:983
4246
msgid ""
4347
"Failed to retrieve authorization parameter! Unable to fetch quotes data."
4448
"\\nStatus: "
4549
msgstr ""
4650
"Kunne ikke hente godkendelsesparameter! Kunne ikke hente kursdata.\n"
4751
"Status: "
4852

49-
#. desklet.js:989
53+
#. desklet.js:1009
5054
msgid "Consent processing failed! Unable to fetch quotes data.\\nStatus: "
5155
msgstr "Samtykkebehandling mislykkedes! Kunne ikke hente kursdata.\\nStatus: "
5256

53-
#. desklet.js:994
57+
#. desklet.js:1014
5458
msgid ""
5559
"Consent processing not completed! Unable to fetch quotes data.\\nStatus: "
5660
msgstr ""
5761
"Samtykkebehandling ikke gennemført! Kunne ikke hente kursdata.\\nStatus: "
5862

59-
#. desklet.js:1017
63+
#. desklet.js:1037
6064
msgid ""
6165
"Failed to retrieve authorization crumb! Unable to fetch quotes data."
6266
"\\nStatus: "

yfquotes@thegli/files/yfquotes@thegli/po/de.po

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ msgstr ""
77
"Project-Id-Version: \n"
88
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-desklets/"
99
"issues\n"
10-
"POT-Creation-Date: 2024-09-12 23:49+0200\n"
10+
"POT-Creation-Date: 2024-11-20 20:33+0100\n"
1111
"PO-Revision-Date: 2023-08-28 16:36+0200\n"
1212
"Last-Translator: \n"
1313
"Language-Team: \n"
@@ -21,45 +21,49 @@ msgstr ""
2121
msgid "No quotes data to display"
2222
msgstr "Keine Finanzdaten vorhanden"
2323

24-
#. desklet.js:415
24+
#. desklet.js:427
2525
msgid "Empty quotes list. Open settings and add some symbols."
2626
msgstr ""
2727
"Liste der Symbole ist leer. Öffne die Einstellungen und füge Symbole hinzu."
2828

29-
#. desklet.js:437 desklet.js:456
29+
#. desklet.js:450 desklet.js:473
30+
msgid "Authorization parameters have expired"
31+
msgstr "Autorisierungsparameter sind abgelaufen"
32+
33+
#. desklet.js:453 desklet.js:476
3034
msgid "Yahoo Finance service not available!\\nStatus: "
3135
msgstr "Yahoo Finance Service nicht verfügbar!\\nStatus: "
3236

33-
#. desklet.js:815
37+
#. desklet.js:835
3438
msgid "Updated at "
3539
msgstr "Aktualisiert um "
3640

37-
#. desklet.js:848
41+
#. desklet.js:868
3842
msgid "Error: "
3943
msgstr "Fehler: "
4044

41-
#. desklet.js:963
45+
#. desklet.js:983
4246
msgid ""
4347
"Failed to retrieve authorization parameter! Unable to fetch quotes data."
4448
"\\nStatus: "
4549
msgstr ""
4650
"Empfang von Autorisierungsparameter ist fehlgeschlagen! Finanzdaten-Abfrage "
4751
"nicht möglich.\\nStatus: "
4852

49-
#. desklet.js:989
53+
#. desklet.js:1009
5054
msgid "Consent processing failed! Unable to fetch quotes data.\\nStatus: "
5155
msgstr ""
5256
"Consent-Erteilung ist fehlgeschlagen! Finanzdaten-Abfrage nicht möglich."
5357
"\\nStatus: "
5458

55-
#. desklet.js:994
59+
#. desklet.js:1014
5660
msgid ""
5761
"Consent processing not completed! Unable to fetch quotes data.\\nStatus: "
5862
msgstr ""
5963
"Consent-Erteilung nicht abgeschlossen! Finanzdaten-Abfrage nicht möglich."
6064
"\\nStatus: "
6165

62-
#. desklet.js:1017
66+
#. desklet.js:1037
6367
msgid ""
6468
"Failed to retrieve authorization crumb! Unable to fetch quotes data."
6569
"\\nStatus: "

yfquotes@thegli/files/yfquotes@thegli/po/es.po

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ msgstr ""
77
"Project-Id-Version: \n"
88
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-desklets/"
99
"issues\n"
10-
"POT-Creation-Date: 2024-09-12 23:49+0200\n"
10+
"POT-Creation-Date: 2024-11-20 20:33+0100\n"
1111
"PO-Revision-Date: 2024-09-03 10:48-0400\n"
1212
"Last-Translator: \n"
1313
"Language-Team: \n"
@@ -21,45 +21,49 @@ msgstr ""
2121
msgid "No quotes data to display"
2222
msgstr "No hay datos de cotizaciones para mostrar"
2323

24-
#. desklet.js:415
24+
#. desklet.js:427
2525
msgid "Empty quotes list. Open settings and add some symbols."
2626
msgstr ""
2727
"Lista de cotizaciones vacía. Abra la configuración y añada algunos símbolos."
2828

29-
#. desklet.js:437 desklet.js:456
29+
#. desklet.js:450 desklet.js:473
30+
msgid "Authorization parameters have expired"
31+
msgstr ""
32+
33+
#. desklet.js:453 desklet.js:476
3034
msgid "Yahoo Finance service not available!\\nStatus: "
3135
msgstr "El servicio de Yahoo Finanzas no está disponible: "
3236

33-
#. desklet.js:815
37+
#. desklet.js:835
3438
msgid "Updated at "
3539
msgstr "Actualizado en "
3640

37-
#. desklet.js:848
41+
#. desklet.js:868
3842
msgid "Error: "
3943
msgstr "Error: "
4044

41-
#. desklet.js:963
45+
#. desklet.js:983
4246
msgid ""
4347
"Failed to retrieve authorization parameter! Unable to fetch quotes data."
4448
"\\nStatus: "
4549
msgstr ""
4650
"Error al recuperar el parámetro de autorización. No se han podido recuperar "
4751
"los datos de las cotizaciones: "
4852

49-
#. desklet.js:989
53+
#. desklet.js:1009
5054
msgid "Consent processing failed! Unable to fetch quotes data.\\nStatus: "
5155
msgstr ""
5256
"No se ha podido procesar el consentimiento. No se han podido recuperar los "
5357
"datos de las cotizaciones: "
5458

55-
#. desklet.js:994
59+
#. desklet.js:1014
5660
msgid ""
5761
"Consent processing not completed! Unable to fetch quotes data.\\nStatus: "
5862
msgstr ""
5963
"No se ha completado el procesamiento del consentimiento. No se han podido "
6064
"recuperar los datos de las cotizaciones: "
6165

62-
#. desklet.js:1017
66+
#. desklet.js:1037
6367
msgid ""
6468
"Failed to retrieve authorization crumb! Unable to fetch quotes data."
6569
"\\nStatus: "

0 commit comments

Comments
 (0)