mirror of
https://github.com/EstrellaXD/Auto_Bangumi.git
synced 2026-11-05 23:18:56 +08:00
feat: init rss polling module
This commit is contained in:
@@ -3,3 +3,4 @@ from .config import Config
|
||||
from .torrent import EpisodeFile, SubtitleFile
|
||||
from .user import UserLogin
|
||||
from .torrent import TorrentBase
|
||||
from .rss import RSSTorrents
|
||||
|
||||
10
src/module/models/rss.py
Normal file
10
src/module/models/rss.py
Normal file
@@ -0,0 +1,10 @@
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class RSSTorrents(BaseModel):
|
||||
name: str = Field(..., alias="item_path")
|
||||
url: str = Field(..., alias="url")
|
||||
analyze: bool = Field(..., alias="analyze")
|
||||
enabled: bool = Field(..., alias="enabled")
|
||||
torrents: list[str] = Field(..., alias="torrents")
|
||||
|
||||
28
src/module/rss/poller.py
Normal file
28
src/module/rss/poller.py
Normal file
@@ -0,0 +1,28 @@
|
||||
import re
|
||||
|
||||
from module.database import RSSDatabase
|
||||
from module.network import RequestContent, TorrentInfo
|
||||
from module.models import BangumiData, RSSTorrents
|
||||
from module.conf import settings
|
||||
|
||||
|
||||
class RSSPoller(RSSDatabase):
|
||||
|
||||
@staticmethod
|
||||
def polling(rss_link, req: RequestContent) -> list[TorrentInfo]:
|
||||
return req.get_torrents(rss_link)
|
||||
|
||||
@staticmethod
|
||||
def filter_torrent(data: BangumiData, torrent: TorrentInfo) -> bool:
|
||||
if data.title_raw in torrent.name:
|
||||
_filter = "|".join(data.filter)
|
||||
if not re.search(_filter, torrent.name):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def foo(self):
|
||||
rss_datas: list[RSSTorrents] = self.get_rss_data()
|
||||
with RequestContent() as req:
|
||||
for rss_data in rss_datas:
|
||||
torrents = self.polling(rss_data.url, req)
|
||||
Reference in New Issue
Block a user