From db9fd9f4766c4ee27d3dc59e681f54b98a374b40 Mon Sep 17 00:00:00 2001 From: moyada Date: Sun, 18 Feb 2024 14:41:30 +0800 Subject: [PATCH] env --- .github/workflows/docker-image.yml | 20 ++++++++++++++++++-- Dockerfile_ARM | 23 +++++++++++++++++++++++ core/apis.py | 14 ++++++++++++-- service/douyin.py | 2 +- stealer/urls.py | 2 +- 5 files changed, 55 insertions(+), 6 deletions(-) create mode 100644 Dockerfile_ARM diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 47b71f8..f77d055 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -13,7 +13,13 @@ jobs: build: runs-on: ubuntu-latest - + strategy: + fail-fast: false + matrix: + platform: + - linux/amd64 + - linux/arm64 + - linux/arm/v7 steps: - name: Checkout @@ -36,5 +42,15 @@ jobs: with: context: . push: true + file: ./Dockerfile + tags: xueyikang/stealer + platforms: linux/amd64,linux/arm64 + + - name: Build and Push Docker arm image + uses: docker/build-push-action@v5 + with: + context: . + push: true + file: ./Dockerfile_ARM tags: xueyikang/stealer - platforms: linux/amd64,linux/arm64 \ No newline at end of file + platform: linux/arm/v7 \ No newline at end of file diff --git a/Dockerfile_ARM b/Dockerfile_ARM new file mode 100644 index 0000000..e6097f3 --- /dev/null +++ b/Dockerfile_ARM @@ -0,0 +1,23 @@ +FROM python:3.8.18-slim + +ENV PYTHONUNBUFFERED 1 + +RUN apt-get update && apt-get upgrade -y && apt-get install -y gcc && apt-get install -y ffmpeg + +# 更新pip +RUN pip install --upgrade pip --index-url http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com + +# 工作目录 +WORKDIR /app +ADD . /app + +# pip安装依赖包 +RUN pip install -r requirements.txt --index-url http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com + +RUN apt-get clean && rm -rf /var/lib/apt/lists/* + +# 打开容器的8000端口 +EXPOSE 8000 + +# 执行命令行,启动django服务 +CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"] diff --git a/core/apis.py b/core/apis.py index 89e87eb..737bcb7 100644 --- a/core/apis.py +++ b/core/apis.py @@ -3,9 +3,11 @@ from django.shortcuts import redirect, render import core +from core import config from core.model import ErrorResult from route import controller from core.type import Video +import core.config def index(request): @@ -14,8 +16,16 @@ def index(request): }) -def ip(request): - return redirect('http://httpbin.org/ip') +def set_env(request): + key = request.GET.get('key') + if not key: + return HttpResponseBadRequest(ErrorResult.TYPE_NOT_PRESENT.get_data()) + value = request.GET.get('value') + if not value: + return HttpResponseBadRequest(ErrorResult.TYPE_NOT_PRESENT.get_data()) + + if key == "bilibili": + config.bilibili_cookie = value def fetch(request): diff --git a/service/douyin.py b/service/douyin.py index a01872b..f7625d1 100644 --- a/service/douyin.py +++ b/service/douyin.py @@ -83,7 +83,7 @@ def get_info(cls, url: str) -> Result: info.cover = DouyinService.get_cover(data) # if data['aweme_type'] is not 0: - if data['images'] is not None : + if data['images'] is not None: info.images = DouyinService.get_image(data) info.filename = data['aweme_id'] + ".zip" else: diff --git a/stealer/urls.py b/stealer/urls.py index 1d37814..5249043 100644 --- a/stealer/urls.py +++ b/stealer/urls.py @@ -23,7 +23,7 @@ # path('admin/', admin.site.urls), path('', TemplateView.as_view(template_name="index.html"), name='index'), # path('', index.index, name='index'), - path('ip/', apis.ip, name='ip'), + # path('set_env', apis.set_env, name='set_env'), path('video/', include('core.urls'), name='video'), ]