Removed useless comments and imports
This commit is contained in:
parent
3520912aae
commit
fe2ef49c74
@ -36,8 +36,6 @@ async def compress_image(image_path: str):
|
|||||||
|
|
||||||
size_before = path.getsize(image_path) / 1024
|
size_before = path.getsize(image_path) / 1024
|
||||||
|
|
||||||
# system(f"exiftool -overwrite_original -all:all= -tagsFromFile @ -exif:Orientation {image_path}")
|
|
||||||
|
|
||||||
if image_type == "image/jpeg":
|
if image_type == "image/jpeg":
|
||||||
task = Thread(target=system, kwargs={"command": f'jpegoptim "{image_path}" -o --max=55 -p --strip-none'})
|
task = Thread(target=system, kwargs={"command": f'jpegoptim "{image_path}" -o --max=55 -p --strip-none'})
|
||||||
elif image_type == "image/png":
|
elif image_type == "image/png":
|
||||||
@ -73,10 +71,6 @@ async def photo_upload(file: UploadFile, album: str, ignore_duplicates: bool = F
|
|||||||
|
|
||||||
if col_albums.find_one( {"user": current_user.user, "name": album} ) is None:
|
if col_albums.find_one( {"user": current_user.user, "name": album} ) is None:
|
||||||
raise AlbumNameNotFoundError(album)
|
raise AlbumNameNotFoundError(album)
|
||||||
# raise HTTPException(status_code=HTTP_404_NOT_FOUND, detail=f"Provided album '{album}' does not exist.")
|
|
||||||
|
|
||||||
# if not file.content_type.startswith("image"):
|
|
||||||
# raise HTTPException(status_code=HTTP_406_NOT_ACCEPTABLE, detail="Provided file is not an image, not accepting.")
|
|
||||||
|
|
||||||
makedirs(path.join("data", "users", current_user.user, "albums", album), exist_ok=True)
|
makedirs(path.join("data", "users", current_user.user, "albums", album), exist_ok=True)
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from classes.exceptions import UserAlreadyExists, UserCredentialsInvalid, UserEmailCodeInvalid
|
from classes.exceptions import UserAlreadyExists, UserCredentialsInvalid, UserEmailCodeInvalid
|
||||||
from classes.models import EmailConfirmed
|
|
||||||
from modules.database import col_users, col_albums, col_photos, col_emails, col_videos, col_emails
|
from modules.database import col_users, col_albums, col_photos, col_emails, col_videos, col_emails
|
||||||
from modules.app import app
|
from modules.app import app
|
||||||
from modules.utils import configGet, logWrite
|
from modules.utils import configGet, logWrite
|
||||||
|
@ -8,7 +8,6 @@ from datetime import datetime, timezone
|
|||||||
from os import makedirs, path, remove
|
from os import makedirs, path, remove
|
||||||
from classes.exceptions import AlbumNameNotFoundError, SearchPageInvalidError, SearchTokenInvalidError, VideoNotFoundError, VideoSearchQueryEmptyError
|
from classes.exceptions import AlbumNameNotFoundError, SearchPageInvalidError, SearchTokenInvalidError, VideoNotFoundError, VideoSearchQueryEmptyError
|
||||||
from classes.models import Video, SearchResultsVideo, VideoPublic
|
from classes.models import Video, SearchResultsVideo, VideoPublic
|
||||||
#from modules.unified_exif_reader import extract_location
|
|
||||||
from modules.security import User, get_current_active_user
|
from modules.security import User, get_current_active_user
|
||||||
from modules.app import app
|
from modules.app import app
|
||||||
from modules.database import col_videos, col_albums, col_tokens
|
from modules.database import col_videos, col_albums, col_tokens
|
||||||
@ -29,9 +28,6 @@ async def video_upload(file: UploadFile, album: str, caption: Union[str, None] =
|
|||||||
if col_albums.find_one( {"user": current_user.user, "name": album} ) is None:
|
if col_albums.find_one( {"user": current_user.user, "name": album} ) is None:
|
||||||
raise AlbumNameNotFoundError(album)
|
raise AlbumNameNotFoundError(album)
|
||||||
|
|
||||||
# if not file.content_type.startswith("video"):
|
|
||||||
# raise HTTPException(status_code=HTTP_406_NOT_ACCEPTABLE, detail="Provided file is not a video, not accepting.")
|
|
||||||
|
|
||||||
makedirs(path.join("data", "users", current_user.user, "albums", album), exist_ok=True)
|
makedirs(path.join("data", "users", current_user.user, "albums", album), exist_ok=True)
|
||||||
|
|
||||||
filename = file.filename
|
filename = file.filename
|
||||||
@ -44,19 +40,10 @@ async def video_upload(file: UploadFile, album: str, caption: Union[str, None] =
|
|||||||
with open(path.join("data", "users", current_user.user, "albums", album, filename), "wb") as f:
|
with open(path.join("data", "users", current_user.user, "albums", album, filename), "wb") as f:
|
||||||
f.write(await file.read())
|
f.write(await file.read())
|
||||||
|
|
||||||
# file_hash = await get_phash(path.join("data", "users", current_user.user, "albums", album, filename))
|
# Hashing and duplicates check should be here
|
||||||
# duplicates = await get_duplicates(file_hash, album)
|
|
||||||
|
|
||||||
# if len(duplicates) > 0 and ignore_duplicates is False:
|
# Coords extraction should be here
|
||||||
# return UJSONResponse(
|
|
||||||
# {
|
|
||||||
# "detail": "video duplicates found. Pass 'ignore_duplicates=true' to ignore.",
|
|
||||||
# "duplicates": duplicates
|
|
||||||
# },
|
|
||||||
# status_code=HTTP_409_CONFLICT
|
|
||||||
# )
|
|
||||||
|
|
||||||
#coords = extract_location(path.join("data", "users", current_user.user, "albums", album, filename))
|
|
||||||
uploaded = col_videos.insert_one(
|
uploaded = col_videos.insert_one(
|
||||||
{
|
{
|
||||||
"user": current_user.user,
|
"user": current_user.user,
|
||||||
@ -66,12 +53,7 @@ async def video_upload(file: UploadFile, album: str, caption: Union[str, None] =
|
|||||||
"uploaded": datetime.now(tz=timezone.utc),
|
"uploaded": datetime.now(tz=timezone.utc),
|
||||||
"modified": datetime.now(tz=timezone.utc)
|
"modified": datetime.now(tz=timezone.utc)
|
||||||
},
|
},
|
||||||
"caption": caption,
|
"caption": caption
|
||||||
# "location": [
|
|
||||||
# coords["lng"],
|
|
||||||
# coords["lat"],
|
|
||||||
# coords["alt"]
|
|
||||||
# ]
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user