From 9fad66c6bee6234d6bafe149950aefff711123fa Mon Sep 17 00:00:00 2001 From: Mike Lang Date: Sat, 4 Sep 2021 17:29:46 +1000 Subject: [PATCH] py3 fixes for restreamer --- restreamer/restreamer/generate_hls.py | 4 ++-- restreamer/restreamer/main.py | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/restreamer/restreamer/generate_hls.py b/restreamer/restreamer/generate_hls.py index 835daa2..d43417a 100644 --- a/restreamer/restreamer/generate_hls.py +++ b/restreamer/restreamer/generate_hls.py @@ -1,6 +1,6 @@ import datetime import os -import urllib +import urllib.parse from collections import Counter @@ -70,7 +70,7 @@ def generate_media(segments, base_url): path = '/'.join(segment.path.split('/')[-2:]) lines.append("#EXT-X-PROGRAM-DATE-TIME:{}".format(segment.start.strftime("%Y-%m-%dT%H:%M:%S.%fZ"))) lines.append("#EXTINF:{:.3f},live".format(segment.duration.total_seconds())) - lines.append(urllib.quote(os.path.join(base_url, path))) + lines.append(urllib.parse.quote(os.path.join(base_url, path))) # If stream is complete, add an ENDLIST marker to show this. if not incomplete: diff --git a/restreamer/restreamer/main.py b/restreamer/restreamer/main.py index 70509de..e45aa2f 100644 --- a/restreamer/restreamer/main.py +++ b/restreamer/restreamer/main.py @@ -19,7 +19,7 @@ from common import dateutil, get_best_segments, rough_cut_segments, fast_cut_seg from common.flask_stats import request_stats, after_request from common.segments import feed_input -import generate_hls +from . import generate_hls app = Flask('restreamer', static_url_path='/segments') @@ -53,11 +53,10 @@ def listdir(path, error=True): def has_path_args(fn): """Decorator to wrap routes which take args which are to be used as parts of a filepath. - Disallows hidden folders and path traversal, and converts unicode to bytes. + Disallows hidden folders and path traversal. """ @functools.wraps(fn) def _has_path_args(**kwargs): - kwargs = {key: value.encode('utf-8') for key, value in kwargs.items()} for key, value in kwargs.items(): # Disallowing a leading . prevents both hidden files and path traversal ("..") if value.startswith('.'):