Skip to content

Commit

Permalink
fix download icons in blacklist
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandrebouttier committed Jul 13, 2021
1 parent be7d94e commit ccbe3d0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 269 deletions.
30 changes: 13 additions & 17 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ cmlog.start('Start generator');
if (!_.isEmpty(config.apikey)) {
axios
.get('https://pro-api.coinmarketcap.com/v1/cryptocurrency/map', {
headers: { 'X-CMC_PRO_API_KEY': config.apikey },
headers: { 'X-CMC_PRO_API_KEY': config.apikey }
})
.then((res) => {
res.data.data.map((crypto, index) => {
Expand All @@ -49,57 +49,53 @@ if (!_.isEmpty(config.apikey)) {
(o) => !_.includes(filesIconsExists, o) && !_.includes(blacklist, o)
);

cmlog.success(
`Retrieving the list of cryptos Total: [${cryptosData.length}]`
);
cmlog.success(`Retrieving the list of cryptos Total: [${cryptosData.length}]`);

if (cryptosData && cryptosData.length === 0) {
cmlog.done('All icons have been updated !');
} else {
cryptosData.forEach((crypto, index) => {
const cryptoName = crypto.replace(/\s+/g, '');

setTimeout(() => {
axios
.get(
`https://pro-api.coinmarketcap.com/v1/cryptocurrency/info?symbol=${crypto}`,
`https://pro-api.coinmarketcap.com/v1/cryptocurrency/info?symbol=${cryptoName}`,
{
headers: { 'X-CMC_PRO_API_KEY': config.apikey },
headers: { 'X-CMC_PRO_API_KEY': config.apikey }
}
)
.then((o) => {
const imageUrl = o.data.data[_.upperCase(crypto)].logo;
const imageUrl = o.data.data[_.upperCase(cryptoName)].logo;
const options = {
url: imageUrl,
dest: `${folderPatch}/icons/${crypto}.png`,
dest: `${folderPatch}/icons/${cryptoName}.png`
};

download
.image(options)
.then(({ filename }) => {
cmlog.success(`Icon saved ${filename}`);
cmlog.waitting(
`PROGRESS [${index + 1}/${cryptosData.length}]`
);
cmlog.waitting(`PROGRESS [${index + 1}/${cryptosData.length}]`);
})
.catch((err) => cmlog.error(new Error(err)));
})
.catch((err) => {
if (err && err.response && err.response.status === 400) {
cmlog.error(
new Error(`Crypto icon not found => "${crypto}"`)
);
cmlog.error(new Error(`Crypto icon not found => "${cryptoName}"`));

const csvWriter = createCsvWriter({
path: 'blacklist.csv',
header: [{ id: 'name', title: 'NAME' }],
append: true,
append: true
});

const records = [{ name: crypto }];
const records = [{ name: cryptoName }];

csvWriter
.writeRecords(records) // returns a promise
.then(() => {
cmlog.info(`Crypto add blacklist => ${crypto}"`);
cmlog.info(`Crypto add blacklist => ${cryptoName}"`);
});
}
});
Expand Down
261 changes: 9 additions & 252 deletions blacklist.csv
Original file line number Diff line number Diff line change
@@ -1,265 +1,22 @@
NAME
xbtc 21
2 give
nlc 2
erc 20
b 2 b
c 20
j 8 t
1 wo
ac 3
0 x btc
tm 2
rock 2
x 8 x
x 12
f 1 c
plus 1
d 4 rk
b 2 g
s 4 f
1 sg
1 x 2
rc 20
e 2 c
p 2 px
btc 2
b 91
7 e
cix 100
x 42
mb 8
1 up
1 mt
1 gold
et lyte t
on le xpa
1 ai
afro x
ifx 24
ak 12
r 2 r
im btc
i own
b 1 p
ff 1
ag 8
2 key
ly xe
sac 1
t 69
mo co
btc 3 l
btc 3 s
eth 3 s
eth 3 l
gom 2
3 cs
4 art
l 2 p
ydai yusdc yusdt ytusd
eth 20 smaco
ethrsi 6040
s trx
s link
s btc
fx 1
based
e mtrg
yamv 2
dacc 2
yi 12
yf dai
g kimchi
i 9 c
yfi 2
p 2 p
po sh
y tsla
x btc
rope
c 2 o
yf 4
defi s
defi l
milk 2
wvg 0
wg 0
y ban
pxusd mar 2021
kp 3 r
x dot
st firo
n 0031
kp 4 r
yfb 2
7 up
nyan 2
yvaultlpycurveyycrv
yfdai
defil
nyan2
noob
bst 1
ib eth
sav 3
c fi
sup 8 eme
cp 3 r
api 3
kp 2 r
lk 3 r
7 add
l 2
yfi 3
c 0 in
emc 2
lburst
c 2
n 8 v
lc 4
vec 2
reb 2
w cres
wav 3
a 5 t
v sxp
z 502
v usdt
v usdc
v busd
v xvs
v bnb
v btc
v eth
v ltc
v xrp
v bch
v link
v dot
m aapl
m googl
m tsla
m nflx
m baba
dj 15
pir
n 3rd z
m amzn
m msft
m twtr
m iau
m qqq
m slv
m uso
m vixy
r 34 p
anrx
b 21
2 based
xeth g
n 0001
3 xt
a eth
1 inch
kp 3 rb
808 ta
v fil
v dai
xdef 2
p btc 35 a
aria 20
zzzv 2
r 3 fi
ar nxm
u 8 d
gst 2
trdl
md
s yfl
mp 3
defi 5
g 999
gfarm 2
b 20
rit 20
y panda
punk basic
slnv 2
d 100
w szo
naruto 2
a enj
mp 4
x dai
a 2 a
x moon
a wsb
b 26
mco 2
l 3 p
50 x
cc 10
orcl 5
creth 2
y vault lp y curve yycrv
m fb
co 2
wx dai
hve 2
co 2 b
p eth 18 c
8 pay
delta rlp
10 set
b 360
mo fi
x blzd
k 21
moon stop
chz 006
d art
bcmc 1
1 mil
ec 2
v doge
v ada
100 x
cbix p
2 goshi
poly moon
w sienna
o 3
g 9 tro
b priva
420 x
eth 2 x fli
0 x mr
x 2 p
football stars
x token
burn 1
kei
polarv 3
2 lc
n 1
cbixp
eth2xfli
xtoken
wntr
c 3
v bit
kei
peepo
hina
charix token
dao 1
baby doge
x sat
charixtoken
bite
b 2 x
4 stc
avatar
hunny
pawg
yfih 2
clit
sak 3
e rsdl
2 crz
n 1 ce
fan 8
burnx 20
z usd

0 comments on commit ccbe3d0

Please sign in to comment.