import os

from dotenv import load_dotenv
from dateutil.parser import parse
from sqlmodel import Session, select, SQLModel, create_engine
import requests

from youtube.models import YouTube

load_dotenv()

YT_CHANNEL = os.environ["YT_CHANNEL"]
YOUTUBE_API_KEY = os.environ["YOUTUBE_API_KEY"]
DATABASE_URL = os.environ["DATABASE_URL"]

YOUTUBE_VIDEO = "youtube#video"
BASE_URL = (
    "https://www.googleapis.com/youtube/v3/search?key={key}"
    "&channelId={channel}&part=snippet,id&order=date&maxResults=20"
)


engine = create_engine(DATABASE_URL, echo=False)


def get_session():
    with Session(engine) as session:
        yield session


def create_db_and_tables():
    