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

html5 transcript exists #9924

Merged
merged 1 commit into from
Nov 6, 2015

Conversation

Shrhawk
Copy link
Contributor

@Shrhawk Shrhawk commented Sep 28, 2015

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 no html5_subs present for html5_resources then create new html5_subs.

@Shrhawk
Copy link
Contributor Author

Shrhawk commented Sep 30, 2015

jenkins run bokchoy

@Shrhawk Shrhawk force-pushed the shr/bug/TNL-3168-import_from_youtube_html5_subs branch 2 times, most recently from 73f0f3e to c386011 Compare October 8, 2015 13:47
@Shrhawk
Copy link
Contributor Author

Shrhawk commented Oct 8, 2015

@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:
Copy link
Contributor

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')

Copy link
Contributor Author

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)

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.

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.

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 ?

Copy link
Contributor Author

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.

@Shrhawk
Copy link
Contributor Author

Shrhawk commented Oct 22, 2015

@muzaffaryousaf, @muhammad-ammar kindly review !

@Shrhawk
Copy link
Contributor Author

Shrhawk commented Oct 26, 2015

@muzaffaryousaf kindly review !

@muzaffaryousaf
Copy link

@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'])

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 ?

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.

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.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great !!

@muzaffaryousaf
Copy link

@Shrhawk I'm done with first pass, let me know when you are done with changes.
Thanks.

@Shrhawk
Copy link
Contributor Author

Shrhawk commented Oct 30, 2015

@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)
Copy link
Contributor Author

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 !

@adampalay
Copy link
Contributor

@Shrhawk , looks like you need to address 3 quality violations:

19:58:32 common/lib/xmodule/xmodule/video_module/video_module.py (94.4%):
19:58:32     432: C7630: (literal-used-as-attribute), VideoDescriptor.editor_saved: getattr using a literal attribute name
19:58:32 lms/djangoapps/courseware/tests/test_video_mongo.py (97.3%):
19:58:32     895: E1120: (no-value-for-parameter), TestEditorSavedMethod.setUp: No value for argument 'self' in unbound method call
19:58:32     905: C0103: (invalid-name), TestEditorSavedMethod.test_editor_saved_when_html5_sub_not_exist: Invalid attribute name "MODULESTORE"

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'):

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

@muzaffaryousaf
Copy link

@Shrhawk 👍 Good to go once you fix the quality issue and one inline comment & don't forget to squash the commits. Thanks.

@Shrhawk
Copy link
Contributor Author

Shrhawk commented Nov 2, 2015

@adampalay done thumps up ?

@Shrhawk Shrhawk force-pushed the shr/bug/TNL-3168-import_from_youtube_html5_subs branch 2 times, most recently from 1587512 to 378b332 Compare November 2, 2015 13:43
# 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', []):
Copy link
Contributor

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.

Copy link
Contributor Author

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 !

@Shrhawk Shrhawk force-pushed the shr/bug/TNL-3168-import_from_youtube_html5_subs branch from 340a02b to f92a766 Compare November 3, 2015 12:51
# 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', []))
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice finding :)

@adampalay
Copy link
Contributor

not sure why tests failed...

@Shrhawk
Copy link
Contributor Author

Shrhawk commented Nov 4, 2015

jenkins run python

@Shrhawk
Copy link
Contributor Author

Shrhawk commented Nov 4, 2015

jenkins run bokchoy

@Shrhawk
Copy link
Contributor Author

Shrhawk commented Nov 5, 2015

@adampalay tests are passing now !!

@adampalay
Copy link
Contributor

@Shrhawk you still need to squash your commits. Then 👍

@Shrhawk Shrhawk force-pushed the shr/bug/TNL-3168-import_from_youtube_html5_subs branch from 26685f9 to a8c8053 Compare November 6, 2015 11:33
Shrhawk added a commit that referenced this pull request Nov 6, 2015
@Shrhawk Shrhawk merged commit ab8aedc into master Nov 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants