-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
html5 transcript exists #9924
html5 transcript exists #9924
Conversation
jenkins run bokchoy |
73f0f3e
to
c386011
Compare
@adampalay @waheedahmed @mushtaqak have a review ! |
@@ -424,6 +424,16 @@ def editor_saved(self, user, old_metadata, old_content): | |||
This should be fixed too. | |||
""" | |||
metadata_was_changed_by_user = old_metadata != own_metadata(self) | |||
# If metadata is not changed by user and html5_sub does not exist. | |||
if self.sub and old_metadata.get('html5_sources', []) and not metadata_was_changed_by_user: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why old_metadata.get('html5_sources', [])
? Why not old_metadata.get('html5_sources', False)
or just old_metadata.get('html5_sources')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok will replace with old_metadata.get('html5_sources', False)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
html5_sources
is a list and i prefer to set the default values accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
old_metadata.get('html5_sources')
this is fine too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you shed some light on this self.sub
, what's the purpose ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The purpose of self.sub
is to check that there should transcript attached to video and then we will sure this this part of code will only run when there is already transcript present because we need transcript for copy or renaming with different htmls_id.
@muzaffaryousaf, @muhammad-ammar kindly review ! |
@muzaffaryousaf kindly review ! |
@Shrhawk Sure. I will take a look in early morning. |
@@ -424,6 +424,16 @@ def editor_saved(self, user, old_metadata, old_content): | |||
This should be fixed too. | |||
""" | |||
metadata_was_changed_by_user = old_metadata != own_metadata(self) | |||
# If metadata is not changed by user and html5_sub does not exist. | |||
if self.sub and old_metadata.get('html5_sources', []) and not metadata_was_changed_by_user: | |||
html5_ids = get_html5_ids(old_metadata['html5_sources']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Shrhawk Do we have unit test coverage for this newly added code, if not, can we add some unit tests ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NVM, i see you have added the tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we get html5_sources
from self/item instead of old_metadata
because manage_video_subtitles_save
uses item.html5_sources
method instead of old_metadata
to copy/rename, if values are different for both the result will be unexpected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same call is happening in manage_video_subtitles_save
method, it will be nice if we can reduce the call, somehow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great !!
@Shrhawk I'm done with first pass, let me know when you are done with changes. |
@muzaffaryousaf i have make changes kindly review it ! |
self.test_dir = path(__file__).abspath().dirname().dirname().dirname().dirname().dirname() | ||
self.file_path = self.test_dir + '/common/test/data/uploads/' + self.file_name | ||
|
||
@ddt.data(TEST_DATA_MONGO_MODULESTORE, TEST_DATA_SPLIT_MODULESTORE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adampalay add both module-stores as you suggested !
@Shrhawk , looks like you need to address 3 quality violations:
Otherwise, this looks good. |
# then there is a syncing issue where html5_subs are not syncing with youtube sub, We can make sync better by | ||
# checking if transcript is present for the video and if any html5_ids transcript is not present then trigger | ||
# the manage_video_subtitles_save to create the missing transcript with particular html5_id. | ||
if not metadata_was_changed_by_user and self.sub and getattr(self, 'html5_sources'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Shrhawk getattr(self, 'html5_sources')
will raise AttributeError
if self
don't have html5_sources
attribute.
https://docs.python.org/2/library/functions.html#getattr
@Shrhawk 👍 Good to go once you fix the quality issue and one inline comment & don't forget to squash the commits. Thanks. |
@adampalay done thumps up ? |
1587512
to
378b332
Compare
# then there is a syncing issue where html5_subs are not syncing with youtube sub, We can make sync better by | ||
# checking if transcript is present for the video and if any html5_ids transcript is not present then trigger | ||
# the manage_video_subtitles_save to create the missing transcript with particular html5_id. | ||
if not metadata_was_changed_by_user and self.sub and getattr(self, 'html5_sources', []): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since []
if falsey, you should instead use hasattr(self, 'html5_sources')
. Then in the next line, you don't need to use getattr
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done @adampalay have a review again !
340a02b
to
f92a766
Compare
# checking if transcript is present for the video and if any html5_ids transcript is not present then trigger | ||
# the manage_video_subtitles_save to create the missing transcript with particular html5_id. | ||
if not metadata_was_changed_by_user and self.sub and hasattr(self, 'html5_sources'): | ||
html5_ids = get_html5_ids(getattr(self, 'html5_sources', [])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you've already checked that self
has html5_sources
, so you don't need getattr
here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice finding :)
not sure why tests failed... |
jenkins run python |
jenkins run bokchoy |
@adampalay tests are passing now !! |
@Shrhawk you still need to squash your commits. Then 👍 |
26685f9
to
a8c8053
Compare
…e_html5_subs html5 transcript exists
TNL-3168
Steps to Reproduce:
1.Create a video component with youtube and html(mp4) url
2.Save the component
3.Edit the component and click import from youtube(transcript)
4.Go to assets page of an course (transcript with youtube_id only)
Problem:
editor_saved is not syncing subs for an edge case above.
Solution:
At editor_saved check if
youtube_sub
already exists and there is nohtml5_subs
present for html5_resources then create newhtml5_subs
.