Spaces:
Paused
Paused
Add support for installing mediaflow-proxy by pip
Browse files- README.md +20 -3
- mediaflow_proxy/main.py +9 -2
- {static → mediaflow_proxy/static}/index.html +0 -0
- {static → mediaflow_proxy/static}/logo.png +0 -0
- poetry.lock +13 -12
- pyproject.toml +21 -4
README.md
CHANGED
|
@@ -31,9 +31,8 @@ MediaFlow Proxy is a powerful and flexible solution for proxifying various types
|
|
| 31 |
- Support for HTTP/HTTPS/SOCKS5 proxy forwarding
|
| 32 |
- Protect against unauthorized access and network bandwidth abuses
|
| 33 |
|
| 34 |
-
## Installation
|
| 35 |
|
| 36 |
-
|
| 37 |
|
| 38 |
Set the following environment variables:
|
| 39 |
|
|
@@ -41,6 +40,7 @@ Set the following environment variables:
|
|
| 41 |
- `PROXY_URL`: Optional. HTTP/HTTPS/SOCKS5 proxy URL for forwarding network requests.
|
| 42 |
- `MPD_LIVE_STREAM_DELAY`: Optional. Delay in seconds for live DASH streams. This is useful to prevent buffering issues with live streams. Default is `30` seconds.
|
| 43 |
|
|
|
|
| 44 |
|
| 45 |
### Option 1: Self-Hosted Deployment
|
| 46 |
|
|
@@ -51,7 +51,24 @@ Set the following environment variables:
|
|
| 51 |
docker run -p 8888:8888 -e API_PASSWORD=your_password mhdzumair/mediaflow-proxy
|
| 52 |
```
|
| 53 |
|
| 54 |
-
#### Using
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
1. Clone the repository:
|
| 57 |
```
|
|
|
|
| 31 |
- Support for HTTP/HTTPS/SOCKS5 proxy forwarding
|
| 32 |
- Protect against unauthorized access and network bandwidth abuses
|
| 33 |
|
|
|
|
| 34 |
|
| 35 |
+
## Configuration
|
| 36 |
|
| 37 |
Set the following environment variables:
|
| 38 |
|
|
|
|
| 40 |
- `PROXY_URL`: Optional. HTTP/HTTPS/SOCKS5 proxy URL for forwarding network requests.
|
| 41 |
- `MPD_LIVE_STREAM_DELAY`: Optional. Delay in seconds for live DASH streams. This is useful to prevent buffering issues with live streams. Default is `30` seconds.
|
| 42 |
|
| 43 |
+
## Installation
|
| 44 |
|
| 45 |
### Option 1: Self-Hosted Deployment
|
| 46 |
|
|
|
|
| 51 |
docker run -p 8888:8888 -e API_PASSWORD=your_password mhdzumair/mediaflow-proxy
|
| 52 |
```
|
| 53 |
|
| 54 |
+
#### Using pip
|
| 55 |
+
1. Install the package:
|
| 56 |
+
```
|
| 57 |
+
pip install mediaflow-proxy
|
| 58 |
+
```
|
| 59 |
+
|
| 60 |
+
2. Set the `API_PASSWORD` and other environment variables in `.env`:
|
| 61 |
+
```
|
| 62 |
+
echo "API_PASSWORD=your_password" > .env
|
| 63 |
+
```
|
| 64 |
+
|
| 65 |
+
3. Run the MediaFlow Proxy server:
|
| 66 |
+
```
|
| 67 |
+
mediaflow-proxy
|
| 68 |
+
```
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
#### Using git & poetry
|
| 72 |
|
| 73 |
1. Clone the repository:
|
| 74 |
```
|
mediaflow_proxy/main.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import logging
|
|
|
|
| 2 |
|
| 3 |
from fastapi import FastAPI, Depends, Security, HTTPException
|
| 4 |
from fastapi.security import APIKeyQuery, APIKeyHeader
|
|
@@ -42,10 +43,16 @@ async def get_favicon():
|
|
| 42 |
|
| 43 |
|
| 44 |
app.include_router(proxy_router, prefix="/proxy", tags=["proxy"], dependencies=[Depends(verify_api_key)])
|
| 45 |
-
app.mount("/", StaticFiles(directory="static", html=True), name="static")
|
| 46 |
|
|
|
|
|
|
|
| 47 |
|
| 48 |
-
|
|
|
|
| 49 |
import uvicorn
|
| 50 |
|
| 51 |
uvicorn.run(app, host="127.0.0.1", port=8888)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import logging
|
| 2 |
+
from importlib import resources
|
| 3 |
|
| 4 |
from fastapi import FastAPI, Depends, Security, HTTPException
|
| 5 |
from fastapi.security import APIKeyQuery, APIKeyHeader
|
|
|
|
| 43 |
|
| 44 |
|
| 45 |
app.include_router(proxy_router, prefix="/proxy", tags=["proxy"], dependencies=[Depends(verify_api_key)])
|
|
|
|
| 46 |
|
| 47 |
+
static_path = resources.files("mediaflow_proxy").joinpath("static")
|
| 48 |
+
app.mount("/", StaticFiles(directory=str(static_path), html=True), name="static")
|
| 49 |
|
| 50 |
+
|
| 51 |
+
def run():
|
| 52 |
import uvicorn
|
| 53 |
|
| 54 |
uvicorn.run(app, host="127.0.0.1", port=8888)
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
if __name__ == "__main__":
|
| 58 |
+
run()
|
{static → mediaflow_proxy/static}/index.html
RENAMED
|
File without changes
|
{static → mediaflow_proxy/static}/logo.png
RENAMED
|
File without changes
|
poetry.lock
CHANGED
|
@@ -88,13 +88,13 @@ files = [
|
|
| 88 |
|
| 89 |
[[package]]
|
| 90 |
name = "certifi"
|
| 91 |
-
version = "2024.
|
| 92 |
description = "Python package for providing Mozilla's CA Bundle."
|
| 93 |
optional = false
|
| 94 |
python-versions = ">=3.6"
|
| 95 |
files = [
|
| 96 |
-
{file = "certifi-2024.
|
| 97 |
-
{file = "certifi-2024.
|
| 98 |
]
|
| 99 |
|
| 100 |
[[package]]
|
|
@@ -124,13 +124,13 @@ files = [
|
|
| 124 |
|
| 125 |
[[package]]
|
| 126 |
name = "fastapi"
|
| 127 |
-
version = "0.112.
|
| 128 |
description = "FastAPI framework, high performance, easy to learn, fast to code, ready for production"
|
| 129 |
optional = false
|
| 130 |
python-versions = ">=3.8"
|
| 131 |
files = [
|
| 132 |
-
{file = "fastapi-0.112.
|
| 133 |
-
{file = "fastapi-0.112.
|
| 134 |
]
|
| 135 |
|
| 136 |
[package.dependencies]
|
|
@@ -139,8 +139,8 @@ starlette = ">=0.37.2,<0.39.0"
|
|
| 139 |
typing-extensions = ">=4.8.0"
|
| 140 |
|
| 141 |
[package.extras]
|
| 142 |
-
all = ["
|
| 143 |
-
standard = ["
|
| 144 |
|
| 145 |
[[package]]
|
| 146 |
name = "gunicorn"
|
|
@@ -197,13 +197,13 @@ trio = ["trio (>=0.22.0,<0.26.0)"]
|
|
| 197 |
|
| 198 |
[[package]]
|
| 199 |
name = "httpx"
|
| 200 |
-
version = "0.27.
|
| 201 |
description = "The next generation HTTP client."
|
| 202 |
optional = false
|
| 203 |
python-versions = ">=3.8"
|
| 204 |
files = [
|
| 205 |
-
{file = "httpx-0.27.
|
| 206 |
-
{file = "httpx-0.27.
|
| 207 |
]
|
| 208 |
|
| 209 |
[package.dependencies]
|
|
@@ -219,6 +219,7 @@ brotli = ["brotli", "brotlicffi"]
|
|
| 219 |
cli = ["click (==8.*)", "pygments (==2.*)", "rich (>=10,<14)"]
|
| 220 |
http2 = ["h2 (>=3,<5)"]
|
| 221 |
socks = ["socksio (==1.*)"]
|
|
|
|
| 222 |
|
| 223 |
[[package]]
|
| 224 |
name = "idna"
|
|
@@ -575,4 +576,4 @@ files = [
|
|
| 575 |
[metadata]
|
| 576 |
lock-version = "2.0"
|
| 577 |
python-versions = "^3.12"
|
| 578 |
-
content-hash = "
|
|
|
|
| 88 |
|
| 89 |
[[package]]
|
| 90 |
name = "certifi"
|
| 91 |
+
version = "2024.8.30"
|
| 92 |
description = "Python package for providing Mozilla's CA Bundle."
|
| 93 |
optional = false
|
| 94 |
python-versions = ">=3.6"
|
| 95 |
files = [
|
| 96 |
+
{file = "certifi-2024.8.30-py3-none-any.whl", hash = "sha256:922820b53db7a7257ffbda3f597266d435245903d80737e34f8a45ff3e3230d8"},
|
| 97 |
+
{file = "certifi-2024.8.30.tar.gz", hash = "sha256:bec941d2aa8195e248a60b31ff9f0558284cf01a52591ceda73ea9afffd69fd9"},
|
| 98 |
]
|
| 99 |
|
| 100 |
[[package]]
|
|
|
|
| 124 |
|
| 125 |
[[package]]
|
| 126 |
name = "fastapi"
|
| 127 |
+
version = "0.112.2"
|
| 128 |
description = "FastAPI framework, high performance, easy to learn, fast to code, ready for production"
|
| 129 |
optional = false
|
| 130 |
python-versions = ">=3.8"
|
| 131 |
files = [
|
| 132 |
+
{file = "fastapi-0.112.2-py3-none-any.whl", hash = "sha256:db84b470bd0e2b1075942231e90e3577e12a903c4dc8696f0d206a7904a7af1c"},
|
| 133 |
+
{file = "fastapi-0.112.2.tar.gz", hash = "sha256:3d4729c038414d5193840706907a41839d839523da6ed0c2811f1168cac1798c"},
|
| 134 |
]
|
| 135 |
|
| 136 |
[package.dependencies]
|
|
|
|
| 139 |
typing-extensions = ">=4.8.0"
|
| 140 |
|
| 141 |
[package.extras]
|
| 142 |
+
all = ["email-validator (>=2.0.0)", "fastapi-cli[standard] (>=0.0.5)", "httpx (>=0.23.0)", "itsdangerous (>=1.1.0)", "jinja2 (>=2.11.2)", "orjson (>=3.2.1)", "pydantic-extra-types (>=2.0.0)", "pydantic-settings (>=2.0.0)", "python-multipart (>=0.0.7)", "pyyaml (>=5.3.1)", "ujson (>=4.0.1,!=4.0.2,!=4.1.0,!=4.2.0,!=4.3.0,!=5.0.0,!=5.1.0)", "uvicorn[standard] (>=0.12.0)"]
|
| 143 |
+
standard = ["email-validator (>=2.0.0)", "fastapi-cli[standard] (>=0.0.5)", "httpx (>=0.23.0)", "jinja2 (>=2.11.2)", "python-multipart (>=0.0.7)", "uvicorn[standard] (>=0.12.0)"]
|
| 144 |
|
| 145 |
[[package]]
|
| 146 |
name = "gunicorn"
|
|
|
|
| 197 |
|
| 198 |
[[package]]
|
| 199 |
name = "httpx"
|
| 200 |
+
version = "0.27.2"
|
| 201 |
description = "The next generation HTTP client."
|
| 202 |
optional = false
|
| 203 |
python-versions = ">=3.8"
|
| 204 |
files = [
|
| 205 |
+
{file = "httpx-0.27.2-py3-none-any.whl", hash = "sha256:7bb2708e112d8fdd7829cd4243970f0c223274051cb35ee80c03301ee29a3df0"},
|
| 206 |
+
{file = "httpx-0.27.2.tar.gz", hash = "sha256:f7c2be1d2f3c3c3160d441802406b206c2b76f5947b11115e6df10c6c65e66c2"},
|
| 207 |
]
|
| 208 |
|
| 209 |
[package.dependencies]
|
|
|
|
| 219 |
cli = ["click (==8.*)", "pygments (==2.*)", "rich (>=10,<14)"]
|
| 220 |
http2 = ["h2 (>=3,<5)"]
|
| 221 |
socks = ["socksio (==1.*)"]
|
| 222 |
+
zstd = ["zstandard (>=0.18.0)"]
|
| 223 |
|
| 224 |
[[package]]
|
| 225 |
name = "idna"
|
|
|
|
| 576 |
[metadata]
|
| 577 |
lock-version = "2.0"
|
| 578 |
python-versions = "^3.12"
|
| 579 |
+
content-hash = "c649fb9bb9f491a8e37b1caabd580211b40aa702b7ab32fa81e1a1f1f6124307"
|
pyproject.toml
CHANGED
|
@@ -1,14 +1,28 @@
|
|
| 1 |
[tool.poetry]
|
| 2 |
-
name = "mediaflow
|
| 3 |
-
version = "1.
|
| 4 |
description = "A high-performance proxy server for streaming media, supporting HTTP(S), HLS, and MPEG-DASH with real-time DRM decryption."
|
| 5 |
authors = ["mhdzumair <mhdzumair@gmail.com>"]
|
| 6 |
readme = "README.md"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
[tool.poetry.dependencies]
|
| 9 |
python = "^3.12"
|
| 10 |
-
fastapi = "^0.112.
|
| 11 |
-
httpx = {extras = ["socks"], version = "^0.27.
|
| 12 |
tenacity = "^9.0.0"
|
| 13 |
xmltodict = "^0.13.0"
|
| 14 |
cachetools = "^5.4.0"
|
|
@@ -25,5 +39,8 @@ black = "^24.8.0"
|
|
| 25 |
requires = ["poetry-core"]
|
| 26 |
build-backend = "poetry.core.masonry.api"
|
| 27 |
|
|
|
|
|
|
|
|
|
|
| 28 |
[tool.black]
|
| 29 |
line-length = 120
|
|
|
|
| 1 |
[tool.poetry]
|
| 2 |
+
name = "mediaflow-proxy"
|
| 3 |
+
version = "1.4.0"
|
| 4 |
description = "A high-performance proxy server for streaming media, supporting HTTP(S), HLS, and MPEG-DASH with real-time DRM decryption."
|
| 5 |
authors = ["mhdzumair <mhdzumair@gmail.com>"]
|
| 6 |
readme = "README.md"
|
| 7 |
+
homepage = "https://github.com/mhdzumair/mediaflow-proxy"
|
| 8 |
+
repository = "https://github.com/mhdzumair/mediaflow-proxy"
|
| 9 |
+
documentation = "https://github.com/mhdzumair/mediaflow-proxy#readme"
|
| 10 |
+
keywords = ["proxy", "media", "streaming", "hls", "dash", "drm"]
|
| 11 |
+
license = "MIT"
|
| 12 |
+
classifiers = [
|
| 13 |
+
"Development Status :: 4 - Beta",
|
| 14 |
+
"Intended Audience :: Developers",
|
| 15 |
+
"License :: OSI Approved :: MIT License",
|
| 16 |
+
"Programming Language :: Python :: 3",
|
| 17 |
+
"Programming Language :: Python :: 3.12",
|
| 18 |
+
]
|
| 19 |
+
include = ["LICENSE", "README.md", "mediaflow_proxy/static/*"]
|
| 20 |
+
|
| 21 |
|
| 22 |
[tool.poetry.dependencies]
|
| 23 |
python = "^3.12"
|
| 24 |
+
fastapi = "^0.112.2"
|
| 25 |
+
httpx = {extras = ["socks"], version = "^0.27.2"}
|
| 26 |
tenacity = "^9.0.0"
|
| 27 |
xmltodict = "^0.13.0"
|
| 28 |
cachetools = "^5.4.0"
|
|
|
|
| 39 |
requires = ["poetry-core"]
|
| 40 |
build-backend = "poetry.core.masonry.api"
|
| 41 |
|
| 42 |
+
[tool.poetry.scripts]
|
| 43 |
+
mediaflow-proxy = "mediaflow_proxy.main:run"
|
| 44 |
+
|
| 45 |
[tool.black]
|
| 46 |
line-length = 120
|