Update
This commit is contained in:
parent
73b5319c60
commit
dda8cd7485
28
FR2T/fr2t.py
28
FR2T/fr2t.py
@ -1,17 +1,19 @@
|
|||||||
from .parser import rssParser, objParser
|
import copy
|
||||||
from .utils import postData, escapeAll, escapeText
|
import copyreg
|
||||||
from jinja2 import Template
|
|
||||||
from pymongo import MongoClient
|
|
||||||
import datetime
|
import datetime
|
||||||
import hashlib
|
import hashlib
|
||||||
import time
|
|
||||||
import re
|
|
||||||
import yaml
|
|
||||||
from multiprocessing import Pool
|
|
||||||
import ssl
|
|
||||||
import copyreg
|
|
||||||
import copy
|
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
|
import ssl
|
||||||
|
import time
|
||||||
|
from multiprocessing import Pool
|
||||||
|
|
||||||
|
import yaml
|
||||||
|
from jinja2 import Template
|
||||||
|
from pymongo import MongoClient
|
||||||
|
|
||||||
|
from .parser import rssParser, objParser
|
||||||
|
from .utils import postData, escapeAll, escapeText
|
||||||
|
|
||||||
|
|
||||||
class FR2T:
|
class FR2T:
|
||||||
@ -181,7 +183,9 @@ def handleRSS(rss, url, telegram, db, user_agent):
|
|||||||
if send:
|
if send:
|
||||||
template = Template(rss["text"])
|
template = Template(rss["text"])
|
||||||
|
|
||||||
args = dict(**result, **content, rss_name=rss["name"], rss_url=rss["url"])
|
args = dict(
|
||||||
|
**result, **content, rss_name=rss["name"], rss_url=rss["url"]
|
||||||
|
)
|
||||||
escapeAll(telegram["parse_mode"], args)
|
escapeAll(telegram["parse_mode"], args)
|
||||||
|
|
||||||
text = template.render(args)
|
text = template.render(args)
|
||||||
|
10
test/rss.py
10
test/rss.py
@ -1,19 +1,23 @@
|
|||||||
import feedparser
|
|
||||||
import json
|
import json
|
||||||
import sys
|
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
import feedparser
|
||||||
|
|
||||||
my_path = __file__
|
my_path = __file__
|
||||||
my_direc = os.path.dirname(__file__)
|
my_direc = os.path.dirname(__file__)
|
||||||
|
|
||||||
def parseUrl(url: str="https://github.com/Apocalypsor/Formatted-RSS-to-Telegram/commits/main.atom"):
|
|
||||||
|
def parseUrl(
|
||||||
|
url: str = "https://github.com/Apocalypsor/Formatted-RSS-to-Telegram/commits/main.atom",
|
||||||
|
):
|
||||||
d = feedparser.parse(url)["entries"]
|
d = feedparser.parse(url)["entries"]
|
||||||
|
|
||||||
file_name = url.replace("https://", "").replace("http://", "").replace("/", "_")
|
file_name = url.replace("https://", "").replace("http://", "").replace("/", "_")
|
||||||
with open(os.path.join(my_direc, f"{file_name}.json"), "w", encoding="UTF-8") as t:
|
with open(os.path.join(my_direc, f"{file_name}.json"), "w", encoding="UTF-8") as t:
|
||||||
json.dump(d, t, indent=4, ensure_ascii=False)
|
json.dump(d, t, indent=4, ensure_ascii=False)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
if len(sys.argv) == 1:
|
if len(sys.argv) == 1:
|
||||||
parseUrl()
|
parseUrl()
|
||||||
|
Loading…
Reference in New Issue
Block a user