Updated with Movistar channels

This commit is contained in:
Joan
2024-10-13 10:58:06 +02:00
parent b4788a22e3
commit 622d36700c
10 changed files with 3746 additions and 36 deletions

View File

@@ -0,0 +1,9 @@
FROM python:3.11
RUN mkdir /app
ADD . /app
RUN pip install -r /app/requirements.txt
WORKDIR /app
CMD [ "python", "/app/proxy.py" ]

36
proxy_movistar/proxy.py Normal file
View File

@@ -0,0 +1,36 @@
import http.server
import socketserver
import requests
from urllib.parse import urlparse, urlunparse
import logging
logging.basicConfig(
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO
)
PROXY_PORT = 8080
HEADER_TO_MODIFY = "Content-Type"
NEW_HEADER_VALUE = "application/dash+xml"
class ProxyHandler(http.server.BaseHTTPRequestHandler):
def do_GET(self):
url_parsed = urlparse(self.path[1:])
try:
response = requests.get(urlunparse(url_parsed))
modified_headers = dict(response.headers)
modified_headers[HEADER_TO_MODIFY] = NEW_HEADER_VALUE
self.send_response(response.status_code)
for header, value in modified_headers.items():
self.send_header(header, value)
self.end_headers()
self.wfile.write(response.content)
except requests.RequestException as e:
self.send_error(502, f"Error al contactar el servidor de destino: {e}")
with socketserver.TCPServer(("", PROXY_PORT), ProxyHandler) as httpd:
logging.info(f"Proxy corriendo en el puerto {PROXY_PORT}")
httpd.serve_forever()

View File

@@ -0,0 +1 @@
requests==2.32.2