Compare commits

...

6 commits

Author SHA1 Message Date
e368de35a0
Add link to fork 2024-11-09 21:48:28 +01:00
92eb20f85c Replace URL for dashboard
The URL for the dashboard has changed. This commit replaces the old one
with the new one.
2019-05-16 22:26:40 +02:00
Martin Puppe
0432c9087a Bump up version number to 1.02 2017-12-17 14:08:14 +01:00
Martin Puppe
3e9464d858 Fix error with newly created Uberspace accounts
Newly created Uberspace accounts do not display an account balance on
the accounting page. The script has to handle that case.
2017-12-17 14:04:51 +01:00
Martin Puppe
a748cff082 Rename variable 2017-10-31 18:02:27 +01:00
Martin Puppe
d6c1aac461 Increment version number 2017-10-31 18:02:14 +01:00
2 changed files with 25 additions and 11 deletions

View file

@ -1,5 +1,11 @@
# MoneyMoney extension for Uberspace.de accounts # MoneyMoney extension for Uberspace.de accounts
> [!IMPORTANT]
> I will not update this extension anymore, but [there is a
> fork](https://github.com/hatobi/moneymoney-uberspace) by
> [@hatobi](https://github.com/hatobi) which is actively maintained and has
> additional functionality.
This extension for [MoneyMoney](https://moneymoney-app.com/) retrieves This extension for [MoneyMoney](https://moneymoney-app.com/) retrieves
the balance and transactions from [Uberspace.de](https://uberspace.de/) the balance and transactions from [Uberspace.de](https://uberspace.de/)
accounts. accounts.

View file

@ -4,8 +4,8 @@
file, You can obtain one at http://mozilla.org/MPL/2.0/. file, You can obtain one at http://mozilla.org/MPL/2.0/.
--]] --]]
WebBanking{version = 1.00, WebBanking{version = 1.02,
url = 'https://uberspace.de/login', url = 'https://dashboard.uberspace.de/login',
services = {'Uberspace.de'}, services = {'Uberspace.de'},
description = string.format( description = string.format(
MM.localizeText("Get balance and transactions for %s"), MM.localizeText("Get balance and transactions for %s"),
@ -24,7 +24,7 @@ function InitializeSession (protocol, bankCode, username, username2,
-- Login. -- Login.
usUsername = username usUsername = username
html = HTML(usConnection:get('https://uberspace.de/login')) html = HTML(usConnection:get('https://dashboard.uberspace.de/login'))
html:xpath('//input[@name="login"]'):attr('value', username) html:xpath('//input[@name="login"]'):attr('value', username)
html:xpath('//input[@name="password"]'):attr('value', password) html:xpath('//input[@name="password"]'):attr('value', password)
@ -52,6 +52,11 @@ function RefreshAccount (account, since)
function ParseAmount (amountString) function ParseAmount (amountString)
local pattern = '(%-?%d+),(%d%d)' local pattern = '(%-?%d+),(%d%d)'
local euro, cent = amountString:match(pattern) local euro, cent = amountString:match(pattern)
if not euro or not cent then
return nil
end
euro = tonumber(euro) euro = tonumber(euro)
cent = tonumber(cent) / 100 cent = tonumber(cent) / 100
if euro < 0 then if euro < 0 then
@ -62,7 +67,7 @@ function RefreshAccount (account, since)
end end
html = HTML(usConnection:get( html = HTML(usConnection:get(
'https://uberspace.de/dashboard/accounting')) 'https://dashboard.uberspace.de/dashboard/accounting'))
tableRows = html:xpath( tableRows = html:xpath(
'//*[@id="transactions"]//tr[count(td)=3][position()<last()]') '//*[@id="transactions"]//tr[count(td)=3][position()<last()]')
print('Found ' .. tableRows:length() .. ' rows') print('Found ' .. tableRows:length() .. ' rows')
@ -74,27 +79,30 @@ function RefreshAccount (account, since)
local children = row:children() local children = row:children()
local pattern = '(%d%d)%.(%d%d)%.(%d%d%d%d)' local pattern = '(%d%d)%.(%d%d)%.(%d%d%d%d)'
local day, month, year = children:get(1):text():match(pattern) local day, month, year = children:get(1):text():match(pattern)
local valueTime = os.time{day=day, month=month, year=year} local bookingDate = os.time{day=day, month=month, year=year}
if valueTime < since then if bookingDate < since then
print('Stopping parsing because transaction is too old.') print('Stopping parsing because transaction is too old.')
print('Date of transaction: ' .. os.date('%c', valueTime)) print('Date of transaction: ' .. os.date('%c', bookingDate))
print('since: ' .. os.date('%c', since)) print('since: ' .. os.date('%c', since))
break break
end end
local amount = ParseAmount(children:get(3):text()) local amount = ParseAmount(children:get(3):text())
table.insert(transactions, { table.insert(transactions, {
bookingDate = valueTime, bookingDate = bookingDate,
amount = amount amount = amount
}) })
end end
balanceElement = html:xpath('//*[@id="total"]') local balanceElement = html:xpath('//*[@id="total"]')
balance = ParseAmount(balanceElement:text()) local balance = ParseAmount(balanceElement:text())
if not balance then
balance = 0
end
return {balance=balance, transactions=transactions} return {balance=balance, transactions=transactions}
end end
function EndSession () function EndSession ()
usConnection:get('https://uberspace.de/logout') usConnection:get('https://dashboard.uberspace.de/logout')
end end