diff options
author | Christopher Rosell <chrippa@tanuki.se> | 2012-07-05 15:06:04 +0200 |
---|---|---|
committer | Christopher Rosell <chrippa@tanuki.se> | 2012-07-05 15:06:04 +0200 |
commit | 1c3db3ea3c8d843f178fa6a5400705e6fe29b925 (patch) | |
tree | f2c4ed989eeb0223547a42695d8fa29fd46298e4 /src/livestreamer/plugins/youtube.py | |
parent | 6db1dc81c2bf5efab4329c17a09f9ee1985cdc5e (diff) |
Smoother JSON checks.
Diffstat (limited to 'src/livestreamer/plugins/youtube.py')
-rw-r--r-- | src/livestreamer/plugins/youtube.py | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/livestreamer/plugins/youtube.py b/src/livestreamer/plugins/youtube.py index 88ae6de..804ddbc 100644 --- a/src/livestreamer/plugins/youtube.py +++ b/src/livestreamer/plugins/youtube.py @@ -3,7 +3,7 @@ from livestreamer.compat import str, bytes, parse_qs from livestreamer.plugins import Plugin, PluginError, NoStreamsError, register_plugin from livestreamer.stream import HTTPStream -from livestreamer.utils import urlget +from livestreamer.utils import urlget, verifyjson import re import json @@ -61,20 +61,18 @@ class Youtube(Plugin): if not info: raise NoStreamsError(self.url) - if "args" in info: - args = info["args"] - else: - raise PluginError("JSON data is missing 'args' key") + args = verifyjson(info, "args") if not "live_playback" in args or args["live_playback"] == "0": raise NoStreamsError(self.url) - if not ("url_encoded_fmt_stream_map" in args and "fmt_list" in args): - raise PluginError("JSON data is missing 'url_encoded_fmt_stream_map' or 'fmt_list' keys") - streams = {} - streammap = self._parse_stream_map(args["url_encoded_fmt_stream_map"]) - formatmap = self._parse_format_map(args["fmt_list"]) + + uestreammap = verifyjson(args, "url_encoded_fmt_stream_map") + fmtlist = verifyjson(args, "fmt_list") + + streammap = self._parse_stream_map(uestreammap) + formatmap = self._parse_format_map(fmtlist) for streaminfo in streammap: if not "url" in streaminfo: |