Skip to content

feat: export video metadata#905

Open
Zibbp wants to merge 3 commits into
mainfrom
export-ganymede-metadata
Open

feat: export video metadata#905
Zibbp wants to merge 3 commits into
mainfrom
export-ganymede-metadata

Conversation

@Zibbp

@Zibbp Zibbp commented Oct 8, 2025

Copy link
Copy Markdown
Owner

Add a task to export the Ganymede metadata of a video. This is stored in a non-standard (not following storage templates) file as this is meant to be a special "metadata" file not part of the archive and exclusive to Ganymede.

Still need to figure out versioning and how it would work with future or modified fields.

export a ganymede.json video metadata file
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @Zibbp, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a significant new feature that allows for the export of detailed video metadata. This functionality is crucial for backup purposes and for facilitating the migration of video data to other instances. The changes encompass both frontend and backend, providing a user-triggerable and automatically scheduled mechanism to generate structured JSON files containing video information and its related entities.

Highlights

  • Video Metadata Export Task: A new task has been introduced to export comprehensive video metadata, including associated channels, playlists, chapters, and muted segments, into a JSON file.
  • Frontend Integration: A new button has been added to the admin tasks page, allowing users to manually trigger the video metadata export task.
  • Backend Implementation: Core logic for fetching and structuring video metadata has been implemented in a new internal/vod/export.go file, utilizing DTO conversions for various entities.
  • Automated Scheduling: The metadata export task is scheduled to run automatically once daily at 01:00.
  • New Dependency: The github.com/jinzhu/copier library has been added to facilitate object-to-object data transfer (DTO conversions).
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new feature to export video metadata as a JSON file. The implementation includes a new background task, UI elements on the admin page, and DTO conversions for various entities. The changes are well-structured. My review includes suggestions to improve performance by batching database queries in the new worker, enhance code clarity and consistency in function signatures and data structures, and address a minor style issue. I've also noted a point about the use of the copier library, suggesting manual mapping for better performance and safety.

Comment on lines +457 to +469
vods, err := store.Client.Vod.Query().Select(entVod.FieldID).All(ctx)
if err != nil {
return fmt.Errorf("failed to fetch videos: %w", err)
}

for _, v := range vods {
err := vodService.ExportMetadata(ctx, v)
if err != nil {
logger.Error().Err(err).Msgf("failed to export metadata for video %s", v.ID)
continue
}
logger.Debug().Msgf("exported metadata for video %s", v.ID)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

This implementation fetches all VODs from the database at once. If there is a large number of videos, this could lead to high memory consumption and potentially cause the task to exceed its 5-minute timeout. It would be more robust to process the videos in batches. A similar batching pattern is used in UpdateVideoStorageUsageWorker.

    const batchSize = 100
	offset := 0
	for {
		vods, err := store.Client.Vod.Query().
			Select(entVod.FieldID).
			Limit(batchSize).
			Offset(offset).
			All(ctx)
		if err != nil {
			return fmt.Errorf("failed to fetch videos: %w", err)
		}
		if len(vods) == 0 {
			break
		}

		for _, v := range vods {
			err := vodService.ExportMetadata(ctx, v)
			if err != nil {
				logger.Error().Err(err).Msgf("failed to export metadata for video %s", v.ID)
				continue
			}
			logger.Debug().Msgf("exported metadata for video %s", v.ID)
		}
		offset += batchSize
	}

Comment thread internal/tasks/worker/worker.go Outdated
Comment thread internal/vod/export.go
Comment thread internal/vod/export.go Outdated
Comment on lines +30 to +33
func (s *Service) ExportMetadata(ctx context.Context, video *ent.Vod) error {
vod, err := s.Store.Client.Vod.
Query().
Where(entVod.IDEQ(video.ID)).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The function ExportMetadata takes video *ent.Vod as an argument, but it only uses video.ID to immediately re-query the database for the full VOD object. It would be clearer and more explicit to change the function signature to accept a videoID uuid.UUID directly. This makes the function's dependency explicit. You'll also need to update the call site in internal/tasks/periodic/periodic.go.

Suggested change
func (s *Service) ExportMetadata(ctx context.Context, video *ent.Vod) error {
vod, err := s.Store.Client.Vod.
Query().
Where(entVod.IDEQ(video.ID)).
func (s *Service) ExportMetadata(ctx context.Context, videoID uuid.UUID) error {
vod, err := s.Store.Client.Vod.
Query().
Where(entVod.IDEQ(videoID)).

Comment thread internal/vod/vod.go Outdated
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.

1 participant