py3 fixes for restreamer

pull/224/head
Mike Lang 3 years ago committed by Mike Lang
parent 6a98addac8
commit 9fad66c6be

@ -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:

@ -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('.'):

Loading…
Cancel
Save