Spaces:
Sleeping
Sleeping
Commit ·
cc97aaf
1
Parent(s): bc1735b
init
Browse files- cookies.json +0 -0
- index.ts +24 -1
cookies.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
index.ts
CHANGED
|
@@ -89,7 +89,7 @@ app.post('/search-stream', async (req: Request, res: Response) => {
|
|
| 89 |
try {
|
| 90 |
// Extract query from request body
|
| 91 |
const { query } = req.body
|
| 92 |
-
|
| 93 |
if (!query) {
|
| 94 |
return res.status(400).json({ error: 'Query is required' })
|
| 95 |
}
|
|
@@ -126,6 +126,29 @@ app.post('/search-stream', async (req: Request, res: Response) => {
|
|
| 126 |
|
| 127 |
// console.log(firstSong)
|
| 128 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
// Get stream URL
|
| 130 |
const stream = await ystream.stream(`https://www.youtube.com/watch?v=` + firstSong.videoId, {
|
| 131 |
quality: 'high',
|
|
|
|
| 89 |
try {
|
| 90 |
// Extract query from request body
|
| 91 |
const { query } = req.body
|
| 92 |
+
|
| 93 |
if (!query) {
|
| 94 |
return res.status(400).json({ error: 'Query is required' })
|
| 95 |
}
|
|
|
|
| 126 |
|
| 127 |
// console.log(firstSong)
|
| 128 |
|
| 129 |
+
|
| 130 |
+
const ystreamAgent = new ystream.YTStreamAgent([{
|
| 131 |
+
key: 'SOCS',
|
| 132 |
+
value: 'CAI',
|
| 133 |
+
domain: 'youtube.com',
|
| 134 |
+
expires: 'Infinity',
|
| 135 |
+
sameSite: 'lax',
|
| 136 |
+
httpOnly: false,
|
| 137 |
+
hostOnly: false,
|
| 138 |
+
secure: true,
|
| 139 |
+
path: '/'
|
| 140 |
+
}], {
|
| 141 |
+
localAddress: '0.0.0.0',
|
| 142 |
+
keepAlive: true,
|
| 143 |
+
keepAliveMsecs: 5e3
|
| 144 |
+
})
|
| 145 |
+
|
| 146 |
+
ystreamAgent.syncFile(__dirname + "/cookies.json")
|
| 147 |
+
|
| 148 |
+
ystream.setGlobalAgent(ystreamAgent)
|
| 149 |
+
ystream.userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:133.0) Gecko/20100101 Firefox/133.0"
|
| 150 |
+
|
| 151 |
+
|
| 152 |
// Get stream URL
|
| 153 |
const stream = await ystream.stream(`https://www.youtube.com/watch?v=` + firstSong.videoId, {
|
| 154 |
quality: 'high',
|