Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ds mov uploading? #71

Merged
merged 7 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions theunderground/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def validate_new_password(self, _):

class MovieUploadForm(FlaskForm):
movie = FileField("Movie", validators=[FileRequired()])
dsmovie = FileField("DS Movie")
title = StringField("Movie title", validators=[DataRequired(), Length(max=48)])
thumbnail = FileField("Movie thumbnail", validators=[FileRequired()])
# Choices for the select field are only evaluated once, so we must set it when necessary.
Expand Down
22 changes: 21 additions & 1 deletion theunderground/movies.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,20 @@ def add_movie():

if form.validate_on_submit():
movie = form.movie.data
dsmovie = form.dsmovie.data
thumbnail = form.thumbnail.data
if movie and thumbnail:
movie_data = movie[0].read()
thumbnail_data = thumbnail[0].read()

if dsmovie:
dsmovie_data = dsmovie[0].read()
ds_mov_id = 2
oscie57 marked this conversation as resolved.
Show resolved Hide resolved
genre = 1
else:
ds_mov_id = None
genre = 0

if validate_mobiclip(movie_data):
# Get the Mobiclip's length from header.
length = get_mobiclip_length(movie_data)
Expand All @@ -70,8 +79,9 @@ def add_movie():
category_id=form.category.data,
length=length,
aspect=True,
genre=0,
genre=genre,
sp_page_id=0,
ds_mov_id=ds_mov_id,
oscie57 marked this conversation as resolved.
Show resolved Hide resolved
staff=False,
)

Expand All @@ -81,6 +91,16 @@ def add_movie():
# 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)

oscie57 marked this conversation as resolved.
Show resolved Hide resolved
# Finally update the category if needed by S3
if s3:
cat_xml = list_category_search(form.category.data)
Expand Down
Loading