-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtumblr-API.py
64 lines (47 loc) · 1.41 KB
/
tumblr-API.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
import pytumblr
import json
import time
import os
import re
def atoi(text):
return int(text) if text.isdigit() else text
def natural_keys(text):
return [ atoi(c) for c in re.split('(\d+)', text) ]
# Authenticate via OAuth
client = pytumblr.TumblrRestClient(
' ',
' ',
' ',
' '
)
# Make the request
blog = client.blog_info('art-py')
os.chdir('artstation')
current_dir = os.getcwd()
print(current_dir)
db_avoid = ["link_db.txt", "name_db.txt", "title_db.txt"]
with open('name_db.txt') as name:
names_bot = json.load(name)
with open('link_db.txt') as link:
source_bot = json.load(link)
with open('title_db.txt') as title:
title_bot = json.load(title)
dir_images = os.listdir('.')
dir_images.sort(key=natural_keys)
print(dir_images)
current_dir2 = os.getcwd()
print(current_dir2)
'''print(ordered_files)'''
counter = 0
for artwork_image in dir_images:
time.sleep(40)
if artwork_image not in db_avoid:
print(artwork_image)
post = "Artist: "
post += names_bot[counter]
post += "\nSource: "
post += source_bot[counter]
client.create_photo('art-py', state="published", tags=["artstation"],
caption=post,
data=artwork_image)
counter += 1