From 7d642251c8d664eb3f7d396f76933a0b2c843a33 Mon Sep 17 00:00:00 2001 From: Anton Avramov Date: Mon, 19 Jul 2021 13:35:34 -0400 Subject: [PATCH 1/2] Fix create directories if they doesn't exists. Sometimes filenames includes directory structure --- dashproxy.py | 1 + 1 file changed, 1 insertion(+) diff --git a/dashproxy.py b/dashproxy.py index 5482ef6..ff5a52a 100755 --- a/dashproxy.py +++ b/dashproxy.py @@ -261,6 +261,7 @@ def full_url(self, dest): def write(self, dest, content): dest = dest[0:dest.rfind('?')] dest = os.path.join(self.proxy.output_dir, dest) + os.makedirs(os.path.dirname(dest), exist_ok=True) f = open(dest, 'wb') f.write(content) f.close() From b8961b1ed186e81eb896494f335ad655b007dcdd Mon Sep 17 00:00:00 2001 From: Anton Avramov Date: Mon, 19 Jul 2021 13:36:21 -0400 Subject: [PATCH 2/2] Fix if there is no ? in the url rfind would return -1 and trim the last char of the filename --- dashproxy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dashproxy.py b/dashproxy.py index ff5a52a..f0c866e 100755 --- a/dashproxy.py +++ b/dashproxy.py @@ -259,7 +259,7 @@ def full_url(self, dest): return self.mpd_base_url + dest # TODO remove hardcoded arrd def write(self, dest, content): - dest = dest[0:dest.rfind('?')] + dest = dest.split('?')[0] dest = os.path.join(self.proxy.output_dir, dest) os.makedirs(os.path.dirname(dest), exist_ok=True) f = open(dest, 'wb')