create dockerization for the script (#105)

* add dockerfile and change base domain to current one

* add ffmpeg to dockerfile and edit README

* add instructions to save media locally

* fix typo

* add dependencies to dockerfile

* fix dependencies

* add ability to switch between anime and film on run without changing config

* add dependencies to dockerfile

* add argparse

* fix readme

* fix args description
This commit is contained in:
Francesco Grazioso 2024-04-12 17:38:34 +02:00 committed by GitHub
parent 2939da93db
commit ddcb3dfb71
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 67 additions and 14 deletions

View File

@ -15,7 +15,8 @@ You can chat, help improve this repo, or just hang around for some fun in the **
* [Requirement](#requirement)
* [Usage](#usage)
* [Update](#update)
* [USAGE AND OPTIONS](#options)
* [CONFIGURATION](#Configuration)
* [DOCKER](#docker)
* [TUTORIAL](#tutorial)
## Requirement
@ -187,5 +188,23 @@ You can choose different vars:
* `%(episode_name)` : Is the name of the episode
>NOTE: You don't need to add .mp4 at the end
## Docker
You can run the script in a docker container, to build the image just run
```
docker build -t streaming-community-api .
```
and to run it use
```
docker run -it -p 8000:8000 streaming-community-api
```
By default the videos will be saved in `/app/Video` inside the container, if you want to to save them in your machine instead of the container just run
```
docker run -it -p 8000:8000 -v /path/to/download:/app/Video streaming-community-api
```
## Tutorial
For a detailed walkthrough, refer to the [video tutorial](https://www.youtube.com/watch?v=Ok7hQCgxqLg&ab_channel=Nothing)

View File

@ -143,8 +143,8 @@ def test_site(domain: str) -> str:
str: The response text if successful, otherwise None.
"""
console.print("[cyan]Make request site [white]...")
site_url = f"https://streamingcommunity.{domain}"
console.print(f"[cyan]Make request site to {site_url} [white]...")
try:
response = requests.get(site_url, headers={'user-agent': get_headers()})

View File

@ -16,7 +16,7 @@
},
"SITE": {
"streaming_site_name": "streamingcommunity",
"streaming_domain": "forum",
"streaming_domain": "africa",
"anime_site_name": "animeunity",
"anime_domain": "to"
},

20
dockerfile Normal file
View File

@ -0,0 +1,20 @@
FROM python:3.11-slim
COPY . /app
WORKDIR /app
ENV TEMP /tmp
RUN mkdir -p $TEMP
RUN apt-get update && apt-get install -y \
ffmpeg \
build-essential \
libssl-dev \
libffi-dev \
python3-dev \
libxml2-dev \
libxslt1-dev
RUN pip install --no-cache-dir -r requirements.txt
CMD ["python", "run.py"]

Binary file not shown.

36
run.py
View File

@ -3,6 +3,7 @@
import sys
import logging
import platform
import argparse
# Internal utilities
@ -168,21 +169,34 @@ def main_switch():
else:
console.print("[red]Cant find a single element")
def run_function(func, close_console=False):
if close_console:
while 1:
func()
else:
func()
if __name__ == '__main__':
logger = Logger()
if not SWITCH_TO:
if not CLOSE_CONSOLE:
main()
else:
while 1:
main()
# Parse command line arguments
parser = argparse.ArgumentParser(description='Script to download film and series from internet.')
parser.add_argument('-a', '--anime', action='store_true', help='Check into anime category')
parser.add_argument('-f', '--film', action='store_true', help='Check into film/tv series category')
args = parser.parse_args()
if args.anime:
run_function(main_switch, CLOSE_CONSOLE)
elif args.film:
run_function(main, CLOSE_CONSOLE)
else:
if not CLOSE_CONSOLE:
main_switch()
# If no arguments are provided, ask the user to input the category
category = input("Insert category (0: Film/series, 1: Anime) : ")
if category == '0':
run_function(main, CLOSE_CONSOLE)
elif category == '1':
run_function(main_switch, CLOSE_CONSOLE)
else:
while 1:
main_switch()
console.print("[red]Invalid category")
sys.exit(0)