Spaces:
Running
Running
rippanteq7
commited on
Commit
•
c7c40f2
1
Parent(s):
9cf0039
Update Cobalt API instance
Browse files
index.js
CHANGED
@@ -52,7 +52,7 @@ const utils = {
|
|
52 |
fetchCobaltAPI: async (url, opts = {}) =>
|
53 |
(
|
54 |
await utils.fetchPOST(
|
55 |
-
'https://
|
56 |
JSON.stringify({ url, ...opts }),
|
57 |
{
|
58 |
headers: {
|
@@ -409,16 +409,16 @@ app.all(/^\/y(outube|t)(\/(d(ownload|l)|search)?)?/, async (req, res) => {
|
|
409 |
if (!utils.ytIdRegex.test(obj.url))
|
410 |
return res.status(400).json({ success: false, message: 'Invalid url' })
|
411 |
|
412 |
-
const payload = {
|
413 |
if (obj.type === 'audio') {
|
414 |
-
payload.
|
415 |
-
|
416 |
} else {
|
417 |
-
payload.
|
418 |
}
|
419 |
|
420 |
const result = await utils.fetchCobaltAPI(obj.url, payload)
|
421 |
-
if (result.
|
422 |
return res
|
423 |
.status(400)
|
424 |
.json({ success: false, message: 'An error occurred' })
|
@@ -460,4 +460,4 @@ app.all(/^\/y(outube|t)(\/(d(ownload|l)|search)?)?/, async (req, res) => {
|
|
460 |
// app.use((req, res, next) => {})
|
461 |
|
462 |
const PORT = process.env.PORT || 7860
|
463 |
-
app.listen(PORT, () => console.log(`App running on port ${PORT}`))
|
|
|
52 |
fetchCobaltAPI: async (url, opts = {}) =>
|
53 |
(
|
54 |
await utils.fetchPOST(
|
55 |
+
'https://c.blahaj.ca/',
|
56 |
JSON.stringify({ url, ...opts }),
|
57 |
{
|
58 |
headers: {
|
|
|
409 |
if (!utils.ytIdRegex.test(obj.url))
|
410 |
return res.status(400).json({ success: false, message: 'Invalid url' })
|
411 |
|
412 |
+
const payload = { filenameStyle: 'pretty' }
|
413 |
if (obj.type === 'audio') {
|
414 |
+
payload.audioBitrate = obj.quality || '128'
|
415 |
+
payload.downloadMode = 'audio'
|
416 |
} else {
|
417 |
+
payload.videoQuality = obj.quality || '720'
|
418 |
}
|
419 |
|
420 |
const result = await utils.fetchCobaltAPI(obj.url, payload)
|
421 |
+
if (!result.url)
|
422 |
return res
|
423 |
.status(400)
|
424 |
.json({ success: false, message: 'An error occurred' })
|
|
|
460 |
// app.use((req, res, next) => {})
|
461 |
|
462 |
const PORT = process.env.PORT || 7860
|
463 |
+
app.listen(PORT, () => console.log(`App running on port ${PORT}`))
|