Skip to content

Commit

Permalink
Tweaks, removed bitmart's shitty API
Browse files Browse the repository at this point in the history
Tweaks, removed bitmart's shitty API
  • Loading branch information
taoteh1221 committed Mar 4, 2022
1 parent 4f353a0 commit 710fb17
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 48 deletions.
2 changes: 0 additions & 2 deletions DOCUMENTATION-ETC/TODO.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ ALWAYS do everything in the optimizations / bugs / tests / ux / qa / other secti
OPTIMIZATIONS / BUGS / TESTS / UX / QA / OTHER SECTION
///////////////////////////////////////////////////////

Shitmart (bitmart) changed their websocket API...see WTF is going on


REDO feature sets in README / on SF project page, to include upgrade check features and raspi temperature display features.

Expand Down
4 changes: 4 additions & 0 deletions DOCUMENTATION-ETC/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,10 @@ v3.08.3

-BUG FIX: Auto-installer script works again (sorry!)

-Removed bitmart's shitty API (lol)

-Added changelog link to upgrade alert

---------------------------------------------------------


Expand Down
2 changes: 1 addition & 1 deletion README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Slideshow Crypto Ticker - Developed by Michael Kilday <[email protected]>, r

Copyright 2019-2022 GPLv3

Open source / 100% FREE real time slideshow crypto price ticker for Raspberry Pi LCD screens, including 24 hour volume and CoinGecko / Binance / Coinbase Pro / Kraken / Kucoin / Bitstamp / Bitfinex / HitBTC / OKex / Bitmart / Gate.io support (more market support coming in the future).
Open source / 100% FREE real time slideshow crypto price ticker for Raspberry Pi LCD screens, including 24 hour volume and CoinGecko / Binance / Coinbase Pro / Kraken / Kucoin / Bitstamp / Bitfinex / HitBTC / OKex / Gate.io support (more market support coming in the future).

Supports running in "slideshow mode", to show all the markets you want.

Expand Down
2 changes: 1 addition & 1 deletion bash/firefox.bash
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ fi


# kiosk mode (for UX)
$FIREFOX_PATH --kiosk -new-tab ~/slideshow-crypto-ticker/index.html
$FIREFOX_PATH --kiosk -private -new-tab ~/slideshow-crypto-ticker/index.html

2 changes: 2 additions & 0 deletions bash/ticker-restart.bash
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ xdotool windowactivate ${WID}
xdotool key ctrl+F5

# firefox
rm -rf ~/.cache/mozilla/firefox/*
sleep 1
WID=$(xdotool search --onlyvisible --class firefox|head -1)
xdotool windowactivate ${WID}
xdotool key ctrl+F5
6 changes: 0 additions & 6 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ var exchange_markets = []; // LEAVE ALONE, AND DON'T DELETE (REQUIRED!!)
// Hitbtc formatting example (MULTIPLE TICKERS NOT SUPPORTED): 'ETHBTC'

// Gate.io formatting example: 'MANA_USDT|SAMO_USDT'

// Bitmart formatting example: 'SG_USDT|SG_BTC'
////
////
// Bitstamp markets (set to '' to disable)
Expand Down Expand Up @@ -84,10 +82,6 @@ exchange_markets['hitbtc'] = '';
////
// Gateio markets (set to '' to disable)
exchange_markets['gateio'] = 'SLC_USDT|RNDR_USDT|SLRS_USDT|BIT_USDT|SAMO_USDT';
////
////
// Bitmart markets (set to '' to disable)
exchange_markets['bitmart'] = ''; // SHITMART NOT WORKING FOR NOW, THEY DECIDED TO CHANGE THEIR API!


// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Expand Down
43 changes: 5 additions & 38 deletions js/core/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ function upgrade_check() {

window.latest_version_description = latest_version_description
+ "Manual Install File:\n\n" + latest_version_download
+ "\n\nChangelog:\n\nhttps://raw.githubusercontent.com/taoteh1221/Slideshow_Crypto_Ticker/main/DOCUMENTATION-ETC/changelog.txt"
+ "\n\n(select all the text of either install method to auto-copy to clipboard)";

$("#upgrade_alert").css({ "display": "block" });
Expand Down Expand Up @@ -311,8 +312,6 @@ api['bitfinex'] = 'wss://api.bitfinex.com/ws/1';

api['okex'] = 'wss://ws.okex.com:8443/ws/v5/public';

api['bitmart'] = 'wss://ws-manager-compress.bitmart.com?protocol=1.1';

api['gateio'] = 'wss://ws.gate.io/v3/';


Expand Down Expand Up @@ -623,25 +622,6 @@ alph_symb_regex = /^[a-z0-9\/\-_|:]+$/i;
});

}
// Bitmart
else if ( exchange == 'bitmart' ) {

// API call config
subscribe_msg[exchange] = {
"op": "subscribe",
"args": [
]
};


// Add markets to API call
var loop = 0;
markets[exchange].forEach(element => {
subscribe_msg[exchange].args[loop] = "spot/ticker:" + element;
loop = loop + 1;
});

}


if ( debug_mode == 'on' ) {
Expand Down Expand Up @@ -671,8 +651,8 @@ function websocket_connect(exchange) {
sockets[exchange] = new WebSocket(api[exchange]);


// Fopr bitmart, hange binary type from "blob" to "arraybuffer"
if ( exchange == 'bitmart' ) {
// Fopr EXCHANGE_NAME_HERE, hange binary type from "blob" to "arraybuffer"
if ( exchange == 'EXCHANGE_NAME_HERE' ) {
sockets[exchange].binaryType = "arraybuffer";
}

Expand All @@ -687,15 +667,14 @@ function websocket_connect(exchange) {
sockets[exchange].onmessage = function(e) {


// Check if response is JSON format or bitmart's compressed websocket data, otherwise presume just a regular string
// Check if response is JSON format or compressed websocket data, otherwise presume just a regular string
if ( is_json(e.data) == true ) {
msg = JSON.parse(e.data);
}
else if ( exchange == 'bitmart' ) {
else if ( exchange == 'EXCHANGE_NAME_HERE' ) {

// NOTES ON DECOMPRESSING (ALSO NEEDED sockets[exchange].binaryType = "arraybuffer"; before opening websocket)

// https://developer-pro.bitmart.com/en/ws/spot_ws/compress.html
// https://nodeca.github.io/pako/
// https://stackoverflow.com/questions/4507316/zlib-decompression-client-side
// https://stackoverflow.com/questions/57264517/pako-js-error-invalid-stored-block-lengths-when-trying-to-inflate-websocket-m
Expand Down Expand Up @@ -850,18 +829,6 @@ function websocket_connect(exchange) {
base_volume = pair_volume('pairing', price_raw, volume_raw);

}
// Bitmart
else if ( exchange == 'bitmart' && msg['table'] == 'spot/ticker' ) {

market_id = msg["data"][0]["symbol"];

price_raw = msg["data"][0]["last_price"];

volume_raw = msg["data"][0]["base_volume_24h"];

base_volume = pair_volume('pairing', price_raw, volume_raw);

}


// Nullify rendering under these circumstances (msg is not our data set)
Expand Down

0 comments on commit 710fb17

Please sign in to comment.