remove lxml

This commit is contained in:
Trim21
2023-04-29 13:12:56 +08:00
parent f47448938b
commit 160088b0c5
5 changed files with 29 additions and 72 deletions

View File

@@ -1,41 +0,0 @@
name: Build(Docker)
on:
push:
tags:
- '\d+\.\d+\.\d+'
jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
- name: Create Version info
working-directory: ./src
run: |
echo "VERSION = '$GITHUB_REF_NAME'" > module/__version__.py
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/arm
push: true
tags: |
estrellaxd/auto_bangumi:latest
estrellaxd/auto_bangumi:${{ github.ref_name }}
labels: ${{ steps.meta.outputs.labels }}

View File

@@ -2,40 +2,35 @@ name: Build(Docker)
on:
push:
tags:
- '\d+\.\d+\.\d+'
jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Checkout
- name: Checkout
uses: actions/checkout@v3
- name: Create Version info
working-directory: ./src
run: |
echo "VERSION = '$GITHUB_REF_NAME'" > module/__version__.py
-
name: Set up QEMU
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
-
name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v3
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
builder: ${{ steps.buildx.output.name }}
platforms: linux/amd64,linux/arm64,linux/arm
push: false
tags: |
estrellaxd/auto_bangumi:latest
estrellaxd/auto_bangumi:${{ github.ref_name }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha, scope=${{ github.workflow }}
cache-to: type=gha, scope=${{ github.workflow }}

View File

@@ -3,12 +3,16 @@
FROM python:3.11-alpine AS Builder
WORKDIR /app
COPY requirements.txt .
RUN apk add --no-cache --virtual=build-dependencies \
RUN --mount=target=/root/.cache/pip,type=cache,sharing=locked \
--mount=target=/root/.ccache,type=cache,sharing=locked \
apk add --no-cache --virtual=build-dependencies \
libxml2-dev \
libxslt-dev \
gcc \
g++ \
linux-headers \
ccache \
build-base && \
python3 -m pip install --upgrade pip && \
pip install cython && \

View File

@@ -1,6 +1,5 @@
anyio
beautifulsoup4
lxml
certifi
charset-normalizer
click

View File

@@ -7,6 +7,7 @@ from .request_url import RequestURL
from module.conf import settings
import xml.etree.ElementTree
FILTER = "|".join(settings.rss_parser.filter)
@@ -21,8 +22,13 @@ class RequestContent(RequestURL):
# Mikanani RSS
def get_torrents(self, _url: str, filter: bool = True) -> [TorrentInfo]:
soup = self.get_xml(_url)
torrent_titles = [item.title.string for item in soup.find_all("item")]
torrent_urls = [item.get("url") for item in soup.find_all("enclosure")]
torrent_titles = []
torrent_urls = []
for item in soup.findall("./channel/item"):
torrent_titles.append(item.find("title").text)
torrent_urls.append(item.find("enclosure").attrib['url'])
torrents = []
for _title, torrent_url in zip(torrent_titles, torrent_urls):
if filter:
@@ -32,14 +38,8 @@ class RequestContent(RequestURL):
torrents.append(TorrentInfo(_title, torrent_url))
return torrents
def get_torrent(self, _url) -> TorrentInfo:
soup = self.get_xml(_url)
item = soup.find("item")
enclosure = item.find("enclosure")
return TorrentInfo(item.title.string, enclosure["url"])
def get_xml(self, _url):
return BeautifulSoup(self.get_url(_url).text, "xml")
def get_xml(self, _url) -> xml.etree.ElementTree.ElementTree:
return xml.etree.ElementTree.fromstring(self.get_url(_url).text)
# API JSON
def get_json(self, _url) -> dict: