Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import json
- print("Sucklessg low effort Python client")
- API_URL = "https://sucklessg.org"
- current_page = 0
- def render_post(id, content, created, replies):
- print("ID: " + str(id))
- print(content)
- print("Reply count: " + str(replies))
- print("Created: " + created)
- print("\n")
- def render_page(page_json):
- for i in page_json:
- render_post(i["id"], i["content"], i["created"], i["replies"])
- print("Page: " + str(current_page))
- def render_thread(thread_json):
- for i in thread_json:
- render_post(i["id"], i["content"], i["created"], None)
- print("End of thread")
- def load_page(page_number):
- page = requests.get(url = API_URL+"/page/"+str(current_page))
- if page.status_code != 200:
- return None
- else:
- return page.json()
- def load_thread(thread_id):
- thread = requests.get(url = API_URL+"/post/"+thread_id)
- if thread.status_code != 200:
- return None
- else:
- return thread.json()
- while True:
- # fetch and render page by current_page number
- page_json = load_page(current_page)
- if page_json is None:
- print("Something dun fucked up")
- else:
- render_page(page_json)
- # get input on action
- print("1) Go to the next page\n2) Go back a page\n3) Enter a thread\n")
- action = input("Action?: ")
- # increment current page
- if action == "1":
- if current_page >= 9:
- print("No more pages for you faggot")
- else:
- current_page+=1
- # deincrement current page
- elif action == "2":
- if current_page <= 0:
- print("gay dumb negative fag")
- else:
- current_page-=1
- # render a thread, ask for the thread id
- elif action == "3":
- thread_id = input("Thread ID?: ")
- thread_json = load_thread(thread_id)
- if thread_json is None:
- print("baaaaaakkaaaa")
- else:
- render_thread(thread_json)
- # block to allow user to read thread
- input()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement