aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/livestreamer/stream.py9
-rw-r--r--src/livestreamer/utils.py4
2 files changed, 6 insertions, 7 deletions
diff --git a/src/livestreamer/stream.py b/src/livestreamer/stream.py
index f72217b..82d9a9a 100644
--- a/src/livestreamer/stream.py
+++ b/src/livestreamer/stream.py
@@ -1,5 +1,5 @@
from .compat import str, is_win32
-from .utils import urlopen
+from .utils import urlget
import os
import pbs
@@ -96,10 +96,9 @@ class HTTPStream(Stream):
self.args = args
def open(self):
- try:
- res = urlopen(self.url, prefetch=False, **self.args)
- except Exception as err:
- raise StreamError(str(err))
+ res = urlget(self.url, prefetch=False,
+ exception=StreamError,
+ **self.args)
return res.raw
diff --git a/src/livestreamer/utils.py b/src/livestreamer/utils.py
index 90b9379..dfee53f 100644
--- a/src/livestreamer/utils.py
+++ b/src/livestreamer/utils.py
@@ -22,14 +22,14 @@ class ArgumentParser(argparse.ArgumentParser):
else:
yield "--%s" % line
-def urlopen(url, method="get", **args):
+def urlopen(url, method="get", exception=PluginError, **args):
if "data" in args and args["data"] is not None:
method = "post"
try:
res = requests.request(method, url, config=RequestsConfig, timeout=15, **args)
except requests.exceptions.RequestException as err:
- raise PluginError(("Unable to open URL: {url} ({err})").format(url=url, err=str(err)))
+ raise exception(("Unable to open URL: {url} ({err})").format(url=url, err=str(err)))
return res