all repos — fixyoutube-go @ a463db2dc3d1b2e9bbe391a4b2db4a173d21b347

A better way to embed YouTube videos everywhere (inspired by FixTweet).

invidious/queries.go (view raw)

 1package invidious
 2
 3const createQueryVideos = `
 4CREATE TABLE IF NOT EXISTS videos (
 5    videoId TEXT PRIMARY KEY,
 6    title TEXT NOT NULL,
 7    description TEXT NOT NULL,
 8    uploader TEXT NOT NULL,
 9    duration int NOT NULL,
10    timestamp_column DATETIME DEFAULT (datetime('now'))
11);`
12
13const createQueryFormats = `
14CREATE TABLE IF NOT EXISTS formats (
15    videoId TEXT,
16	name TEXT,
17    height TEXT NOT NULL,
18    width TEXT NOT NULL,
19    url TEXT,
20	PRIMARY KEY (videoId, name),
21	FOREIGN KEY(videoId) REFERENCES videos(videoId)
22);`
23
24const getVideoQuery = "SELECT * FROM videos WHERE videoId = (?) AND timestamp_column > ?;"
25const getFormatQuery = "SELECT * FROM formats WHERE videoId = (?)"
26
27const cacheVideoQuery = "INSERT OR REPLACE INTO videos (videoId, title, description, uploader, duration) VALUES (?, ?, ?, ?, ?);"
28const cacheFormatQuery = "INSERT OR REPLACE INTO formats (videoId, name, height, width, url) VALUES (?, ?, ?, ?, ?);"
29
30const clearQuery = "DELETE FROM videos;"