from datetime import datetime
import uuid

from sqlalchemy.orm import Session

from src.db.models.media import MediaVideo
from src.webapps.media.forms import AddLinkForm


def create_new_video(video: AddLinkForm, db: Session) -> MediaVideo:
    print(video.url)
    media_video = MediaVideo()
    media_video.id = str(uuid.uuid4())
    media_video.url = str(video.url)
    media_video.created_date = datetime.now()
    media_video.last_modified_date = datetime.now()
    media_video.review = True
    media_video.should_download = True
    db.add(media_video)
    db.commit()
    db.refresh(media_video)
    print(media_video)
    return media_video
