A MC API for extracting streaming sources from MC by file ID.
-
Python 3.11
-
aiohttp
-
fastapi
-
uvicorn
-
httpx
-
Clone this repository
git clone https://github.com/carlosesteven/MC_API.git cd MC_API -
Install dependencies
pip install fastapi uvicorn aiohttp httpx
To run the server, simply execute:
clear && python -m uvicorn app:app --host 0.0.0.0 --port 8446
By default, Server will the API at http://127.0.0.1:8446. The node list starts with this local address so distribution works without extra configuration.
GET /api?id=<file_id>&version=<version>
GET /distribute?id=<file_id>&version=<version>
GET /nodes
POST /nodes?url=<node_url>
DELETE /nodes?url=<node_url>
GET http://127.0.0.1:8446/api?id=XXXXXX&version=XX
GET http://127.0.0.1:8446/distribute?id=XXXXXX&version=XX
Returns a JSON with the extracted video sources and additional metadata.
`/distribute` responses also include the node address that processed the request.
-
Update package lists:
sudo apt update -
Install prerequisites:
sudo apt install software-properties-common -y -
Add the deadsnakes PPA:
sudo add-apt-repository ppa:deadsnakes/ppa -y -
Install Python 3.11 and related packages:
sudo apt install python3.11 python3.11-venv python3.11-dev -y -
Verify the installation:
python3.11 --version
-
Create a virtual environment with Python 3.11:
python3.11 -m venv venv -
Activate the virtual environment:
source venv/bin/activate -
Install the project dependencies:
pip install fastapi uvicorn aiohttp httpx -
Run the project:
python -m uvicorn app:app --host 0.0.0.0 --port 8446 -
Deactivate the virtual environment (optional):
deactivate
To run your server in the background and keep it running after closing the terminal, use the following commands:
-
Start the Server in Background
nohup python -m uvicorn app:app --host 0.0.0.0 --port 8446 > /dev/null 2>&1 &This command will start the server in the background.
-
Check if the Server is Running
ps aux | grep uvicornThis will show you the process ID (PID) of the running app.py server.
-
Stop the Server
kill pidOR
pkill -f "uvicorn app:app"This command will stop all running processes that match app.py.