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

Refactor metadata_extract.py #257

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

deldesir
Copy link
Collaborator

@deldesir deldesir commented Sep 24, 2024

This pull request refactors the metadata_extract.py file to improve code readability, maintainability, and performance.

Key Changes Introduced:

  • Replaced direct SQLite queries with SQLAlchemy ORM for database interactions.

  • Enhanced logging for better traceability and debugging within the task class.

  • Improved error handling to manage exceptions more gracefully.

  • Refactored the subprocess execution and metadata updating logic.

  • Tested on Ubuntu 24.04

Uses SQLAlchemy...
@deldesir deldesir marked this pull request as draft September 24, 2024 17:00
@deldesir deldesir requested a review from holta September 25, 2024 02:18
@deldesir deldesir self-assigned this Sep 25, 2024
@deldesir deldesir added the enhancement New feature or request label Sep 25, 2024
@deldesir deldesir marked this pull request as ready for review September 25, 2024 02:18
@holta
Copy link
Member

holta commented Sep 25, 2024

How was this tested?

Thanks @deldesir!

Optimization: Removes the for loop for total_duration specifically and incorporated the var into the subsequent for loop. 
Fixes TaskDownload call where session was being passed wrongly.
Cleans up live_status variable.
@deldesir
Copy link
Collaborator Author

How to test

  • Pull the PR following How do I test a pull request (PR) ? instructions.
  • Submit a YouTube video URL via the “Download to IIAB” button and monitor the “Task” page to check whether metadata fetching is reported.
  • On success, verify with datasette to review the extraction with datasette /library/calibre-web/xklb-metadata.db -h 0.0.0.0 -p <PORT_NUMBER> and then point your browser to http:<IIAB_URL>:<PORT_NUMBER>. If metadata are present for the required video, that means the refactoring was effective and functionality is preserved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants