mirror of
https://github.com/developersIndia/deviras.git
synced 2024-12-22 08:09:49 +05:30
new scripts & readme
This commit is contained in:
parent
98db840054
commit
df213fb36a
12
README.md
12
README.md
@ -13,7 +13,14 @@
|
|||||||
|
|
||||||
Used for changing the text below total members & live members count in a subreddit.
|
Used for changing the text below total members & live members count in a subreddit.
|
||||||
|
|
||||||
![r/developersIndia About widget](https://user-images.githubusercontent.com/34342551/185678556-e4c911c9-fb12-49da-9ca6-8f8ce2ad9b5a.png)
|
### [aoc](https://github.com/developersIndia/deviras/blob/aoc)
|
||||||
|
|
||||||
|
Used for updating the Advent of Code leaderboard in the [post](https://www.reddit.com/r/developersIndia/comments/1889ar3/advent_of_code_rdevelopersindia_leaderboard_year/).
|
||||||
|
|
||||||
|
### [job_thread](https://github.com/developersIndia/deviras/blob/job_thread)
|
||||||
|
|
||||||
|
Used for creating [hiring threads](https://www.reddit.com/r/developersIndia/?f=flair_name%3A%22Hiring%22) in the subreddit that gets the job from our [job board](https://developersindia.in/job-board/).
|
||||||
|
|
||||||
|
|
||||||
## Setup
|
## Setup
|
||||||
|
|
||||||
@ -40,9 +47,6 @@ Used for changing the text below total members & live members count in a subredd
|
|||||||
python -m unittest
|
python -m unittest
|
||||||
```
|
```
|
||||||
|
|
||||||
## Resources & Learning Material
|
|
||||||
|
|
||||||
- [PRAW Docs](https://praw.readthedocs.io/en/stable/code_overview/other/idcard.html)
|
|
||||||
|
|
||||||
## Contributors ✨
|
## Contributors ✨
|
||||||
|
|
||||||
|
0
community-threads-grabber/__init__.py
Normal file
0
community-threads-grabber/__init__.py
Normal file
58
community-threads-grabber/main.py
Normal file
58
community-threads-grabber/main.py
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
import praw
|
||||||
|
import os
|
||||||
|
from datetime import datetime
|
||||||
|
import json
|
||||||
|
|
||||||
|
client_id = os.environ["REDDIT_CLIENT_ID"]
|
||||||
|
client_secret = os.environ["REDDIT_CLIENT_SECRET"]
|
||||||
|
reddit_pass = os.environ["REDDIT_PASSWORD"]
|
||||||
|
username = os.environ["REDDIT_USERNAME"]
|
||||||
|
|
||||||
|
|
||||||
|
def get_collection(reddit):
|
||||||
|
collection = reddit.subreddit("developersIndia").collections(
|
||||||
|
permalink="https://reddit.com/r/developersIndia/collection/958aef35-f9cb-414d-ab33-08bc639e47de"
|
||||||
|
)
|
||||||
|
return collection
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
reddit = praw.Reddit(
|
||||||
|
client_id=client_id,
|
||||||
|
client_secret=client_secret,
|
||||||
|
username=username,
|
||||||
|
password=reddit_pass,
|
||||||
|
user_agent=f"Automod reader by u/{username}",
|
||||||
|
)
|
||||||
|
|
||||||
|
collection = get_collection(reddit)
|
||||||
|
|
||||||
|
print(f"Last updated: {datetime.utcfromtimestamp(collection.last_update_utc)}")
|
||||||
|
|
||||||
|
posts = []
|
||||||
|
|
||||||
|
for submission_id in collection.sorted_links:
|
||||||
|
submission = reddit.submission(submission_id)
|
||||||
|
post = {
|
||||||
|
"title": submission.title,
|
||||||
|
"url": submission.url,
|
||||||
|
"id": submission.id,
|
||||||
|
"num_comments": submission.num_comments,
|
||||||
|
"created_at": datetime.utcfromtimestamp(submission.created_utc).isoformat(),
|
||||||
|
"flair_text": submission.link_flair_text,
|
||||||
|
}
|
||||||
|
posts.append(post)
|
||||||
|
|
||||||
|
collection_json = {
|
||||||
|
"collection_last_updated": datetime.utcfromtimestamp(
|
||||||
|
collection.last_update_utc
|
||||||
|
).isoformat(),
|
||||||
|
"posts": posts,
|
||||||
|
}
|
||||||
|
|
||||||
|
with open("collection.json", "w") as f:
|
||||||
|
json.dump(collection_json, f, indent=4)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
10
idcard_update/README.md
Normal file
10
idcard_update/README.md
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
## idcard_update
|
||||||
|
|
||||||
|
Used for changing the text below total members & live members count in a subreddit.
|
||||||
|
|
||||||
|
![r/developersIndia About widget](https://user-images.githubusercontent.com/34342551/185678556-e4c911c9-fb12-49da-9ca6-8f8ce2ad9b5a.png)
|
||||||
|
|
||||||
|
|
||||||
|
## Resources & Learning Material
|
||||||
|
|
||||||
|
- [PRAW Docs](https://praw.readthedocs.io/en/stable/code_overview/other/idcard.html)
|
Loading…
Reference in New Issue
Block a user