"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.StreamingPlaylistsCommand = void 0;
const tslib_1 = require("tslib");
const core_utils_1 = require("../../core-utils");
const requests_1 = require("../requests");
const shared_1 = require("../shared");
class StreamingPlaylistsCommand extends shared_1.AbstractCommand {
    get(options) {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            const { videoFileToken, reinjectVideoFileToken, withRetry, currentRetry = 1 } = options;
            try {
                const result = yield (0, requests_1.unwrapTextOrDecode)(this.getRawRequest(Object.assign(Object.assign({}, options), { url: options.url, query: {
                        videoFileToken,
                        reinjectVideoFileToken
                    }, implicitToken: false, defaultExpectedStatus: 200 })));
                return result;
            }
            catch (err) {
                if (!withRetry || currentRetry > 5)
                    throw err;
                yield (0, core_utils_1.wait)(100);
                return this.get(Object.assign(Object.assign({}, options), { withRetry, currentRetry: currentRetry + 1 }));
            }
        });
    }
    getFragmentedSegment(options) {
        return (0, requests_1.unwrapBody)(this.getRawRequest(Object.assign(Object.assign({}, options), { url: options.url, range: options.range, implicitToken: false, defaultExpectedStatus: 200 })));
    }
    getSegmentSha256(options) {
        return (0, requests_1.unwrapBodyOrDecodeToJSON)(this.getRawRequest(Object.assign(Object.assign({}, options), { url: options.url, implicitToken: false, defaultExpectedStatus: 200 })));
    }
}
exports.StreamingPlaylistsCommand = StreamingPlaylistsCommand;
//# sourceMappingURL=streaming-playlists-command.js.map