···11+-- Add up migration script here
22+CREATE VIEW video_metadata_view AS SELECT
33+ metadata->>'fulltitle' title,
44+ metadata->>'duration' duration,
55+ metadata->>'channel' channel,
66+ metadata->>'id' AS id,
77+ metadata->>'upload_date' AS upload_date,
88+ metadata->>'view_count' AS views,
99+ video_path
1010+FROM videos ORDER BY concat(video_path, title) DESC;
+1-1
readme.md
···2626### Why not deconstruct the json metadata into database columns?
2727The youtube-dl / yt-dlp json metadata schema does not appear to be stable, and as such, **all data could not reliably be serialized into standardized columns**. Different versions of these tools may also have generated and attached different data. Since SQLite makes it trivial to work with json, and in an effort to preserve as much of this data as possible, the whole of the json data is parsed, validated, and inserted into the database.
28282929-However, for convenience, it may make sense to offer a [table view](https://sqlite.org/lang_createview.html) that extracts much of the metadata as fields as so ease in querying
2929+However, for convenience, the `video_metadata_view` [table view](https://sqlite.org/lang_createview.html) may also be used for ease of querying.
30303131### Why SQLite? Why not a Key-value store database? or a document database?
3232With the current schema consisting of only two colums: `video_path` & `metadata`, one might argue this job would be a better fit for a Key-value database, like Redis or one of it's many open-source derivatives, or a document database such as MongoDB to better fit the unstructured nature of the json metadata.