Skip to content

Commit

Permalink
actually upload
Browse files Browse the repository at this point in the history
  • Loading branch information
oscie57 committed Jun 2, 2024
1 parent a247916 commit c7fa773
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions theunderground/movies.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from theunderground.mobiclip import (
get_category_list,
validate_mobiclip,
validate_mobi_dsi,
get_mobiclip_length,
save_movie_data,
delete_movie_data,
Expand Down Expand Up @@ -62,9 +63,11 @@ def add_movie():

if dsmovie:
dsmovie_data = dsmovie[0].read()
validation_ds = validate_mobi_dsi(dsmovie_data)
genre = 1
else:
genre = 0
validation_ds = False

if validate_mobiclip(movie_data):
# Get the Mobiclip's length from header.
Expand All @@ -82,24 +85,14 @@ def add_movie():
staff=False,
)

if dsmovie:
if dsmovie and validation_ds:
db_movie.ds_mov_id = db_movie.movie_id

db.session.add(db_movie)
db.session.commit()

# Now that we've inserted the movie, we can properly move it.
save_movie_data(db_movie.movie_id, thumbnail_data, movie_data)

# Save the DS movie if it exists to /dsmov/{get_movie_path}/{movie_id}.enc
# NOT on s3

if dsmovie:
dsmovie_dir = get_movie_path(db_movie.movie_id)
dsmovie_path = f"{dsmovie_dir}/{db_movie.movie_id}.enc"

with open(dsmovie_path, "wb") as f:
f.write(dsmovie_data)
save_movie_data(db_movie.movie_id, thumbnail_data, movie_data, dsmovie_data if dsmovie and validation_ds else None)

# Finally update the category if needed by S3
if s3:
Expand Down

0 comments on commit c7fa773

Please sign in to comment.