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

Download indexed videos #10

Merged
merged 8 commits into from
Jan 31, 2024

Conversation

kieraneglin
Copy link
Owner

@kieraneglin kieraneglin commented Jan 31, 2024

What's new?

A lot.

  • Adds new MediaMetadata model for storing things like full yt-dlp responses
  • Adds a MetadataParser module for yt-dlp to interpret the JSON response
  • Adds media_item_id to the Tasks model
  • Adds a new worker to handle downloading videos async
  • Adds methods for fetching yet-to-be downloaded MediaItems for processing
  • Adds random_string helper method
  • Adds method on main Repo module to help with Oban job insertion - this insert_unique_job method returns an error tuple if a job would've created a duplicate

What's changed?

  • Updates create_task, delete_tasks_for, and delete_pending_tasks_for to work with MediaItems
  • Transmogrifies download_for_media_profile into download_for_media_item since I had no use for the former. Now, it takes a given MediaItem and downloads its media based on the settings from the MediaProfile
  • Updated yt-dlp runner module to take a third argument of its output template. More on that Below.

What's fixed?

  • I was previously reading yt-dlps stdout to parse its output, but that's no good. It would emit warnings sometimes and would attempt to parse those. Surprise, didn't work! Now, output is written to a tmpfile (on disk) and that file is immediately re-read and its contents parsed. The biggest practical change is that the runner now takes a 3rd argument that specifies the output template (reference) which is what's returned from the runner
  • Fixes yt-dlp runner args parser so that it appends flags instead of preprending them. This old behaviour broke yt-dlps multi-part args by adding them out of order

Any other comments?

N/A

Adding the metadata model made me realize that, in many cases, yt-dlp
returns undesired input in stdout, breaking parsing. In order to get
the metadata model working, I had to change the way in which the app
interacts with yt-dlp. Now, output is written as a file to disk which
is immediately re-read and returned.
@kieraneglin kieraneglin self-assigned this Jan 31, 2024
@kieraneglin kieraneglin added bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request media downloads media categorization labels Jan 31, 2024
@kieraneglin kieraneglin merged commit b202b3b into ke/download-a-video-v1 Jan 31, 2024
@kieraneglin kieraneglin deleted the ke/download-indexed-media branch January 31, 2024 03:42
@kieraneglin kieraneglin added this to the Download First Video(s) milestone Jan 31, 2024
kieraneglin added a commit that referenced this pull request Jan 31, 2024
* Updated package.json (and made an excuse to make a branch)

* Video filepath parser (#6)

* Restructured files; Added parser placeholder

* More restructuring

* Added basic parser for hydrating template strings

* Improved docs

* More docs

* Initial implementation of media profiles (#7)

* [WIP] Added basic video download method

* [WIP] Very-WIP first steps at parsing options and downloading

* Made my options safe by default and removed special safe versions

* Ran html generator for mediaprofile model - leaving as-is for now

* Addressed a bunch of TODO comments

* Add "channel" type Media Source (#8)

* [WIP] Working on fetching channel metadata in yt-dlp backend

* Finished first draft of methods to do with querying channels

* Renamed CommandRunnerMock to have a more descriptive name

* Ran the phx generator for the channel model

* Renamed Downloader namespace to MediaClient

* [WIP] saving before attempting LiveView

* LiveView did not work out but here's a working controller how about

* Index a channel (#9)

* Ran a MediaItem generator; Reformatted to my liking

* [WIP] added basic index function

* setup oban

* Added basic Oban job for indexing

* Added in workers for indexing; hooked them into record creation flow

* Added a task model with a phx generator

* Tied together tasks with jobs and channels

* Download indexed videos (#10)

* Clarified documentation

* more comments

* [WIP] hooked up basic video downloading; starting work on metadata

* Added metadata model and parsing

Adding the metadata model made me realize that, in many cases, yt-dlp
returns undesired input in stdout, breaking parsing. In order to get
the metadata model working, I had to change the way in which the app
interacts with yt-dlp. Now, output is written as a file to disk which
is immediately re-read and returned.

* Added tests for video download worker

* Hooked up video downloading to the channel indexing pipeline

* Adds tasks for media items

* Updated video metadata parser to extract the title

* Ran linting
kieraneglin added a commit that referenced this pull request Mar 29, 2024
* Updated package.json (and made an excuse to make a branch)

* Video filepath parser (#6)

* Restructured files; Added parser placeholder

* More restructuring

* Added basic parser for hydrating template strings

* Improved docs

* More docs

* Initial implementation of media profiles (#7)

* [WIP] Added basic video download method

* [WIP] Very-WIP first steps at parsing options and downloading

* Made my options safe by default and removed special safe versions

* Ran html generator for mediaprofile model - leaving as-is for now

* Addressed a bunch of TODO comments

* Add "channel" type Media Source (#8)

* [WIP] Working on fetching channel metadata in yt-dlp backend

* Finished first draft of methods to do with querying channels

* Renamed CommandRunnerMock to have a more descriptive name

* Ran the phx generator for the channel model

* Renamed Downloader namespace to MediaClient

* [WIP] saving before attempting LiveView

* LiveView did not work out but here's a working controller how about

* Index a channel (#9)

* Ran a MediaItem generator; Reformatted to my liking

* [WIP] added basic index function

* setup oban

* Added basic Oban job for indexing

* Added in workers for indexing; hooked them into record creation flow

* Added a task model with a phx generator

* Tied together tasks with jobs and channels

* Download indexed videos (#10)

* Clarified documentation

* more comments

* [WIP] hooked up basic video downloading; starting work on metadata

* Added metadata model and parsing

Adding the metadata model made me realize that, in many cases, yt-dlp
returns undesired input in stdout, breaking parsing. In order to get
the metadata model working, I had to change the way in which the app
interacts with yt-dlp. Now, output is written as a file to disk which
is immediately re-read and returned.

* Added tests for video download worker

* Hooked up video downloading to the channel indexing pipeline

* Adds tasks for media items

* Updated video metadata parser to extract the title

* Ran linting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request media categorization media downloads
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant