import requests


def add_videos_to_playlist(playlist_id: str, video_ids: list, auth: str, cookie: str, key: str) -> int:
    """Add YouTube videos corresponding to the given video ids to a playlist with the given playlist id.

    Args:
        playlist_id (str): ID of a YouTube playlist you want to add videos to (your own playlist)
        video_ids (list): list with IDs of the videos you want to add to the playlist
        auth (str): HTTP header needed for authorization
        cookie (str): HTTP header needed for authorization
        key (str): key needed for authorization

    Returns:
        int: status code for the HTTP request to YouTube
    """

    headers = {
        "User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:92.0) Gecko/20100101 Firefox/92.0",
        "Content-Type": "application/json",
        "Authorization": auth,
        "Origin": "https://www.youtube.com",
        "Cookie": cookie
    }

    body = {
        'playlistId': playlist_id,
        'actions': [
            {
                'action': 'ACTION_ADD_VIDEO',
                'addedVideoId': v,
                'dedupeOption': 'DEDUPE_OPTION_SKIP'  # Else returns error when duplicate found
            } for v in video_ids
        ]
    }

    context = {
        "context": {
            "client": {
                "clientName": "WEB_REMIX",
                "clientVersion": "0.1",
            },
        }
    }

    body.update(context)

    response = requests.post(f'https://www.youtube.com/youtubei/v1/browse/edit_playlist?key={key}',
                             json=body,
                             headers=headers)

    return response.status_code