-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0902f43
commit 0d79c18
Showing
7 changed files
with
92 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ beautifulsoup4 | |
tgbot-ping | ||
redis | ||
apscheduler | ||
pymongo | ||
pymongo | ||
tornado |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/usr/local/bin/python3 | ||
# coding: utf-8 | ||
|
||
# YYeTsBot - dump_kv.py | ||
# 2/6/21 18:12 | ||
# | ||
|
||
__author__ = "Benny <benny.think@gmail.com>" | ||
|
||
import threading | ||
import requests | ||
import json | ||
from concurrent.futures.thread import ThreadPoolExecutor | ||
|
||
s = requests.Session() | ||
|
||
with open("index.json", ) as f: | ||
ids = json.load(f) | ||
|
||
chunk = [ids[x:x + 3000] for x in range(0, len(ids), 3000)] | ||
|
||
|
||
def download(c): | ||
print("running batch ", c[0]) | ||
for i in c: | ||
data = s.get("https://yyets.dmesg.app/id={}".format(i)).json() | ||
with open(f"{i}.json", "w") as f: | ||
json.dump(data, f) | ||
|
||
|
||
if __name__ == '__main__': | ||
threads = [] | ||
for part in chunk: | ||
# Create 9 threads counting 10-19, 20-29, ... 90-99. | ||
thread = threading.Thread(target=download, args=(part,)) | ||
threads.append(thread) | ||
|
||
# Start them all | ||
for thread in threads: | ||
thread.start() | ||
|
||
# Wait for all to complete | ||
for thread in threads: | ||
thread.join() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/local/bin/python3 | ||
# coding: utf-8 | ||
|
||
# YYeTsBot - load_from_kv.py | ||
# 2/6/21 18:27 | ||
# | ||
|
||
__author__ = "Benny <benny.think@gmail.com>" | ||
|
||
import pymongo | ||
import json | ||
import os | ||
|
||
mongo_client = pymongo.MongoClient() | ||
|
||
data_files = [i for i in os.listdir("data/") if i.endswith(".json")] | ||
col = mongo_client["zimuzu"]["yyets"] | ||
for data_file in data_files: | ||
with open(os.path.join("data", data_file)) as f: | ||
d = json.load(f) | ||
views = int(d["data"]["info"]["views"]) | ||
d["data"]["info"]["views"] = views | ||
col.insert_one(d) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters