Tweak /sheeb command
All checks were successful
Build and push / changes (push) Successful in 3s
Build and push / Lint-Python (push) Successful in 2s
Build and push / Build-and-Push-Docker (push) Successful in 2m37s
Build and push / sync-argocd-app (push) Successful in 2s
Build and push / post-status-to-discord (push) Successful in 3s
All checks were successful
Build and push / changes (push) Successful in 3s
Build and push / Lint-Python (push) Successful in 2s
Build and push / Build-and-Push-Docker (push) Successful in 2m37s
Build and push / sync-argocd-app (push) Successful in 2s
Build and push / post-status-to-discord (push) Successful in 3s
This commit is contained in:
parent
3f630f18fe
commit
9eb2b9ef4a
@ -20,7 +20,6 @@ def get_dog():
|
|||||||
|
|
||||||
|
|
||||||
def random_sheeb():
|
def random_sheeb():
|
||||||
# return requests.get("http://shibe.online/api/shibes?count=1&urls=true").json()[0]
|
|
||||||
return get_from_reddit.get_image(["shiba", "shibe", "shibainu"])
|
return get_from_reddit.get_image(["shiba", "shibe", "shibainu"])
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,17 +20,20 @@ def get_image(boards, nsfw=False):
|
|||||||
if isinstance(boards, list):
|
if isinstance(boards, list):
|
||||||
boards = random.choice(boards)
|
boards = random.choice(boards)
|
||||||
|
|
||||||
request_string = f"https://reddit.com/r/{boards}/random.json"
|
request_string = f"https://www.reddit.com/r/{boards}/hot.json?raw_json=1"
|
||||||
|
|
||||||
if not nsfw:
|
|
||||||
# Append this header to the request. Tells the API to only return SFW results
|
|
||||||
request_string += "?obey_over18=true"
|
|
||||||
|
|
||||||
response = requests.get(
|
response = requests.get(
|
||||||
request_string, headers={"User-agent": random_user_agent}
|
request_string, headers={"User-agent": random_user_agent}
|
||||||
).json()[0]["data"]["children"][0]["data"]
|
).json()["data"]["children"]
|
||||||
|
|
||||||
image_url = "https://rxddit.com" + response["permalink"]
|
response = random.choice(response)["data"]
|
||||||
|
|
||||||
|
if response.get("url_overridden_by_dest"):
|
||||||
|
image_url = response["url_overridden_by_dest"]
|
||||||
|
else:
|
||||||
|
image_url = response["url"]
|
||||||
|
|
||||||
|
# image_url = "https://rxddit.com" + response["permalink"]
|
||||||
|
|
||||||
if "youtu.be" in response["url"]:
|
if "youtu.be" in response["url"]:
|
||||||
image_url = response["url"]
|
image_url = response["url"]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user