Initial
This commit is contained in:
24
Dockerfile
Normal file
24
Dockerfile
Normal file
@@ -0,0 +1,24 @@
|
||||
FROM ubuntu:20.04
|
||||
|
||||
ENV TERM linux
|
||||
ENV DEBIAN_FRONTEND noninteractive
|
||||
|
||||
RUN apt-get update
|
||||
RUN apt-get upgrade -y
|
||||
RUN apt-get install -y python3-pip tor
|
||||
RUN pip3 install --upgrade ulozto-downloader[auto-captcha]
|
||||
|
||||
RUN pip3 install fastapi uvicorn subprocess.run
|
||||
|
||||
RUN cd /opt/
|
||||
RUN mkdir /path/
|
||||
|
||||
COPY api.py /opt/api.py
|
||||
#CMD ["python3", "/opt/api.py"]
|
||||
WORKDIR /opt/
|
||||
ENTRYPOINT ["uvicorn", "api:app", "--reload" , "--host", "0.0.0.0", "--port", "8000"]
|
||||
#ENTRYPOINT ["python3", /opt/api.py"]
|
||||
#CMD ["/bin/bash"]
|
||||
|
||||
# cd /path/
|
||||
# ulozto-downloader --parts 15 ""
|
||||
21
Dockerfile2
Normal file
21
Dockerfile2
Normal file
@@ -0,0 +1,21 @@
|
||||
FROM ubuntu:20.04
|
||||
|
||||
ENV TERM linux
|
||||
ENV DEBIAN_FRONTEND noninteractive
|
||||
|
||||
RUN apt-get update
|
||||
RUN apt-get upgrade -y
|
||||
RUN apt-get install -y python3-pip tor
|
||||
RUN pip3 install --upgrade ulozto-downloader[auto-captcha]
|
||||
|
||||
RUN cd /opt/
|
||||
RUN mkdir /path/
|
||||
|
||||
#CMD ["python3", "/opt/api.py"]
|
||||
WORKDIR /opt/
|
||||
CMD ["/bin/bash"]
|
||||
#ENTRYPOINT ["python3", /opt/api.py"]
|
||||
#CMD ["/bin/bash"]
|
||||
|
||||
# cd /path/
|
||||
# ulozto-downloader --parts 15 ""
|
||||
37
api.py
Normal file
37
api.py
Normal file
@@ -0,0 +1,37 @@
|
||||
from typing import Union
|
||||
|
||||
from fastapi import FastAPI
|
||||
import os
|
||||
import subprocess, signal
|
||||
import threading
|
||||
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
@app.get("/")
|
||||
def read_root():
|
||||
return {"status": "Success"}
|
||||
|
||||
|
||||
@app.get("/download/")
|
||||
def read_item(url: Union[str, None] = None, parts: Union[int, None] = None):
|
||||
if parts is None:
|
||||
parts = "15"
|
||||
|
||||
os.chdir('/path/')
|
||||
separator = '#'
|
||||
url = url.split(separator, 1)[0]
|
||||
print("URL: ", url)
|
||||
|
||||
|
||||
|
||||
#command = ["nohup ulozto-downloader", "--parts", parts, url]
|
||||
#os.system("nohup ulozto-downloader --parts " + parts + " " + url)
|
||||
#command = subprocess.Popen(["ulozto-downloader"] + "--parts " + parts + " " + url + " >&/dev/null &", stdin=None, stdout=None, stderr=None, close_fds=True)
|
||||
|
||||
cmd = 'nohup python /usr/local/bin/ulozto-downloader "--parts" "%s" "%s" &' % (parts, url)
|
||||
os.system(cmd)
|
||||
|
||||
|
||||
return {"status": "Success", "link": url, "parts": parts}
|
||||
16
main.py
Normal file
16
main.py
Normal file
@@ -0,0 +1,16 @@
|
||||
# This is a sample Python script.
|
||||
|
||||
# Press Shift+F10 to execute it or replace it with your code.
|
||||
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
|
||||
|
||||
|
||||
def print_hi(name):
|
||||
# Use a breakpoint in the code line below to debug your script.
|
||||
print(f'Hi, {name}') # Press Ctrl+8 to toggle the breakpoint.
|
||||
|
||||
|
||||
# Press the green button in the gutter to run the script.
|
||||
if __name__ == '__main__':
|
||||
print_hi('PyCharm')
|
||||
|
||||
# See PyCharm help at https://www.jetbrains.com/help/pycharm/
|
||||
Reference in New Issue
Block a user