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

feat: save youtube thumbnail info (WIP) #35263

Closed

Conversation

rpenido
Copy link
Contributor

@rpenido rpenido commented Aug 8, 2024

Description

This is a proof of concept PR to discuss the best way to store the YouTube thumbnails for the Video XBlock

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Aug 8, 2024
@openedx-webhooks
Copy link

Thanks for the pull request, @rpenido!

What's next?

Please work through the following steps to get your changes ready for engineering review:

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.

🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads

🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

🔘 Update the status of your PR

Your PR is currently marked as a draft. After completing the steps above, update its status by clicking "Ready for Review", or removing "WIP" from the title, as appropriate.

🔘 Let us know that your PR is ready for review:

Who will review my changes?

This repository is currently maintained by @openedx/wg-maintenance-edx-platform. Tag them in a comment and let them know that your changes are ready for review.

Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@rpenido rpenido force-pushed the rpenido/add-youtube-thumbnails branch from a9246f2 to 6c948d6 Compare August 8, 2024 20:42
@@ -645,6 +645,9 @@ def editor_saved(self, user, old_metadata, old_content): # lint-amnesty, pylint
if val_youtube_id and self.youtube_id_1_0 != val_youtube_id:
self.youtube_id_1_0 = val_youtube_id

if not self.edx_video_id and self.youtube_id_1_0:
self.thumbnail = f"https://img.youtube.com/vi/{self.youtube_id_1_0}/sddefault.jpg"
Copy link
Contributor

Choose a reason for hiding this comment

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

The only probably I can see with this is with the edge case in which:

  1. The user explicitly sets the thumbnail to a value in OLX; and...
  2. The user changes some video metadata, but not the actual YouTube video location.

In that case, we would not want to override the explicit thumbnail they set with the YouTube default.

Whatever you end up writing though, please add thorough comments explaining why this is okay to do, since this logic would not be obvious to someone who isn't familiar with some of the weirdness of VideoBlock.

Copy link
Contributor

Choose a reason for hiding this comment

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

Then we can also add and not self.thumbnail to the check?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Then we can also add and not self.thumbnail to the check?

This will prevent the thumbnail from being updated if the YouTube URL changes. Also, we are not cleaning the thumbnail if we change the URL (i.e. from a YouTube video for a stream)

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, right. Then I think it's better to never save this thumbnail value into the thumbnail field - besides that means that existing videos without thumbnails won't show up unless they are edited and saved. Instead, every time index_dictionary() is called, return self.thumbnail or (autodetect youtube URL if applicable) or None but don't save it into the self.thumbnail field.

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 advantage of saving it is that it can be used in other places, like the block editor (which works out of the box).
image

Another option would be to create a new thumbnail_youtube field to store this data and add a getter to the thumbnail property using the thumbnail field as a fallback.

def get_thumbnail(self):
  return self.thumbnail or self.thumbnail_youtube

Copy link
Contributor

Choose a reason for hiding this comment

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

If we store it and the user change the YouTube URL, will we be able to automatically update the thumbnail_youtube field?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. We already have the logic to handle it with the youtube_id_1_0 field.

@rpenido
Copy link
Contributor Author

rpenido commented Sep 11, 2024

Closing this as this is part of a Discovery

@rpenido rpenido closed this Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
open-source-contribution PR author is not from Axim or 2U
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants