def _read_ytdl_file(self, ctx):
    assert ('ytdl_corrupt' not in ctx)
    (stream, _) = self.sanitize_open(self.ytdl_filename(ctx['filename']), 'r')
    try:
        ytdl_data = json.loads(stream.read())
        ctx['fragment_index'] = ytdl_data['downloader']['current_fragment']['index']
        if ('extra_state' in ytdl_data['downloader']):
            ctx['extra_state'] = ytdl_data['downloader']['extra_state']
    except Exception:
        ctx['ytdl_corrupt'] = True
    finally:
        stream.close()
def _read_ytdl_file(self, ctx):
    assert ('ytdl_corrupt' not in ctx)
    (stream, _) = self.sanitize_open(self.ytdl_filename(ctx['filename']), 'r')
    try:
        ytdl_data = json.loads(stream.read())
        ctx['fragment_index'] = ytdl_data['downloader']['current_fragment']['index']
        if ('extra_state' in ytdl_data['downloader']):
            ctx['extra_state'] = ytdl_data['downloader']['extra_state']
    except Exception:
        ctx['ytdl_corrupt'] = True
    finally:
        stream.close()