from flask import Blueprint, redirect, request
import requests

skyit_bp = Blueprint('skyit', __name__)

@skyit_bp.route('/skyit')
def skyitredirect():
    channel = request.args.get('channel', 1)

    params = {
        'id': f'{channel}',
        'isMobile': 'false',
    }

    response = requests.get(f'https://apid.sky.it/vdp/v1/getLivestream', params=params).json()

    url = response["streaming_url"]
    return redirect(url)
