Compare commits
No commits in common. "83c87c310d37587636aafc3b6b9ea1e644063ac7" and "eb34c4cd8adab561e484192d6c6fb7ae2c04be73" have entirely different histories.
83c87c310d
...
eb34c4cd8a
1 changed files with 7 additions and 10 deletions
17
script.py
17
script.py
|
@ -56,23 +56,20 @@ for submission in reddit.subreddit(str(getenv("REDDIT_SUBREDDIT"))).top(time_fil
|
||||||
mastodon.status_post(status_text, visibility="unlisted")
|
mastodon.status_post(status_text, visibility="unlisted")
|
||||||
# check if reddit video
|
# check if reddit video
|
||||||
elif "v.redd.it" in submission.url:
|
elif "v.redd.it" in submission.url:
|
||||||
filename = "video.mp4"
|
|
||||||
|
|
||||||
# download video with highest possible resolution while not exceeding 10MB
|
|
||||||
print("Downloading video post: https://www.reddit.com" + submission.permalink)
|
print("Downloading video post: https://www.reddit.com" + submission.permalink)
|
||||||
downloader = Downloader(url="https://www.reddit.com"+submission.permalink, filename=filename, max_s=10_000_000, auto_max=True)
|
downloader = Downloader(url="https://www.reddit.com"+submission.permalink, filename="video.mp4", max_q=True)
|
||||||
return_val = downloader.download()
|
downloader.download()
|
||||||
|
|
||||||
print("\nUploading video")
|
print("\nUploading video")
|
||||||
|
|
||||||
# check if video was downloaded successfully (digit return value if unsuccessful, otherwise string value containing the path to the video)
|
# check if video file is small enough for the server (10MB)
|
||||||
if str(return_val).isdigit():
|
if getsize(filename) < 10_000_000:
|
||||||
status_text = submission.title + "\n\nDas gepostete Video ist leider zu groß für diesen Server. Das Video bzw. der Post kann über den untenstehenden Link aufgerufen werden. " + "\n\ngeposted von u/" + submission.author.name + "\nhttps://www.reddit.com" + submission.permalink
|
|
||||||
mastodon.status_post(status_text, visibility="unlisted")
|
|
||||||
else:
|
|
||||||
media = mastodon.media_post(filename)
|
media = mastodon.media_post(filename)
|
||||||
status_text = submission.title + "\n\ngeposted von u/" + submission.author.name + "\nhttps://www.reddit.com" + submission.permalink
|
status_text = submission.title + "\n\ngeposted von u/" + submission.author.name + "\nhttps://www.reddit.com" + submission.permalink
|
||||||
mastodon.status_post(status_text, media_ids=media["id"], visibility="unlisted")
|
mastodon.status_post(status_text, media_ids=media["id"], visibility="unlisted")
|
||||||
|
else:
|
||||||
|
status_text = submission.title + "\n\nDas gepostete Video ist leider zu lang für diesen Server. Das Video bzw. der Post kann über den untenstehenden Link aufgerufen werden. " + "\n\ngeposted von u/" + submission.author.name + "\nhttps://www.reddit.com" + submission.permalink
|
||||||
|
mastodon.status_post(status_text, visibility="unlisted")
|
||||||
|
|
||||||
remove(filename)
|
remove(filename)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue