Skip to content

Commit 83ce83a

Browse files
committed
feat: Implement format and quality settings
1 parent 3fcf1b9 commit 83ce83a

8 files changed

Lines changed: 214 additions & 0 deletions

File tree

locales/en.ftl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,20 @@ setting-instance = custom instance
4646
setting-instance-unset = disabled
4747
setting-instance-custom = override
4848
49+
setting-video-format = video format
50+
setting-video-format-h264 = mp4 (h264)
51+
setting-video-format-h265 = mp4 (h265)
52+
setting-video-format-av1 = webm (av1)
53+
setting-video-format-vp9 = webm (vp9)
54+
setting-video-quality = video quality
55+
56+
setting-audio-format = audio format
57+
setting-audio-format-best = best possible
58+
setting-audio-format-mp3 = mp3
59+
setting-audio-format-ogg = ogg
60+
setting-audio-format-wav = wav
61+
setting-audio-format-opus = opus
62+
setting-audio-quality = audio bitrate
63+
4964
stats-personal = i helped you with downloading { $count } times! (˶ᵔ ᵕ ᵔ˶)
5065
stats-global = i helped with downloading { $count } times! (˶ᵔ ᵕ ᵔ˶)

locales/ru.ftl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,11 @@ setting-instance = кастомный инстанс
4141
setting-instance-unset = выключен
4242
setting-instance-custom = настроить
4343
44+
setting-video-format = формат видео
45+
setting-video-quality = качество видео
46+
setting-audio-format = формат аудио
47+
setting-audio-format-best = наилучший
48+
setting-audio-quality = битрейт аудио
49+
4450
stats-personal = я помог тебе с загрузкой { $count } раз! (˶ᵔ ᵕ ᵔ˶)
4551
stats-global = я помог с загрузкой { $count } раз! (˶ᵔ ᵕ ᵔ˶)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
ALTER TABLE settings ADD `video_format` text DEFAULT 'h264' NOT NULL;--> statement-breakpoint
2+
ALTER TABLE settings ADD `video_quality` text DEFAULT '1080' NOT NULL;--> statement-breakpoint
3+
ALTER TABLE settings ADD `audio_format` text DEFAULT 'mp3' NOT NULL;--> statement-breakpoint
4+
ALTER TABLE settings ADD `audio_quality` text DEFAULT '128' NOT NULL;

migrations/meta/0002_snapshot.json

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
{
2+
"version": "5",
3+
"dialect": "sqlite",
4+
"id": "bc28f23d-3c68-4763-b3d8-3e7361f9d4f3",
5+
"prevId": "8f524a1e-29ad-4518-88f2-435c6a3114f0",
6+
"tables": {
7+
"requests": {
8+
"name": "requests",
9+
"columns": {
10+
"id": {
11+
"name": "id",
12+
"type": "text",
13+
"primaryKey": true,
14+
"notNull": true,
15+
"autoincrement": false
16+
},
17+
"author_id": {
18+
"name": "author_id",
19+
"type": "integer",
20+
"primaryKey": false,
21+
"notNull": true,
22+
"autoincrement": false
23+
},
24+
"url": {
25+
"name": "url",
26+
"type": "text",
27+
"primaryKey": false,
28+
"notNull": true,
29+
"autoincrement": false
30+
}
31+
},
32+
"indexes": {},
33+
"foreignKeys": {},
34+
"compositePrimaryKeys": {},
35+
"uniqueConstraints": {}
36+
},
37+
"settings": {
38+
"name": "settings",
39+
"columns": {
40+
"id": {
41+
"name": "id",
42+
"type": "integer",
43+
"primaryKey": true,
44+
"notNull": true,
45+
"autoincrement": false
46+
},
47+
"output": {
48+
"name": "output",
49+
"type": "text",
50+
"primaryKey": false,
51+
"notNull": false,
52+
"autoincrement": false
53+
},
54+
"attribution": {
55+
"name": "attribution",
56+
"type": "integer",
57+
"primaryKey": false,
58+
"notNull": true,
59+
"autoincrement": false,
60+
"default": 0
61+
},
62+
"language": {
63+
"name": "language",
64+
"type": "text",
65+
"primaryKey": false,
66+
"notNull": false,
67+
"autoincrement": false
68+
},
69+
"instance": {
70+
"name": "instance",
71+
"type": "text",
72+
"primaryKey": false,
73+
"notNull": false,
74+
"autoincrement": false
75+
},
76+
"video_format": {
77+
"name": "video_format",
78+
"type": "text",
79+
"primaryKey": false,
80+
"notNull": true,
81+
"autoincrement": false,
82+
"default": "'h264'"
83+
},
84+
"video_quality": {
85+
"name": "video_quality",
86+
"type": "text",
87+
"primaryKey": false,
88+
"notNull": true,
89+
"autoincrement": false,
90+
"default": "'1080'"
91+
},
92+
"audio_format": {
93+
"name": "audio_format",
94+
"type": "text",
95+
"primaryKey": false,
96+
"notNull": true,
97+
"autoincrement": false,
98+
"default": "'mp3'"
99+
},
100+
"audio_quality": {
101+
"name": "audio_quality",
102+
"type": "text",
103+
"primaryKey": false,
104+
"notNull": true,
105+
"autoincrement": false,
106+
"default": "'128'"
107+
}
108+
},
109+
"indexes": {
110+
"settings_id_unique": {
111+
"name": "settings_id_unique",
112+
"columns": [
113+
"id"
114+
],
115+
"isUnique": true
116+
}
117+
},
118+
"foreignKeys": {},
119+
"compositePrimaryKeys": {},
120+
"uniqueConstraints": {}
121+
},
122+
"users": {
123+
"name": "users",
124+
"columns": {
125+
"id": {
126+
"name": "id",
127+
"type": "integer",
128+
"primaryKey": true,
129+
"notNull": true,
130+
"autoincrement": false
131+
},
132+
"downloads": {
133+
"name": "downloads",
134+
"type": "integer",
135+
"primaryKey": false,
136+
"notNull": false,
137+
"autoincrement": false,
138+
"default": 0
139+
}
140+
},
141+
"indexes": {
142+
"users_id_unique": {
143+
"name": "users_id_unique",
144+
"columns": [
145+
"id"
146+
],
147+
"isUnique": true
148+
}
149+
},
150+
"foreignKeys": {},
151+
"compositePrimaryKeys": {},
152+
"uniqueConstraints": {}
153+
}
154+
},
155+
"enums": {},
156+
"_meta": {
157+
"schemas": {},
158+
"tables": {},
159+
"columns": {}
160+
}
161+
}

migrations/meta/_journal.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@
1515
"when": 1736519894021,
1616
"tag": "0001_eminent_ultron",
1717
"breakpoints": true
18+
},
19+
{
20+
"idx": 2,
21+
"version": "5",
22+
"when": 1744796917670,
23+
"tag": "0002_cuddly_pet_avengers",
24+
"breakpoints": true
1825
}
1926
]
2027
}

src/core/data/db/schema.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,8 @@ export const settings = sqliteTable("settings", {
1717
preferredAttribution: int("attribution").notNull().default(0),
1818
languageOverride: text("language"),
1919
instanceOverride: text("instance"),
20+
videoFormat: text("video_format").notNull().default("h264"),
21+
videoQuality: text("video_quality").notNull().default("1080"),
22+
audioFormat: text("audio_format").notNull().default("mp3"),
23+
audioQuality: text("audio_quality").notNull().default("128"),
2024
})

src/core/data/settings.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ export const defaultSettings: Settings = {
1414
preferredAttribution: 0,
1515
languageOverride: null,
1616
instanceOverride: null,
17+
videoFormat: "h264",
18+
videoQuality: "1080",
19+
audioFormat: "mp3",
20+
audioQuality: "128",
1721
}
1822

1923
export const settingOptions: {
@@ -23,6 +27,10 @@ export const settingOptions: {
2327
preferredAttribution: [0, 1],
2428
languageOverride: [null, ...locales],
2529
instanceOverride: [null, customValue],
30+
videoFormat: ["h264", "h265", "av1", "vp9"],
31+
videoQuality: ["144", "240", "360", "480", "720", "1080", "1440", "2160", "max"],
32+
audioFormat: ["best", "mp3", "ogg", "wav", "opus"],
33+
audioQuality: ["8", "64", "96", "128", "256", "320"],
2634
}
2735

2836
export const settingI18n: {
@@ -32,6 +40,10 @@ export const settingI18n: {
3240
preferredAttribution: { key: "attribution", mode: "translatable" },
3341
languageOverride: { key: "lang", mode: "translatable" },
3442
instanceOverride: { key: "instance", mode: "literal" },
43+
videoFormat: { key: "video-format", mode: "translatable" },
44+
videoQuality: { key: "video-quality", mode: "literal" },
45+
audioFormat: { key: "audio-format", mode: "translatable" },
46+
audioQuality: { key: "audio-quality", mode: "literal" },
3547
}
3648

3749
export async function getSettings(id: number): Promise<Settings> {

src/telegram/helpers/handler.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ export async function handleMediaDownload(outputType: string, request: MediaRequ
107107
const params: Omit<CobaltDownloadParams, "url"> = {
108108
downloadMode: outputType,
109109
filenameStyle: "basic",
110+
youtubeVideoCodec: settings.videoFormat === "h265" ? "h264" : settings.videoFormat,
111+
tiktokH265: settings.videoFormat === "h265",
112+
videoQuality: settings.videoQuality,
113+
audioFormat: settings.audioFormat,
114+
audioBitrate: settings.audioQuality,
110115
}
111116
const res = await finishRequest(request, params, endpoints)
112117
if (!res.success)

0 commit comments

Comments
 (0)