- with opener.open(master_url) as resp:
- if resp.status == 200:
- lines = resp.read().decode('utf-8').splitlines()
- streams = parse_master(lines)
- if streams:
- winner = max(streams, key = lambda s: s.attrs['RESOLUTION'].vertical)
- (ep, curr_variant) = re.match(r'(.*)_(.*?)\.m3u8$', winner.uri).groups()
- assert ep == stream_spec.endpoint
- else:
- assert resp.status == 404
- time.sleep(_DELAY.total_seconds())
+ try:
+ resp = opener.open(master_url)
+ except tuple(IGNORE_EXCEPTIONS):
+ pass
+ else:
+ with resp:
+ if resp.status == 200:
+ lines = resp.read().decode('utf-8').splitlines()
+ streams = parse_master(lines)
+ if streams:
+ winner = max(streams, key = lambda s: s.attrs['RESOLUTION'].vertical)
+ (ep, curr_variant) = re.match(r'(.*)_(.*?)\.m3u8$', winner.uri).groups()
+ assert ep == stream_spec.endpoint
+ else:
+ assert resp.status == 404