Updated with Movistar channels
This commit is contained in:
9
proxy_movistar/Dockerfile
Normal file
9
proxy_movistar/Dockerfile
Normal 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
36
proxy_movistar/proxy.py
Normal 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()
|
||||
1
proxy_movistar/requirements.txt
Normal file
1
proxy_movistar/requirements.txt
Normal file
@@ -0,0 +1 @@
|
||||
requests==2.32.2
|
||||
Reference in New Issue
Block a user