package ctbrec.sites.fc2live;

import java.io.IOException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import ctbrec.Config;
import ctbrec.Model;
import ctbrec.io.HttpClient;
import ctbrec.recorder.download.HlsDownload;

public class Fc2HlsDownload extends HlsDownload {

    private static final transient Logger LOG = LoggerFactory.getLogger(Fc2HlsDownload.class);

    public Fc2HlsDownload(HttpClient client) {
        super(client);
    }

    @Override
    public void start(Model model, Config config) throws IOException {
        Fc2Model fc2Model = (Fc2Model) model;
        try {
            fc2Model.openWebsocket();
            super.start(model, config);
        } catch (InterruptedException e) {
            LOG.error("Couldn't start download for {}", model, e);
        } finally {
            fc2Model.closeWebsocket();
        }
    }

    @Override
    public void stop() {
        super.stop();
    }
}
