Skip to content

Commit

Permalink
Merge branch 'master' into manage_video_storage
Browse files Browse the repository at this point in the history
  • Loading branch information
susanodd committed Jan 20, 2025
2 parents ecb9296 + 5382785 commit 334ccf5
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 21 deletions.
4 changes: 2 additions & 2 deletions signbank/dictionary/adminviews.py
Original file line number Diff line number Diff line change
Expand Up @@ -7587,8 +7587,8 @@ def fetch_video_stills_for_gloss(request, gloss_id):

gloss = Gloss.objects.get(id=gloss_id, archived=False)

folder = gloss.idgloss + '-' + gloss_id
folder = folder.replace(' ', '_')
from signbank.video.convertvideo import get_folder_name
folder = get_folder_name(gloss)
temp_location_frames = os.path.join(settings.GLOSS_IMAGE_DIRECTORY, "signbank-thumbnail-frames", folder)
temp_video_frames_folder = os.path.join(settings.WRITABLE_FOLDER,
settings.GLOSS_IMAGE_DIRECTORY, "signbank-thumbnail-frames", folder)
Expand Down
13 changes: 6 additions & 7 deletions signbank/gloss_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ def detect_type_related_problems_for_gloss_update(changes, dataset, language_cod
continue
if field in language_fields:
continue
if field == "Senses":
if field in ['Senses', 'senses']:
continue
if isinstance(field, FieldChoiceForeignKey):
field_choice_category = field.field_choice_category
Expand Down Expand Up @@ -474,17 +474,17 @@ def gloss_update_do_changes(user, gloss, changes, language_code):
handshape = Handshape.objects.get(name__iexact=new_value)
setattr(gloss, field.name, handshape)
changes_done.append((field.name, original_value, new_value))
elif field in ["senses", "Senses"]:
original_senses = collect_revision_history_for_senses(gloss)
update_senses(gloss, new_value)
new_senses = collect_revision_history_for_senses(gloss)
changes_done.append((field.name, original_senses, new_senses))
elif field.name == 'semField':
update_semantic_field(gloss, new_value, language_code)
changes_done.append((field.name, original_value, new_value))
elif field.name == 'derivHist':
update_derivation_history_field(gloss, new_value, language_code)
changes_done.append((field.name, original_value, new_value))
elif field.name == "senses" and isinstance(field, models.ManyToManyField):
original_senses = collect_revision_history_for_senses(gloss)
update_senses(gloss, new_value)
new_senses = collect_revision_history_for_senses(gloss)
changes_done.append((field.name, original_senses, new_senses))
else:
# text field
setattr(gloss, field.name, new_value)
Expand Down Expand Up @@ -522,7 +522,6 @@ def gloss_update(gloss, update_fields_dict, language_code):
dataset = gloss.lemma.dataset
language_fields, api_fields_2024 = api_update_gloss_fields(dataset, language_code)
human_readable_to_internal, human_readable_to_json = update_gloss_columns_to_value_dict_keys(dataset, language_code)

combined_fields = api_fields_2024
for language_field in language_fields:
gloss_dict_language_field = human_readable_to_json[language_field]
Expand Down
22 changes: 12 additions & 10 deletions signbank/video/convertvideo.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,18 @@ def probe_format(file):
return r['inputvideoformat']


def generate_image_sequence(sourcefile):
basename, _ = os.path.splitext(sourcefile.path)
def get_folder_name(gloss):
gloss_video_filename = gloss.idgloss + '-' + str(gloss.id)
filename = gloss_video_filename.replace(' ', '_')
folder_name = filename.replace('.', '-')
return folder_name


def generate_image_sequence(gloss, sourcefile):

temp_location_frames = os.path.join(settings.WRITABLE_FOLDER,
settings.GLOSS_IMAGE_DIRECTORY, "signbank-thumbnail-frames")
filename, ext = os.path.splitext(os.path.basename(sourcefile.name))
filename = filename.replace(' ', '_')
folder_name, _ = os.path.splitext(filename)
folder_name = get_folder_name(gloss)
temp_video_frames_folder = os.path.join(temp_location_frames, folder_name)
# Create the necessary subfolder if needed
if not os.path.isdir(temp_location_frames):
Expand All @@ -156,13 +161,10 @@ def generate_image_sequence(sourcefile):
return stills


def remove_stills(sourcefile):
basename, _ = os.path.splitext(sourcefile.path)
def remove_stills(gloss):
temp_location_frames = os.path.join(settings.WRITABLE_FOLDER,
settings.GLOSS_IMAGE_DIRECTORY, "signbank-thumbnail-frames")
filename, ext = os.path.splitext(os.path.basename(sourcefile.name))
filename = filename.replace(' ', '_')
folder_name, _ = os.path.splitext(filename)
folder_name = get_folder_name(gloss)
temp_video_frames_folder = os.path.join(temp_location_frames, folder_name)
# remove the temp files
stills_pattern = temp_video_frames_folder+"/*.png"
Expand Down
4 changes: 2 additions & 2 deletions signbank/video/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -703,11 +703,11 @@ def small_video(self, use_name=False):

def make_image_sequence(self):

generate_image_sequence(self.videofile)
generate_image_sequence(self.gloss, self.videofile)

def delete_image_sequence(self):

remove_stills(self.videofile)
remove_stills(self.gloss)

def make_small_video(self):
# this method is not called (bugs)
Expand Down

0 comments on commit 334ccf5

Please sign in to comment.