-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
80 lines (75 loc) · 2.97 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import json
from gsheet import GSheet
from openseaa import Opensea
from nft import Nft
import time
def load_config():
with open('config.json') as f:
return json.load(f)
def main():
config = load_config()
only_verified = config["only_verified"]
excluded_collections = config["exclude_collections_slugs"]
token_ids = config["tokens_ids"]
nft = Nft()
opensea = Opensea()
gsheet = GSheet()
if config["ONLY_collections_provided"]:
for collection in config["collections_slugs"]:
try:
collection_data = opensea.get_collection(collection)
except:
time.sleep(2)
continue
if collection_data:
print(collection_data)
if collection_data["address"] not in gsheet.addresses:
if token_ids:
token_id = token_ids[0]
print("start transfer to ", collection_data["address"])
res = nft.transfer_nft(token_id, collection_data["address"])
if res:
token_ids.remove(token_id)
gsheet.add_to_sheet(collection, collection_data["user"], collection_data["address"])
else:
break
else:
counter = 0
number_of_collection = config["number_of_collections"]
while True:
if counter == number_of_collection:
break
try:
collections = opensea.get_collections(number_of_collection)
except:
time.sleep(2)
continue
for collection in collections:
if collection in excluded_collections:
continue
try:
collection_data = opensea.get_collection(collection)
except:
time.sleep(2)
continue
if collection_data:
print(collection_data)
if collection_data["address"] in gsheet.addresses:
continue
if only_verified and not collection_data["verified"]:
continue
if token_ids:
token_id = token_ids[0]
print("start transfer to ", collection_data["address"])
res = nft.transfer_nft(token_id, collection_data["address"])
if res:
print("transfered")
token_ids.remove(token_id)
gsheet.add_to_sheet(collection, collection_data["user"], collection_data["address"])
counter += 1
if counter == number_of_collection:
break
else:
break
if __name__ == '__main__':
main()