Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 86954ec1 authored by Stephane Mankowski's avatar Stephane Mankowski

Add new source "cryptocompare"

parent 713511c3
......@@ -10,6 +10,7 @@ skrooge (2.22.0)
*Correction: With last version of KDE, KMessageWidget are sometimes empty
*Correction: Add missing "Full screen" menu
*Correction: Remove coinmarketcap because not morking anymore
*Feature: Add new source "cryptocompare"
-- Stephane MANKOWSKI <stephane@mankowski.fr>
......
......@@ -58,5 +58,5 @@ INSTALL(FILES ${PROJECT_SOURCE_DIR}/org.kde.skrooge-import-plugin.desktop DESTIN
INSTALL(FILES ${PROJECT_SOURCE_DIR}/org.kde.skrooge-source-plugin.desktop DESTINATION ${KDE_INSTALL_KSERVICETYPES5DIR})
INSTALL(DIRECTORY sources DESTINATION ${KDE_INSTALL_KSERVICES5DIR} FILES_MATCHING PATTERN "*.desktop")
INSTALL(PROGRAMS skrooge-yahoodl.py DESTINATION ${KDE_INSTALL_DATADIR}/skrooge)
INSTALL(PROGRAMS skrooge-coinmarketcap.py DESTINATION ${KDE_INSTALL_DATADIR}/skrooge)
INSTALL(PROGRAMS skrooge-ratesapi.py DESTINATION ${KDE_INSTALL_DATADIR}/skrooge)
INSTALL(PROGRAMS skrooge-cryptocompare.py DESTINATION ${KDE_INSTALL_DATADIR}/skrooge)
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#**************************************************************************
#* Copyright (C) 2017 by S. MANKOWSKI / G. DE BURE support@mankowski.fr
#* Redistribution and use in source and binary forms, with or without
#* modification, are permitted provided that the following conditions
#* are met:
#*
#* 1. Redistributions of source code must retain the above copyright
#* notice, this list of conditions and the following disclaimer.
#* 2. Redistributions in binary form must reproduce the above copyright
#* notice, this list of conditions and the following disclaimer in the
#* documentation and/or other materials provided with the distribution.
#*
#* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
#* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
#* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
#* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
#* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
#* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
#* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
#* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
#* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
#* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#**************************************************************************
import urllib.request
import json
import sys
import time
units=sys.argv[1].split('-')
f = urllib.request.urlopen('https://min-api.cryptocompare.com/data/v2/histoday?fsym='+units[0]+'&tsym='+units[1]+'&limit=1000&api_key='+units[2])
print("Date,Price")
for item in json.loads(f.read().decode('utf-8'))['Data']['Data']:
print(time.strftime('%Y-%m-%d', time.gmtime(int(item["time"])))+','+str(item['close']))
[Desktop Entry]
Name=Cryptocompare
Comment=You can get the list of available quotes from <a href="https://www.cryptocompare.com/">CryptoCompare</a>.<br/>Then, you must create an account to get an API key.<br/>Then, enter the <expected quote>-<in the expected currency>-<the api key>. Example: if you want BTC in USD, you must enter BTC-USD-3b415edbc7d42bd9e367dc43b415edbc7d42bd9e367dc3b415edbc7d42bd9e36.
Encoding=UTF-8
Icon=skrooge
Type=Service
X-KDE-ServiceTypes=skrooge/source
X-Krunner-ID=cryptocompare
X-KDE-PluginInfo-Author=Stephane MANKOWSKI,miraks
X-KDE-PluginInfo-Email=stephane@mankowski.fr
X-KDE-PluginInfo-Name=Cryptocompare
X-KDE-PluginInfo-Version=1.0
X-KDE-PluginInfo-Website=https://skrooge.org/
X-KDE-PluginInfo-Category=Plugins
X-KDE-PluginInfo-Depends=
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=true
#The url or the command line to get the list of accounts in the standard output, something like this:
#%1 will be replaced by the internet code of the unit
#%2 will be replaced by the current day in format yyyy-MM-dd
#%3 will be replaced by the previous date in format yyyy-MM-dd
#Example:
# X-SKROOGE-url=https://server/?s=%1
# or
# X-SKROOGE-script=mydownloadscript %1
#This parameter is MANDATORY
X-SKROOGE-script=skrooge-cryptocompare.py %1
#The mode (HTML or CSV or CSVR). In HTML mode, only one value will be extracted from downloaded page. In CSV mode, a value per line will be extracted. CSVR means CSV in reverse mode
X-SKROOGE-mode=CSVR
#Regular expression to capture the price of the quote
#This parameter is not MANDATORY.
X-SKROOGE-price=[^,]*,([^,]*)
#Regular expression to capture the date of the quote
#This parameter is not MANDATORY.
X-SKROOGE-date=([^,]*),.*
#The date format
X-SKROOGE-dateformat=yyyy-MM-dd
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment